feat(core): add structuredContent to resources_get and resources_list#1232
Merged
Cali0707 merged 1 commit intoJun 29, 2026
Merged
Conversation
Closed
4 tasks
…_list resources_get and resources_list now return structuredContent alongside the existing text output, enabling programmatic MCP clients to consume K8s objects directly without parsing YAML or table strings. This follows Recipe 1 from docs/specs/structured-output.md, using the PrintObjStructured + NewToolCallResultFull infrastructure already on main (PR containers#960). The text Content field is unchanged -- existing clients that only read Content[0].Text see no difference. For resources_get (single object, always YAML): - StructuredContent is map[string]any (the K8s object) For resources_list (respects --list-output config): - YAML: StructuredContent is {"items": [...]} with each item as map[string]any - Table: StructuredContent is {"items": [...]} with column-keyed maps Refs containers#920 Co-authored-by: Cursor <cursoragent@cursor.com> Signed-off-by: Jordi Gil <jgil@redhat.com> Co-authored-by: Cursor <cursoragent@cursor.com>
jordigilh
force-pushed
the
feat/resources-structured-content
branch
from
June 28, 2026 21:44
2297eb1 to
b28bb03
Compare
Collaborator
|
/run-mcpchecker core |
Contributor
mcpchecker MCP Evaluation ResultsCommit:
Diff vs. Baseline (main)Click to expand mcpchecker diff📊 Evaluation Results
❌ Regressions (2)
|
Cali0707
approved these changes
Jun 29, 2026
Cali0707
left a comment
Collaborator
There was a problem hiding this comment.
LGTM, thanks @jordigilh !
manusa
added a commit
to marcnuri-forks/kubernetes-mcp-server
that referenced
this pull request
Jun 29, 2026
The Recipe 1 status note said the pattern had no in-tree adopter yet. It now does: resources_get/list landed in containers#1232, and this PR converts namespacesList and the pod list tools. Update the note to name those handlers as the canonical reference and drop the stale wording. Also fix the prose that still described namespacesList as unconverted. Signed-off-by: Marc Nuri <marc@marcnuri.com> Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
resources_getandresources_listnow returnstructuredContentalongside the existing text output, enabling programmatic MCP clients to consume K8s objects directly without parsing YAML or table strings.This extracts the K8s resource tool retrofit from #920 as a standalone change, following Recipe 1 from
docs/specs/structured-output.md.Why
We maintain an MCP client (kubernaut) that consumes
resources_getandresources_listprogrammatically to buildunstructured.Unstructuredobjects for fleet metadata caching. Today we have to parse the text content (YAML or table strings) back into structured data, which is fragile and loses type fidelity. WithstructuredContent, our client can consume the K8s object directly asmap[string]any.The infrastructure is already on main (PR #960:
PrintObjStructured,NewToolCallResultFull,ensureStructuredObject) and the structured-output spec documents Recipe 1 as the intended pattern for K8s resource tools — but notes "has no in-tree adopter yet." This PR is that first adopter for the core resource tools.Changes
pkg/toolsets/core/resources.go(2 handlers, ~10 lines changed):resourcesGet:output.MarshalYaml(ret)+NewToolCallResult→output.Yaml.PrintObjStructured(ret)+NewToolCallResultFullresourcesList:params.ListOutput.PrintObj(ret)+NewToolCallResult→params.ListOutput.PrintObjStructured(ret)+NewToolCallResultFullpkg/mcp/resources_test.go(3 new subtests):resources_get returns namespace / returns structured content— assertsStructuredContentis a map withkind,apiVersion,metadata.nameresources_list returns namespaces / returns structured content with items— assertsStructuredContentis{"items": [...]}per MCP spec wrappingresources_list as table / returns structured content from table— asserts table output also producesStructuredContentBackward compatibility
Fully backward compatible. The
Content[0].Textfield is unchanged — existing clients that only read text see no difference.structuredContentis additive per the MCP spec. This is the same pattern used byconfiguration_contexts_list(#1151).Checks
Refs #920
Made with Cursor