Skip to content

feat(mcp): add describe tool for deployed functions#3744

Open
Ankitsinghsisodya wants to merge 3 commits into
knative:mainfrom
Ankitsinghsisodya:feat/mcp-describe-tool
Open

feat(mcp): add describe tool for deployed functions#3744
Ankitsinghsisodya wants to merge 3 commits into
knative:mainfrom
Ankitsinghsisodya:feat/mcp-describe-tool

Conversation

@Ankitsinghsisodya
Copy link
Copy Markdown
Contributor

Summary

Expose the existing func describe command as an MCP tool so clients can inspect a function’s deployment details (name, image, namespace, routes, subscriptions, etc.) without shelling out manually.

Changes

  • Add describe MCP tool with read-only annotations (DestructiveHint: false, IdempotentHint documented as no side effects).
  • Input: optional path or name (at most one); optional namespace only when name is set; optional output and verbose. Aligns output formats with the CLI (human, plain, json, yaml, url — no xml for describe).
  • Reject invalid combinations before invoking the executor: both path and name, or namespace without a usable name; treat empty strings as unset for path / name / namespace so we never pass a blank positional name.
  • Register the tool in pkg/mcp/mcp.go.
  • Tests: path + flags, name + namespace (same validation style as delete), path+name conflict, namespace without name, and zero-arg describe (current working directory).

Test plan

  • go test ./pkg/mcp/...

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
Copilot AI review requested due to automatic review settings May 15, 2026 00:00
@knative-prow
Copy link
Copy Markdown

knative-prow Bot commented May 15, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Ankitsinghsisodya
Once this PR has been reviewed and has the lgtm label, please assign dsimansk for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@knative-prow knative-prow Bot requested review from dsimansk and jrangelramos May 15, 2026 00:00
@knative-prow knative-prow Bot added size/L 🤖 PR changes 100-499 lines, ignoring generated files. needs-ok-to-test 🤖 Needs an org member to approve testing labels May 15, 2026
@knative-prow
Copy link
Copy Markdown

knative-prow Bot commented May 15, 2026

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 /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Tip

We noticed you've done this a few times! Consider joining the org to skip this step and gain /lgtm and other bot rights. We recommend asking approvers on your previous PRs to sponsor you.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions 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.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 describeTool with DescribeInput/DescribeOutput types and a handler that validates mutually exclusive path/name and requires name when namespace is 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.

Comment thread pkg/mcp/mcp.go Outdated
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
Copy link
Copy Markdown

codecov Bot commented May 15, 2026

Codecov Report

❌ Patch coverage is 88.57143% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 57.02%. Comparing base (e435a89) to head (1f6358c).

Files with missing lines Patch % Lines
pkg/mcp/tools_describe.go 88.23% 3 Missing and 1 partial ⚠️
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     
Flag Coverage Δ
e2e 35.75% <0.00%> (-0.07%) ⬇️
e2e go 32.37% <0.00%> (-0.06%) ⬇️
e2e node 28.15% <0.00%> (-0.06%) ⬇️
e2e python 32.74% <0.00%> (-0.06%) ⬇️
e2e quarkus 28.29% <0.00%> (-0.06%) ⬇️
e2e rust 27.70% <0.00%> (?)
e2e springboot 26.19% <0.00%> (-0.07%) ⬇️
e2e typescript 28.25% <0.00%> (-0.08%) ⬇️
e2e-config-ci 17.67% <0.00%> (-0.04%) ⬇️
integration 17.27% <0.00%> (-0.03%) ⬇️
unit macos-14 45.12% <88.88%> (+0.07%) ⬆️
unit macos-latest 45.12% <88.88%> (+0.07%) ⬆️
unit ubuntu-24.04-arm 45.39% <88.57%> (+0.07%) ⬆️
unit ubuntu-latest 46.08% <88.88%> (+0.07%) ⬆️
unit windows-latest 45.16% <88.88%> (+0.07%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-ok-to-test 🤖 Needs an org member to approve testing size/L 🤖 PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants