Skip to content

feat(mcp): add 'describe' tool and update documentation - #3995

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

feat(mcp): add 'describe' tool and update documentation#3995
Ankitsinghsisodya wants to merge 3 commits into
knative:mainfrom
Ankitsinghsisodya:mcp-describe-tool

Conversation

@Ankitsinghsisodya

Copy link
Copy Markdown
Contributor

Changes

  • 🎁 Add a describe MCP tool that wraps func describe --output json and returns structured JSON (name, namespace, URL, routes, image, readiness, deployer, labels, subscriptions, revision) instead of requiring agents to parse text output
  • 🎁 Add a describe help resource and document the tool's path/name mutual-exclusivity in pkg/mcp/instructions.md
  • 🎁 Add tests covering argument passing, JSON parsing, path/name mutual exclusivity, and malformed CLI output handling

/kind enhancement

Fixes #

Release Note

release-note Added a `describe` MCP tool that returns structured JSON (URL, image, namespace, labels, subscriptions, readiness) for a deployed Function, so AI agents no longer need to parse `func describe`'s text output. ​

Docs

​```docs

​```

- 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.
Copilot AI lite review requested due to automatic review settings August 7, 2026 13:48
@knative-prow knative-prow Bot added the kind/enhancement Feature additions or improvements to existing label Aug 7, 2026
@knative-prow
knative-prow Bot requested review from dsimansk and jrangelramos August 7, 2026 13:49
@knative-prow

knative-prow Bot commented Aug 7, 2026

Copy link
Copy Markdown

[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 added the size/L 🤖 PR changes 100-499 lines, ignoring generated files. label Aug 7, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds a new MCP describe tool to expose func describe --output json as structured JSON, updates MCP guidance docs, and introduces unit tests for the new tool so agents don’t need to parse human-formatted CLI output.

Changes:

  • Added describe MCP tool, registered it in the server, and added a matching help resource.
  • Documented describe usage (including path/name mutual exclusivity) in pkg/mcp/instructions.md.
  • Added tests covering argument passing, JSON parsing, and validation errors.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
pkg/mcp/tools_test.go Adds a shared test helper for decoding StructuredContent into typed structs.
pkg/mcp/tools_describe.go Implements the new describe tool, input validation, CLI invocation, and structured output mapping.
pkg/mcp/tools_describe_test.go Adds unit tests for describe args, mutual exclusivity validation, and malformed output handling.
pkg/mcp/mcp.go Registers the new describe tool and adds a help resource for it.
pkg/mcp/instructions.md Documents describe usage and updates the “read help first” guidance list.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/mcp/tools_describe_test.go
Comment thread pkg/mcp/tools_describe.go
- 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/enhancement Feature additions or improvements to existing 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