fix(mcp): hide server-beta-only tools from worker-runtime tools/list (closes #3064)#3065
Open
rodboev wants to merge 2 commits into
Open
fix(mcp): hide server-beta-only tools from worker-runtime tools/list (closes #3064)#3065rodboev wants to merge 2 commits into
rodboev wants to merge 2 commits into
Conversation
Contributor
Greptile SummaryThis PR makes MCP tool discovery aware of the selected runtime. The main changes are:
Confidence Score: 5/5The runtime-aware filtering is narrowly scoped to tool discovery and preserves the existing direct-call guard behavior. Focused tests cover worker versus server-beta visibility, schema compatibility, and preservation of worker-capable tools; the generated bundles were rebuilt from the source changes.
What T-Rex did
Reviews (2): Last reviewed commit: "fix(mcp): satisfy logger coverage for th..." | Re-trigger Greptile |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Worker runtime currently advertises
observation_*andmemory_*MCP tools that only run whenCLAUDE_MEM_RUNTIME=server-beta, so clients can discover a tool that is guaranteed to fail in the active runtime. This change makestools/listruntime-aware: worker mode hides the eight server-beta-only tool names, while server-beta keeps the current full observation and memory surface.The handler registry stays intact, and
requireServerBetaForObservationTool()still rejects direct worker-mode calls as defense in depth. The main proof is a focused runtime-visibility regression test on the production filtering logic, plus the existing schema and alias guards. The shipped plugin bundles were then regenerated through the normal build so installed MCP clients pick up the same filtered surface.A follow-up CI rerun also required one debug-level logger call inside the new visibility helper.
src/servers/*files are covered by the repo's logger-standards guard, so the helper now carries the same observability contract as the rest of the MCP server surface without changing the advertised tool set.Why
requireServerBetaForObservationTool()already rejects theobservation_*path outsideserver-betaatsrc/servers/mcp-server.ts:240-245, which means the implementation already knows those handlers are not worker-capable. The problem is earlier in the flow: the top-level registry atsrc/servers/mcp-server.ts:429-667includes those server-beta-only tools unconditionally, andListToolsRequestSchemaatsrc/servers/mcp-server.ts:902-909advertises that full registry without checking runtime.This PR fixes the advertised MCP contract rather than adding worker stubs.
CallToolRequestSchemastays on the full registry so the same actionable wrong-runtime error remains in place if a client bypasses discovery and calls one of those tools directly.Issue analysis and the direct MCP transcript in #3064 identified the worker-runtime list surface as the bug; related PR #3044 stays out of scope because it adds a separate worker write tool instead of filtering discovery.
Scope
Risk
The only semantic change to the MCP contract is which tool names
tools/listadvertises in worker mode. Server-beta keeps the existing tool exposure, and the handler-level guard remains unchanged. The logger follow-up is debug-only instrumentation inside the helper. The real regression risk is hiding a worker-capable tool by mistake, which is why the proof centers on worker-vs-server-beta visibility behavior rather than source-string inspection alone.Verification
bun test tests/servers/mcp-runtime-tool-visibility.test.ts tests/servers/mcp-tool-schemas.test.ts- pass (15/15)bun test tests/logger-usage-standards.test.ts -t "should have logger coverage in high-priority files"- passnpm.cmd run typecheck:root- passnpm run build- pass, shipped bundles regeneratednpm run lint:hook-io- passnpm run lint:spawn-env- passnpm run strip-comments:check- current repo snapshot still reportsChanged: 329 (check mode, no writes)Closes #3064