Skip to content

mcpx: honour ?codemode=false on /mcp — expose raw tools (PLG-35 of #1940) - #2992

Merged
dezren39 merged 4 commits into
mainfrom
queue/3240-1940-codemode-false
Oct 31, 2026
Merged

dezren39 merged 4 commits into
mainfrom
queue/3240-1940-codemode-false

Conversation

@dezren39

@dezren39 dezren39 commented Oct 31, 2026 •

Copy link
Copy Markdown
Member

Implements PLG-35 of #1940 (queue task 3240): the daemon's /mcp endpoint honours ?codemode=false by exposing the raw upstream tools surface instead of the code-mode surface. Absence of the parameter — and any value other than exactly false — changes nothing. This does not close #1940: CODE-53 (docs) and PLG-38 (plugin abort) remain open slices on the issue.

What

  • internal/mcpserver/codemode.go (new): the switch is read once in ServeHTTP from the request URL and rides the request context. That request's tools/list is every upstream tool, flat, under <namespace>_<tool> (the registry's existing Native spelling); the gateway's own tools are absent from that surface, and tools/call for a raw name routes to its owning upstream under the upstream's own name via Backend.Call. Gateway tools called through the raw surface are refused (-32602, via the surface check).
  • New optional backend interface mcpserver.RawToolsBackend; collisions that join to the same exposed name are refused rather than silently resolved (same rule as pass-through), and a backend/upstream that cannot be listed is an error (-32603), never a partial catalogue.
  • internal/cli/serve.go: mcpBackend.RawTools lists each visible namespace through the same UpstreamTools pass-through mode uses.
  • Capabilities: the raw list varies like the pass-through list, so tools.listChanged follows it on a codemode=false request.
  • Docs: docs/mcp.md gains the per-connection raw surface; register row PLG-35 updated to "honours, does not send" with a dated detail note (mcpx as a client sending the parameter remains open and is recorded there).

Tests

New HTTP-level tests in internal/mcpserver/codemode_test.go (the switch lives on the URL, so they go through ServeHTTP):

  • raw list is exactly the namespaced upstream tools, sorted, with no gateway tools
  • absent / true / 1 / FALSE values keep the gateway surface
  • a raw call reaches the right upstream under its own name
  • mcpx_exec through the raw surface is -32602
  • unlistable backend and down upstream are -32603, not an empty list

Verified on the laptop: go test ./internal/mcpserver/ pass, go test ./internal/cli/ pass, go vet clean, gofmt clean.

Refs #1940


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

)

ServeHTTP reads codemode=false from the request URL; that request gets the raw surface instead of the code-mode surface: every upstream tool flat under <namespace>_<tool>, gateway tools absent, tools/call routed to the owning upstream under its own name. New mcpserver.RawToolsBackend, implemented by the CLI backend over the visible namespaces (UpstreamTools per namespace); an unlistable namespace fails the whole list rather than serving a partial catalogue. Absence and any other value change nothing.

Tests: 5 new HTTP-level cases in internal/mcpserver/codemode_test.go (raw list, unchanged default/other values, call routing, gateway tools refused -32602, unlistable backend/upstream = -32603). go test ./internal/mcpserver/ and ./internal/cli/ pass on the laptop; go vet clean.
@dezren39
dezren39 requested a review from a team as a code owner October 31, 2026 08:22
@coderabbitai

coderabbitai Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 47 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: bd6c0687-63e0-495e-bf97-1ca67b138ea2
Commits

Reviewing files that changed from the base of the PR and between c1b9052 and a71c550.

Files selected for processing: 14
  • pkgs/mcpx/docs/compare/register/plugin-apis.md
  • pkgs/mcpx/docs/mcp.md
  • pkgs/mcpx/internal/cli/serve.go
  • pkgs/mcpx/internal/cli/serve_ask.go
  • pkgs/mcpx/internal/cli/serve_ask_raw_test.go
  • pkgs/mcpx/internal/mcpserver/ask.go
  • pkgs/mcpx/internal/mcpserver/codemode.go
  • pkgs/mcpx/internal/mcpserver/codemode_test.go
  • pkgs/mcpx/internal/mcpserver/export_test.go
  • pkgs/mcpx/internal/mcpserver/listen.go
  • pkgs/mcpx/internal/mcpserver/passthrough.go
  • pkgs/mcpx/internal/mcpserver/server.go
  • pkgs/mcpx/internal/mcpserver/tasks.go
  • pkgs/mcpx/internal/mcpserver/transport.go
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-31T10:49:19.761381Z a71c550 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@dezren39

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 213d74349d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread pkgs/mcpx/internal/mcpserver/server.go Resolved
Comment thread pkgs/mcpx/internal/mcpserver/server.go Resolved
Comment thread pkgs/mcpx/internal/mcpserver/server.go Resolved
…ridge, and list-changed delivery

Codex review round on #2992, three P2 threads:

- Tasks: runInner now takes the request context and re-applies its
  raw-surface selection to the task body context. The task store runs
  the body on a fresh background context, so the inner tools/call was
  judged against the gateway surface and a validated raw name was
  refused with -32602.
- Ask bridge: daemonAsker.Begin resolves raw names through the new
  mcpserver.RawToolOf (the request raw lookup, mirroring PassToolOf)
  to namespace + the upstream own tool name, with client capabilities
  relayed as on the pass-through path. Raw names previously fell to
  ErrNotInterruptible and ran with no ask attribution.
- Notifications: one predicate, toolsListChangedFor, now decides
  tools.listChanged in capabilities(), the subscriptions/listen
  agreement, and the legacy notifier stream. The latter two used only
  toolsVary(), so a raw request was advertised listChanged:true but
  never delivered a tools/list_changed.

Regression tests cover each fix and were verified to fail pre-fix.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a05c6e6195

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread pkgs/mcpx/internal/mcpserver/server.go Resolved
Comment thread pkgs/mcpx/internal/mcpserver/server.go Resolved
…asks, capabilities, and protocol errors

Round-2 Codex review on #2992 (PLG-35 of #1940):
- taskSupportOf/legacyTaskSupport now consult the request raw tool definitions, so a raw tool execution.taskSupport is honoured (required -> -32021 without the tasks extension; legacy task-augmented calls follow the declaration instead of always -32601).
- mcpBackend.Call forwards DeclaredCapabilities for raw calls (isRawCall via RawToolOf), not only pass-through namespaces, so upstreams narrow by what the caller can answer.
- The same direct treatment applies to relayedFault in mcpBackend.Call and to passCall in the ask bridge, so upstream JSON-RPC errors (incl. -32021 with its data) relay as errors instead of flattening into isError results.

Tests: TestCodemodeFalseRequiredRawToolWithoutTheExtensionIsMissingCapability, TestCodemodeFalseLegacyTaskAugmentedRawCalls, TestCodemodeFalseAskBridgeRelaysUpstreamProtocolErrors; full mcpserver+cli suites pass on laptop.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cbf364f4c7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread pkgs/mcpx/internal/cli/serve_ask.go Resolved
@dezren39

Copy link
Copy Markdown
Member Author

@codex review

Round-3 finding fixed in a71c550 (raw resolution before gateway argument decoding, with regression test). Please re-review the new head.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: a71c550b68

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@dezren39
dezren39 merged commit 37df0a6 into main Oct 31, 2026
14 of 18 checks passed
@dezren39
dezren39 deleted the queue/3240-1940-codemode-false branch October 31, 2026 15:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mcpx and opencode code mode: nested code mode, ?codemode=false, and what a harness expects of mcpx_exec

1 participant