feat(mcp): return structured JSON from the 'list' tool - #4001
Open
Ankitsinghsisodya wants to merge 7 commits into
Open
feat(mcp): return structured JSON from the 'list' tool#4001Ankitsinghsisodya wants to merge 7 commits into
Ankitsinghsisodya wants to merge 7 commits into
Conversation
- Introduced the 'describe' tool with support for both path and name parameters. - Updated instructions to clarify the requirements for 'delete' and 'describe' tools. - Added help resources for the 'describe' tool in the MCP server. This enhances the functionality of the MCP by providing a way to describe functions in the cluster.
- Added a new test to verify that the describe handler correctly parses JSON output even when preceded by non-JSON warnings in stderr. - Introduced a new function, parseDescribeOutput, to extract and parse the JSON object from combined stdout+stderr output, ensuring robustness against leading noise. This improves the reliability of the describe tool in real-world scenarios where warnings may be emitted before the JSON payload.
- Added ExecuteSplit method to the executor interface, allowing separate capture of stdout and stderr. - Updated the describe handler to utilize ExecuteSplit, ensuring JSON parsing is unaffected by stderr warnings. - Modified tests to validate the new execution method and its behavior with leading stderr content. This enhancement increases the robustness of the describe tool by preventing stderr noise from interfering with JSON output parsing.
…on rules - Updated the describe tool to include middleware version information in the output. - Added validation to ensure 'namespace' is only valid when describing by 'name', rejecting cases where both 'path' and 'namespace' are provided. - Enhanced documentation to clarify usage and requirements for the describe command. - Added tests to verify the new middleware handling and validation logic. These changes improve the functionality and robustness of the describe tool, ensuring accurate representation of function instances in the cluster.
- Updated the list tool to return structured JSON output, including an `items` array with details of deployed Functions and a `warnings` field for non-fatal issues. - Modified the list handler to utilize separate stdout and stderr capturing, improving error reporting and JSON parsing reliability. - Added tests to ensure correct handling of various output scenarios, including no functions found, empty stdout, and malformed JSON. These changes enhance the usability and robustness of the list tool, providing clearer output and better error management.
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: Ankitsinghsisodya The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
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.
Changes
listMCP tool to return structured JSON (items: name, namespace, runtime, url, ready, deployer; pluswarnings) instead of an opaquemessagestring, following the same "semantic" pattern introduced by thedescribetool in feat(mcp): add 'describe' tool and update documentation #3995--output jsoninternally regardless of caller input, usingExecuteSplitso stderr content can never corrupt the parsed JSON (same rationale asdescribe)--output json) as a valid empty result instead of a parse errorpkg/mcp/instructions.mdto document the newitems/warningsoutput shapeThis follows up on review feedback from #3995 (#3995 (comment)), which identified
listas the highest-priority command to move from the "passthrough" (Message: string) pattern to the "semantic" (structured, parsed) pattern, since it already supports--output json./kind enhancement
Fixes #
Release Note
release-note Changed the `list` MCP tool to return structured JSON (an `items` array with each Function's name, namespace, runtime, url, readiness, and deployer, plus a `warnings` field) instead of raw CLI text output. Docs
docs