feat(mcp): add describe tool for deployed functions#3744
feat(mcp): add describe tool for deployed functions#3744Ankitsinghsisodya wants to merge 3 commits into
Conversation
This commit introduces a new 'describe' tool to the MCP package, allowing users to retrieve detailed information about deployed functions, including name, image, namespace, routes, and event subscriptions. The tool accepts either a local path or a function name as input. Additionally, unit tests have been added to ensure the correct functionality of the describe tool, covering various scenarios such as input validation and expected outputs. - Added describeTool definition in tools_describe.go - Implemented describeHandler to process requests - Created tools_describe_test.go with comprehensive tests for the describe tool This enhancement improves the usability of the MCP by providing a straightforward way to obtain function details.
This commit expands the unit tests for the describe tool, adding checks for both string and boolean flags, and ensuring correct argument validation. The tests now verify that the tool handles positional arguments and flags appropriately, including scenarios with no arguments. Additionally, the describe tool's input validation logic has been refined to clarify the mutual exclusivity of the 'path' and 'name' parameters, and to ensure that the namespace is only valid when a name is provided. - Updated TestTool_Describe_ByName to validate input arguments - Added TestTool_Describe_NoArgs to check behavior with no arguments - Improved input validation in describeHandler for clarity and correctness
|
[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 |
|
Hi @Ankitsinghsisodya. Thanks for your PR. I'm waiting for a knative member to verify that this patch is reasonable to test. If it is, they should reply with Tip We noticed you've done this a few times! Consider joining the org to skip this step and gain Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds a new describe MCP tool that wraps the func describe CLI subcommand, with input validation and tests.
Changes:
- Introduces
describeToolwithDescribeInput/DescribeOutputtypes and a handler that validates mutually exclusivepath/nameand requiresnamewhennamespaceis set. - Registers the new tool in the MCP server.
- Adds tests covering path, name, no-args, and validation error cases.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| pkg/mcp/tools_describe.go | New describe tool definition, input/output types, and handler. |
| pkg/mcp/mcp.go | Registers describeTool with the MCP server. |
| pkg/mcp/tools_describe_test.go | Tests covering describe tool argument passing and validation errors. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| mcp.AddTool(i, createTool, s.createHandler) | ||
| mcp.AddTool(i, buildTool, s.buildHandler) | ||
| mcp.AddTool(i, deployTool, s.deployHandler) | ||
| mcp.AddTool(i, deployTool, s.deployHandler) |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3744 +/- ##
==========================================
+ Coverage 56.95% 57.02% +0.07%
==========================================
Files 181 182 +1
Lines 21116 21151 +35
==========================================
+ Hits 12026 12061 +35
+ Misses 7866 7865 -1
- Partials 1224 1225 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This commit cleans up the MCP tool registration code by removing unnecessary trailing whitespace from the line that adds the deploy tool. This minor adjustment improves code readability and adheres to standard formatting practices.
Summary
Expose the existing
func describecommand as an MCP tool so clients can inspect a function’s deployment details (name, image, namespace, routes, subscriptions, etc.) without shelling out manually.Changes
describeMCP tool with read-only annotations (DestructiveHint: false,IdempotentHintdocumented as no side effects).pathorname(at most one); optionalnamespaceonly whennameis set; optionaloutputandverbose. Alignsoutputformats with the CLI (human,plain,json,yaml,url— noxmlfor describe).pathandname, ornamespacewithout a usablename; treat empty strings as unset forpath/name/namespaceso we never pass a blank positional name.pkg/mcp/mcp.go.delete), path+name conflict, namespace without name, and zero-arg describe (current working directory).Test plan
go test ./pkg/mcp/...