Skip to content

fix(mcp): add readonly guard to createHandler#3811

Open
Elvand-Lie wants to merge 1 commit into
knative:mainfrom
Elvand-Lie:fix/mcp-create-readonly
Open

fix(mcp): add readonly guard to createHandler#3811
Elvand-Lie wants to merge 1 commit into
knative:mainfrom
Elvand-Lie:fix/mcp-create-readonly

Conversation

@Elvand-Lie
Copy link
Copy Markdown
Contributor

Problem

The createHandler in pkg/mcp/tools_create.go lacks the s.readonly.Load() check that is present in other mutating tools like deployHandler and deleteHandler.

Because of this, an MCP client can execute the create command (which writes project scaffolding files to the disk) even when the server is operating in readonly mode.

Fix

Added the s.readonly.Load() guard to match the behavior of other tools.

Fixes #3810

@knative-prow knative-prow Bot requested review from dsimansk and jrangelramos May 20, 2026 20:01
@knative-prow
Copy link
Copy Markdown

knative-prow Bot commented May 20, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Elvand-Lie
Once this PR has been reviewed and has the lgtm label, please assign matzew 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 size/XS 🤖 PR changes 0-9 lines, ignoring generated files. needs-ok-to-test 🤖 Needs an org member to approve testing labels May 20, 2026
@knative-prow
Copy link
Copy Markdown

knative-prow Bot commented May 20, 2026

Hi @Elvand-Lie. 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.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 20, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 52.53%. Comparing base (ad6edb6) to head (86fa702).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3811      +/-   ##
==========================================
- Coverage   53.42%   52.53%   -0.89%     
==========================================
  Files         200      200              
  Lines       23426    23445      +19     
==========================================
- Hits        12515    12318     -197     
- Misses       9655     9882     +227     
+ Partials     1256     1245      -11     
Flag Coverage Δ
e2e 21.73% <0.00%> (-11.97%) ⬇️
e2e go 29.66% <0.00%> (+0.01%) ⬆️
e2e node 25.96% <0.00%> (+0.09%) ⬆️
e2e python 29.99% <0.00%> (+0.01%) ⬆️
e2e quarkus 26.07% <0.00%> (+0.09%) ⬆️
e2e rust 25.52% <0.00%> (+0.08%) ⬆️
e2e springboot 24.19% <0.00%> (+0.08%) ⬆️
e2e typescript 26.05% <0.00%> (+0.09%) ⬆️
e2e-config-ci 26.78% <0.00%> (+0.02%) ⬆️
integration 15.76% <0.00%> (+0.13%) ⬆️
unit macos-14 42.24% <100.00%> (+0.04%) ⬆️
unit macos-latest 42.24% <100.00%> (+0.04%) ⬆️
unit ubuntu-24.04-arm 42.55% <100.00%> (+0.04%) ⬆️
unit ubuntu-latest 43.11% <100.00%> (+0.04%) ⬆️
unit windows-latest 42.31% <100.00%> (+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.

@Elvand-Lie Elvand-Lie force-pushed the fix/mcp-create-readonly branch from 1ea04b7 to c4cd153 Compare May 21, 2026 06:26
@lkingland lkingland added the ok-to-test 🤖 Non-member PR verified by an org member that is safe to test. label May 21, 2026
@Elvand-Lie Elvand-Lie force-pushed the fix/mcp-create-readonly branch from c4cd153 to b8524f9 Compare May 21, 2026 13:08
@knative-prow knative-prow Bot added size/S 🤖 PR changes 10-29 lines, ignoring generated files. and removed size/XS 🤖 PR changes 0-9 lines, ignoring generated files. needs-ok-to-test 🤖 Needs an org member to approve testing labels May 21, 2026
The createHandler lacks the s.readonly.Load() check that is present
in other mutating tools like deployHandler and deleteHandler.

Because of this, an MCP client can execute the create command (which
writes project scaffolding files to the disk) even when the server is
operating in readonly mode.

Added the guard to match the behavior of other tools.

Fixes knative#3810
@Elvand-Lie Elvand-Lie force-pushed the fix/mcp-create-readonly branch from b8524f9 to 86fa702 Compare May 21, 2026 13:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ok-to-test 🤖 Non-member PR verified by an org member that is safe to test. size/S 🤖 PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mcp: createHandler lacks readonly mode guard

2 participants