Skip to content

refactor(mcp): remove writeEnabled param from Server.Start#3765

Open
Ankitsinghsisodya wants to merge 1 commit into
knative:mainfrom
Ankitsinghsisodya:fix/mcp-start-remove-writeenabled-param
Open

refactor(mcp): remove writeEnabled param from Server.Start#3765
Ankitsinghsisodya wants to merge 1 commit into
knative:mainfrom
Ankitsinghsisodya:fix/mcp-start-remove-writeenabled-param

Conversation

@Ankitsinghsisodya
Copy link
Copy Markdown
Contributor

Problem

Server.Start accepted a writeEnabled bool parameter and reassigned s.readonly from it:

func (s *Server) Start(ctx context.Context, writeEnabled bool) error {
    s.readonly = !writeEnabled
    return s.impl.Run(ctx, s.transport)
}

The instructions string is embedded into mcp.ServerOptions at New() time via instructions(s.readonly) — a static string baked in before Start is ever called. The s.readonly reassignment in Start had 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.go already passes WithReadonly(!writeEnabled) to New(), so s.readonly is set correctly before instructions() runs. The writeEnabled parameter on Start was therefore redundant and a latent footgun.

Fix

Remove writeEnabled bool from Server.Start and propagate the signature change through the call stack. WithReadonly in New() is now the single source of truth for readonly mode.

Files changed

  • pkg/mcp/mcp.goStart(ctx), removed s.readonly = !writeEnabled
  • pkg/functions/client.goMCPServer interface, StartMCPServer, noopMCPServer all drop the bool param
  • pkg/mock/mcp_server.goStartFn and Start drop the bool param
  • cmd/mcp.goStartMCPServer(cmd.Context()), no writeEnabled arg
  • cmd/mcp_test.goTestMCP_StartWriteable rewritten; removed unused context import
  • pkg/mcp/mcp_test.goserver.Start(t.Context()), removed !readonly
  • pkg/functions/client_test.goStartMCPServer(t.Context()), removed true

Testing

All existing tests pass. Readonly correctness (instructions reflecting the correct mode) is covered by TestInstructions in pkg/mcp.

…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.
Copilot AI review requested due to automatic review settings May 16, 2026 14:46
@knative-prow knative-prow Bot requested review from dsimansk and jrangelramos May 16, 2026 14:46
@knative-prow
Copy link
Copy Markdown

knative-prow Bot commented May 16, 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 dsimansk 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 the size/M 🤖 PR changes 30-99 lines, ignoring generated files. label May 16, 2026
@knative-prow
Copy link
Copy Markdown

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

@knative-prow knative-prow Bot added the needs-ok-to-test 🤖 Needs an org member to approve testing label May 16, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 16, 2026

Codecov Report

❌ Patch coverage is 50.00000% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 57.06%. Comparing base (2bbf9fe) to head (23aed7b).

Files with missing lines Patch % Lines
pkg/mock/mcp_server.go 0.00% 3 Missing ⚠️
pkg/functions/client.go 66.66% 1 Missing ⚠️
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     
Flag Coverage Δ
e2e 35.93% <0.00%> (+0.01%) ⬆️
e2e go 31.46% <0.00%> (+<0.01%) ⬆️
e2e node 27.25% <0.00%> (+<0.01%) ⬆️
e2e python 31.83% <0.00%> (+<0.01%) ⬆️
e2e quarkus 27.37% <0.00%> (+<0.01%) ⬆️
e2e rust 26.77% <0.00%> (+<0.01%) ⬆️
e2e springboot 25.29% <0.00%> (+<0.01%) ⬆️
e2e typescript 27.35% <0.00%> (+<0.01%) ⬆️
e2e-config-ci 28.30% <0.00%> (+<0.01%) ⬆️
integration 17.35% <0.00%> (-0.03%) ⬇️
unit macos-14 45.05% <50.00%> (-0.01%) ⬇️
unit macos-latest 45.05% <50.00%> (-0.01%) ⬇️
unit ubuntu-24.04-arm 45.31% <50.00%> (-0.01%) ⬇️
unit ubuntu-latest 46.01% <50.00%> (-0.01%) ⬇️
unit windows-latest 45.10% <50.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/M 🤖 PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant