Skip to content

mcp: split config tools by action for accurate tool annotations#3661

Open
Ankitsinghsisodya wants to merge 3 commits intoknative:mainfrom
Ankitsinghsisodya:fix/mcp-config-tool-annotations
Open

mcp: split config tools by action for accurate tool annotations#3661
Ankitsinghsisodya wants to merge 3 commits intoknative:mainfrom
Ankitsinghsisodya:fix/mcp-config-tool-annotations

Conversation

@Ankitsinghsisodya
Copy link
Copy Markdown
Contributor

Problem

config_envs, config_labels, and config_volumes each accepted an action
parameter (list, add, remove) but declared DestructiveHint: true at the
tool level. MCP tool annotations are static metadata evaluated at discovery time,
before any invocation arguments exist. A client that respects hints treats the tool
as destructive on every call — including a read-only list.

Changes

Split each combined tool into three single-action tools, each carrying annotations
that accurately describe that action's semantics:

Tool ReadOnlyHint DestructiveHint
config_{envs,labels,volumes}_list true — (irrelevant per spec when ReadOnly)
config_{envs,labels,volumes}_add false false (additive only)
config_{envs,labels,volumes}_remove false true

The action field is removed from all input structs. Each tool's Args() method
hardcodes the correct subcommand. IdempotentHint is set to true on list tools.

Tests

Nine dedicated tests (list/add/remove per resource) replace the previous six combined
tests. All pass.

- Introduced separate tools for managing environment variables, labels, and volumes: `config_envs_list`, `config_envs_add`, `config_envs_remove`, `config_labels_list`, `config_labels_add`, `config_labels_remove`, `config_volumes_list`, `config_volumes_add`, and `config_volumes_remove`.
- Updated corresponding handler functions to support new tool functionalities.
- Enhanced test cases to validate the new tools and their respective actions.
- Improved argument handling and output structures for better clarity and usability.
Copilot AI review requested due to automatic review settings May 6, 2026 07:09
@knative-prow
Copy link
Copy Markdown

knative-prow Bot commented May 6, 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 matejvasek 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 6, 2026 07:09
@knative-prow knative-prow Bot added size/XL 🤖 PR changes 500-999 lines, ignoring generated files. needs-ok-to-test 🤖 Needs an org member to approve testing labels May 6, 2026
@knative-prow
Copy link
Copy Markdown

knative-prow Bot commented May 6, 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

This PR updates the MCP “config” tools to avoid incorrect static tool annotations by splitting the previously multi-action tools into separate single-action tools, so clients can correctly treat list as read-only while still flagging remove as destructive.

Changes:

  • Split config_{envs,labels,volumes} into *_list, *_add, and *_remove tools with action-appropriate MCP annotations.
  • Remove the action field from config tool inputs and hardcode the correct subcommand in each tool’s Args().
  • Replace the prior combined tests with dedicated list/add/remove tests per resource.

Reviewed changes

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

Show a summary per file
File Description
pkg/mcp/tools_config_volumes.go Splits volumes config into list/add/remove tools, each with distinct input/output structs and annotations.
pkg/mcp/tools_config_volumes_test.go Updates tests to call config_volumes_{list,add,remove} and validates the resulting CLI args.
pkg/mcp/tools_config_labels.go Splits labels config into list/add/remove tools with action-specific annotations and args.
pkg/mcp/tools_config_labels_test.go Updates tests to target the new labels tools and validates expected args.
pkg/mcp/tools_config_envs.go Splits env var config into list/add/remove tools with action-specific annotations and args.
pkg/mcp/tools_config_envs_test.go Updates tests to call the new envs tools and validates expected args.
pkg/mcp/mcp.go Registers the new tools with the MCP server instead of the old combined tools.

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

Comment thread pkg/mcp/mcp.go
Comment on lines +12 to 20
var configEnvsListTool = &mcp.Tool{
Name: "config_envs_list",
Title: "Config Environment Variables List",
Description: "Lists the environment variables configured for a function.",
Annotations: &mcp.ToolAnnotations{
Title: "Config Environment Variables",
ReadOnlyHint: false,
DestructiveHint: ptr(true),
IdempotentHint: false, // Adding the same environment variable twice or removing a non-existent one will fail.
Title: "Config Environment Variables List",
ReadOnlyHint: true,
IdempotentHint: true,
},
@codecov
Copy link
Copy Markdown

codecov Bot commented May 6, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 56.85%. Comparing base (18ff6b3) to head (7509204).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3661      +/-   ##
==========================================
+ Coverage   53.49%   56.85%   +3.35%     
==========================================
  Files         181      181              
  Lines       20732    20788      +56     
==========================================
+ Hits        11091    11818     +727     
+ Misses       8567     7761     -806     
- Partials     1074     1209     +135     
Flag Coverage Δ
e2e 36.22% <0.00%> (-0.10%) ⬇️
e2e go 32.87% <0.00%> (?)
e2e node 28.58% <0.00%> (?)
e2e python 33.23% <0.00%> (?)
e2e quarkus 28.72% <0.00%> (?)
e2e rust 28.13% <0.00%> (?)
e2e springboot 26.62% <0.00%> (?)
e2e typescript 28.69% <0.00%> (?)
e2e-config-ci 17.94% <0.00%> (-0.08%) ⬇️
integration 17.37% <0.00%> (?)
unit macos-14 44.54% <100.00%> (+0.27%) ⬆️
unit macos-latest 44.54% <100.00%> (+0.27%) ⬆️
unit ubuntu-24.04-arm 44.65% <100.00%> (+0.20%) ⬆️
unit ubuntu-latest 45.39% <100.00%> (+0.27%) ⬆️
unit windows-latest 44.52% <100.00%> (+0.27%) ⬆️

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.

- Updated instructions for `config_*` tools to specify new commands: `config_envs_list`, `config_envs_add`, `config_envs_remove`, `config_labels_list`, `config_labels_add`, `config_labels_remove`, `config_volumes_list`, `config_volumes_add`, and `config_volumes_remove`.
- Clarified usage instructions, including the requirement for absolute paths and the effects of add/remove operations on local `func.yaml` files.
- Added authoritative usage references for environment variables, labels, and volumes.
- Implemented tests for `config_envs_list`, `config_envs_add`, and `config_envs_remove` to ensure proper propagation of executor errors.
- Added similar tests for `config_labels_list`, `config_labels_add`, and `config_labels_remove`.
- Included tests for `config_volumes_list`, `config_volumes_add`, and `config_volumes_remove` to validate error handling.
- Each test verifies that the expected error result is returned when the executor encounters an error during execution.
@Ankitsinghsisodya
Copy link
Copy Markdown
Contributor Author

cc @gauron99

@gauron99 gauron99 requested review from lkingland and removed request for dsimansk and jrangelramos May 7, 2026 07:40
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/XL 🤖 PR changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants