You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor: add structured output support and MCP spec compliance (#960)
* refactor(output): add PrintObjStructured to Output interface
Extend the Output interface with a PrintObjStructured method that returns
both a human-readable text representation and optional structured data
extracted from Kubernetes objects. This lays the groundwork for consumers
that need programmatic access to the data alongside the formatted text.
- Add PrintResult struct holding Text and Structured fields
- Implement PrintObjStructured for yaml (returns deep-copied list items
or object map)
- Implement PrintObjStructured for table (extracts column-keyed maps via
tableToStructured helper)
- Refactor table.PrintObj to delegate to printTable for code reuse
- Rewrite output tests to testify/suite pattern with new coverage
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Marc Nuri <marc@marcnuri.com>
* feat(api): add NewToolCallResultFull constructor
Add a NewToolCallResultFull constructor that creates a ToolCallResult with
both human-readable text and structured content as separate fields. Unlike
NewToolCallResultStructured (which JSON-serializes structured data into
Content), this preserves the original text representation (e.g. table or
YAML output) alongside the structured data.
Refactor NewToolCallResult and NewToolCallResultStructured to delegate to
NewToolCallResultFull, making it the single canonical constructor.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Marc Nuri <marc@marcnuri.com>
* fix(mcp): wrap slice structuredContent in object per MCP spec
The MCP specification requires structuredContent to marshal to a JSON
object, but NewStructuredResult could receive slice/array values. Add
ensureStructuredObject to automatically wrap slices in {"items": [...]}
so that the result always complies with the spec.
Typed nil slices (e.g. []string(nil)) are detected via reflect and
return nil to avoid producing {"items": null}.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Marc Nuri <marc@marcnuri.com>
---------
Signed-off-by: Marc Nuri <marc@marcnuri.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
0 commit comments