feat(resources): add gotemplate parameter for resources_list and resources_get#918
Open
edcdavid wants to merge 2 commits intocontainers:mainfrom
Open
feat(resources): add gotemplate parameter for resources_list and resources_get#918edcdavid wants to merge 2 commits intocontainers:mainfrom
edcdavid wants to merge 2 commits intocontainers:mainfrom
Conversation
…urces_get - Enhanced the resources_list and resources_get tools to support an optional gotemplate parameter, allowing users to extract specific fields from Kubernetes resources instead of returning full YAML. - Updated descriptions in the input schemas to reflect the new functionality. - Implemented applyGoTemplate function to handle template execution and error management. - Updated the resourcesList function to correctly handle the gotemplate parameter by ensuring that the output is formatted as a table only when the gotemplate is not used. - Enhanced the data structure returned when a gotemplate is specified, ensuring that the items are properly formatted within the response object. This change improves the functionality and output consistency of the resourcesList tool.
a0a077c to
14bbaa4
Compare
1cb6f1f to
481e1d0
Compare
Member
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.
Adds an optional gotemplate parameter (same syntax as oc get -o go-template) that lets callers extract specific fields server-side instead of returning full YAML.
Why: LLMs currently receive entire resource YAML even when they only need one field. This wastes context window tokens and slows down responses. With gotemplate, the LLM declares exactly what it needs and the server returns only that — easily 10-100x fewer tokens for targeted queries.
Benefits:
Token efficiency — {{.status.phase}} returns a single value instead of hundreds of YAML lines
CLI parity — uses the same Go template syntax as oc get -o go-template, so templates are portable between CLI and MCP workflows
Server-side projection — iteration, conditionals, and field extraction run on the server, not in the LLM
Backward compatible — parameter is optional; omitting it preserves existing full-YAML behavior
Examples:
resources_list(kind="Pod", gotemplate="{{range .items}}{{.metadata.name}}\n{{end}}")
resources_get(kind="Application", name="my-app", gotemplate="{{.spec.source.repoURL}}")
Assisted by: Cursor