fix(mcp): add readonly guard to buildHandler#3840
Conversation
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>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: Ankitsinghsisodya The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
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 Regular contributors should join the org to skip this step. Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions 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. |
There was a problem hiding this comment.
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
buildtool calls whens.readonlyis enabled, returning an error before executing the build command.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Codecov Report❌ Patch coverage is
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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Problem
buildHandlerinvokesfunc build, which can write updated image metadata back tofunc.yaml(e.g.build.image). The tool is correctly annotated withReadOnlyHint: false, but it was missing thes.readonly.Load()check that prevents mutating operations when the MCP server starts in readonly mode.Changes
pkg/mcp/tools_build.go: adds.readonly.Load()guard at the top ofbuildHandler, consistent with the existing pattern indeleteHandleranddeployHandler.