refactor(mcp): remove writeEnabled param from Server.Start#3765
refactor(mcp): remove writeEnabled param from Server.Start#3765Ankitsinghsisodya wants to merge 1 commit into
Conversation
…related functions This change simplifies the MCP server start process by removing the writeEnabled boolean parameter. The server now defaults to readonly mode unless explicitly configured otherwise. Updated related tests and comments to reflect this change in behavior.
|
[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 Tip We noticed you've done this a few times! Consider joining the org to skip this step and gain 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. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3765 +/- ##
==========================================
- Coverage 57.06% 57.06% -0.01%
==========================================
Files 181 181
Lines 21145 21144 -1
==========================================
- Hits 12067 12066 -1
+ Misses 7855 7854 -1
- Partials 1223 1224 +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
Server.Startaccepted awriteEnabled boolparameter and reassigneds.readonlyfrom it:The instructions string is embedded into
mcp.ServerOptionsatNew()time viainstructions(s.readonly)— a static string baked in beforeStartis ever called. Thes.readonlyreassignment inStarthad no effect on the instructions agents receive, but could silently make handler behaviour inconsistent with those instructions if the two callers ever passed disagreeing values.cmd/mcp.goalready passesWithReadonly(!writeEnabled)toNew(), sos.readonlyis set correctly beforeinstructions()runs. ThewriteEnabledparameter onStartwas therefore redundant and a latent footgun.Fix
Remove
writeEnabled boolfromServer.Startand propagate the signature change through the call stack.WithReadonlyinNew()is now the single source of truth for readonly mode.Files changed
pkg/mcp/mcp.go—Start(ctx), removeds.readonly = !writeEnabledpkg/functions/client.go—MCPServerinterface,StartMCPServer,noopMCPServerall drop theboolparampkg/mock/mcp_server.go—StartFnandStartdrop theboolparamcmd/mcp.go—StartMCPServer(cmd.Context()), nowriteEnabledargcmd/mcp_test.go—TestMCP_StartWriteablerewritten; removed unusedcontextimportpkg/mcp/mcp_test.go—server.Start(t.Context()), removed!readonlypkg/functions/client_test.go—StartMCPServer(t.Context()), removedtrueTesting
All existing tests pass. Readonly correctness (instructions reflecting the correct mode) is covered by
TestInstructionsinpkg/mcp.