Tools: x-mcp-header annotation tooling + -32602 unknown-tool rendering (#1632) - #1735
Conversation
#1632) Card 9/10 of the SDK-v2 + New Spec stack. Adds SEP-2243 `x-mcp-header` tooling to the Tools tab and adjusts result rendering for SDK v2's unknown-tool behavior, and bumps the SDK to 2.0.0-beta.5. - **`core/json/xMcpHeader.ts`**: a faithful port of the SDK's (non-public) `scanXMcpHeaderDeclarations` — validates every SEP-2243 constraint (primitive types incl. `number`, RFC 9110 token, case-insensitive uniqueness, statically-reachable `properties`-only chain) and derives the mirrored `Mcp-Param-{Name}` params for a kept tool. - **Excluded tools**: the SDK silently drops tools with invalid annotations from `tools/list`. InspectorClient now re-lists the RAW (unfiltered) list and scans it to recompute the excluded set with reasons — gated to the modern non-stdio era (matching the SDK's gate), recomputed on every aggregate refresh, surfaced via a new `excludedToolsChange` event + `getExcludedTools()` and `useInspectorClient().excludedTools`. The Tools sidebar lists them struck-through under an "Excluded (SEP-2243)" divider with the reason on hover. - **Mirrored args**: ToolDetailPanel shows a "Mirrored request headers" section listing each arg → `Mcp-Param-{Name}` (with the browser-omits note). - **-32602 rendering**: SDK v2 rejects an unknown-tool call with `-32602` instead of an `isError` result, which previously rendered nothing. New ToolCallErrorPanel renders a thrown tool-call error, with a targeted "Unknown Tool" hint for `-32602`. Adds unit + Storybook + integration coverage (a real modern server with an invalid-header tool fixture) for every path. `npm run ci`-equivalent checks green. Closes #1632 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XNdjEPKLG637X8YmhDiEk5
Register the `invalid_header_tool` fixture as a preset and add `xmcpheader-modern-http.json` — a modern HTTP showcase serving echo, a valid-header `get_weather`, and the invalid-header tool — so the Tools-tab x-mcp-header tooling (mirrored headers, excluded-tools surface, -32602 rendering) can be exercised manually. Documented in the README alongside the other per-SEP showcase configs. Smoke-tested end to end in the web client. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XNdjEPKLG637X8YmhDiEk5
End-to-end web-client verification of the x-mcp-header Tools tooling against the modern showcase server: excluded-tools surface + reason, mirrored-headers section, and the -32602 unknown-tool error panel. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XNdjEPKLG637X8YmhDiEk5
|
@claude review |
|
Claude finished @cliffhall's task in 2m 51s —— View job Code review — PR #1735 (x-mcp-header tooling +
|
Addresses the review on PR #1735: 1. -32602 "Unknown Tool" mislabel: `-32602` is generic Invalid params, so a known tool called with bad arguments hit the same code and rendered under the definitive "Unknown Tool" heading. Replace `isUnknownToolError` with `classifyToolCallError(code, message)` → "unknown-tool" only when the message names it (not found / unknown tool / …), else "invalid-params" (new "Invalid Parameters" heading + schema hint), else "generic". 2. Double pagination walk: expand the `listAllTools` comment to document that the excluded-tools recompute is a deliberately un-cached second raw walk (doubles list round-trips on modern non-stdio, runs even on a cache-served aggregate) — accepted for a debugging tool, no-op on legacy/stdio. 3. Doc nit: `scanXMcpHeaderDeclarations` no longer claims to visit "$ref targets" — reworded to note `$ref` is never followed (refs resolve into the unreachable `$defs` body). 4. Search nit: the excluded-list filter now matches name AND title, matching the main tools filter. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XNdjEPKLG637X8YmhDiEk5
|
Thanks for the review! Addressed in 679e776:
|
|
@claude review |
|
Claude finished @cliffhall's task in 1m 41s —— View job Code review — PR #1735 (re-review after 679e776)
The five items from the prior review are all handled well. Quick verification pass:
Also spot-checked: the SDK bump to One small residual on the
|
The re-review noted the -32602 disambiguation was symmetric: broad markers
("does not exist", "unrecognized") could inversely mislabel a genuine
invalid-params message (e.g. "property 'region' does not exist") as "Unknown
Tool". Scope the not-found/does-not-exist family to require the word "tool" in
the same clause (matching the SDK's "Tool <name> not found"); keep "unknown
tool" / "no such tool" as standalone unambiguous markers. Adds a
tool-less-"does not exist" test asserting it classifies as invalid-params.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XNdjEPKLG637X8YmhDiEk5
|
Thanks — and good call on the symmetric-mislabel residual. Addressed in 95195e4: the unknown-tool matcher is now tool-scoped. The broad
|
|
@claude review |
|
Claude finished @cliffhall's task in 1m 47s —— View job Code review — PR #1735 (re-review after
|
|
Thanks for the thorough re-reviews! Agreed the remaining corner (an argument literally named |
…hot (#1632) Adds a `trigger_invalid_params` spec-error trigger to the modern showcase server: the injector answers its `tools/call` with a real `-32602 Invalid params` JSON-RPC error whose message does NOT name an unknown tool. This lets the "Invalid Parameters" branch of the tool-call error panel (added in the review response) be exercised live, distinct from the unknown-tool `-32602`. - `SPEC_ERROR_TRIGGERS` gains the `trigger_invalid_params` entry (HTTP 200, in-band -32602) + preset registration. - Enable `injectSpecErrors` on `xmcpheader-modern-http.json` and add the tool. - README + pr-screenshots README document it; adds the live "Invalid Parameters" proof screenshot. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XNdjEPKLG637X8YmhDiEk5
|
@claude review |
|
Claude finished @cliffhall's task in 1m 10s —— View job Code review — PR #1735 (x-mcp-header tooling +
|
|
Thanks for the final pass — glad the |
Closes #1632
Card 9/10 of the SDK-v2 + New Spec stack. Adds SEP-2243
x-mcp-headertooling to the Tools tab and adjusts result rendering for SDK v2's unknown-tool behavior. Also upgrades the MCP SDK to2.0.0-beta.5(from beta.4) across all clients.What's in it
core/json/xMcpHeader.ts— a faithful port of the SDK's (non-public)scanXMcpHeaderDeclarations. Validates every SEP-2243 constraint: primitive types only (string/integer/boolean, plusnumberto match the SDK's conformance-referee carve-out), RFC 9110 header-name token, case-insensitive uniqueness, and the statically-reachableproperties-only chain (an annotation underitems/oneOf/additionalProperties/$defs/etc. invalidates the tool). Also derives the mirroredMcp-Param-{Name}params for a kept tool. Pure and 100%-covered.Excluded tools shown with reasons. The spec makes exclusion mandatory — a modern Streamable HTTP client MUST drop a tool with an invalid annotation, and the SDK's
listTools()does so silently.InspectorClientnow re-lists the raw (unfiltered)tools/listand scans it to recompute the excluded set with each reason — gated to the modern non-stdio era (matching the SDK's own gate), recomputed on every aggregate refresh. Surfaced via a newexcludedToolsChangeevent +getExcludedTools()anduseInspectorClient().excludedTools. The Tools sidebar lists them struck-through under an "Excluded (SEP-2243)" divider, with the reason on hover.Mirrored args indicated.
ToolDetailPanelshows a "Mirrored request headers (SEP-2243)" section listing each arg →Mcp-Param-{Name}, with a note that the browser omitsMcp-Param-*(mirroring is Node/proxy-only).-32602rendering. SDK v2 rejects an unknown-tool call with-32602instead of returning anisErrorresult — which previously rendered nothing (the result panel only shows on aresult). NewToolCallErrorPanelrenders a thrown tool-call error. Because-32602is the generic Invalid params code, the heading is chosen from the message: "Unknown Tool" (with the excluded/removed hint) when the message names a missing tool, else "Invalid Parameters" (with a schema hint).Proof screenshots
End-to-end verification in the web client against the modern showcase server (
test-servers/configs/xmcpheader-modern-http.json). More detail inpr-screenshots/README.md.Excluded tools + reason —
invalid_header_toolis dropped fromtools/list; the Inspector surfaces it struck-through under an "Excluded (SEP-2243)" divider, with the scan reason on hover.Mirrored request headers —
get_weather'scityarg mirrors toMcp-Param-City.-32602→ "Unknown Tool" — a-32602whose message names a missing tool (reproduced by swapping the sessionless server to one withoutechowhile the cached list still showed it).-32602→ "Invalid Parameters" — a-32602that is not an unknown tool renders under a distinct heading with a schema hint (triggered live via thetrigger_invalid_paramstest tool, which returns a real-32602JSON-RPC error). This is the disambiguation added in the review response.Testing
useInspectorClientexcluded-tools subscription.ToolCallErrorPanel.inspectorClient-excluded-tools.test.ts) driving a real modern server with an invalid-header tool fixture (createInvalidHeaderTool), covering exclusion, the reason/event, pagination walk, legacy no-op, disconnect clear, and the best-effort recompute.xmcpheader-modern-http.json) +invalid_header_tool/trigger_invalid_paramspresets, documented in the README.validate+ per-file ≥90coveragegate (web/cli/tui/launcher) + Storybook + smoke all green locally. SDK beta.5 bump verified end-to-end via the CLI/TUI/web smokes and the browser smoke above.🤖 Generated with Claude Code
https://claude.ai/code/session_01XNdjEPKLG637X8YmhDiEk5