Skip to content

fix(mcp): add readonly guard to buildHandler#3840

Open
Ankitsinghsisodya wants to merge 2 commits into
knative:mainfrom
Ankitsinghsisodya:fix/mcp-build-readonly-guard
Open

fix(mcp): add readonly guard to buildHandler#3840
Ankitsinghsisodya wants to merge 2 commits into
knative:mainfrom
Ankitsinghsisodya:fix/mcp-build-readonly-guard

Conversation

@Ankitsinghsisodya
Copy link
Copy Markdown
Contributor

Problem

buildHandler invokes func build, which can write updated image metadata back to func.yaml (e.g. build.image). The tool is correctly annotated with ReadOnlyHint: false, but it was missing the s.readonly.Load() check that prevents mutating operations when the MCP server starts in readonly mode.

Changes

  • pkg/mcp/tools_build.go: add s.readonly.Load() guard at the top of buildHandler, consistent with the existing pattern in deleteHandler and deployHandler.

Implement a check in the buildHandler method to prevent build operations when the server is in readonly mode. This ensures that users are informed to enable write access before proceeding with builds, enhancing server state management.

Signed-off-by: [Your Name] <your.email@example.com>
Copilot AI review requested due to automatic review settings May 24, 2026 12:08
@knative-prow knative-prow Bot requested review from dsimansk and jrangelramos May 24, 2026 12:08
@knative-prow
Copy link
Copy Markdown

knative-prow Bot commented May 24, 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 gauron99 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
Copy link
Copy Markdown

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

Regular contributors should join the org to skip this step.

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.

@knative-prow knative-prow Bot added needs-ok-to-test 🤖 Needs an org member to approve testing size/XS 🤖 PR changes 0-9 lines, ignoring generated files. labels May 24, 2026
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 read-only gate to the MCP build tool so the server refuses build requests when write operations are disabled.

Changes:

  • Rejects build tool calls when s.readonly is enabled, returning an error before executing the build command.

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

Comment thread pkg/mcp/tools_build.go Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented May 24, 2026

Codecov Report

❌ Patch coverage is 0% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 53.44%. Comparing base (692383b) to head (11b41e1).

Files with missing lines Patch % Lines
pkg/mcp/tools_build.go 0.00% 3 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3840      +/-   ##
==========================================
- Coverage   53.44%   53.44%   -0.01%     
==========================================
  Files         200      200              
  Lines       23450    23454       +4     
==========================================
+ Hits        12534    12535       +1     
- Misses       9662     9664       +2     
- Partials     1254     1255       +1     
Flag Coverage Δ
e2e 33.71% <0.00%> (-0.01%) ⬇️
e2e go 29.65% <0.00%> (-0.01%) ⬇️
e2e node 25.95% <0.00%> (-0.01%) ⬇️
e2e python 29.99% <0.00%> (-0.01%) ⬇️
e2e quarkus 26.06% <0.00%> (-0.01%) ⬇️
e2e rust 25.47% <0.00%> (-0.07%) ⬇️
e2e springboot 24.20% <0.00%> (-0.01%) ⬇️
e2e typescript 26.05% <0.00%> (-0.01%) ⬇️
e2e-config-ci 26.77% <0.00%> (-0.01%) ⬇️
integration 15.76% <0.00%> (-0.02%) ⬇️
unit macos-14 42.22% <0.00%> (-0.01%) ⬇️
unit macos-latest 42.22% <0.00%> (-0.01%) ⬇️
unit ubuntu-24.04-arm 42.51% <0.00%> (-0.01%) ⬇️
unit ubuntu-latest 43.08% <0.00%> (-0.01%) ⬇️
unit windows-latest 42.29% <0.00%> (-0.01%) ⬇️

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.

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/XS 🤖 PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants