* Tools: x-mcp-header annotation tooling + -32602 unknown-tool rendering (#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 * test-servers: x-mcp-header modern showcase config + preset (#1632) 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 * docs: add #1632 proof screenshots to pr-screenshots 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 * Respond to review: disambiguate -32602, doc/search nits (#1632) 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 * Tighten unknown-tool matcher to be tool-scoped (#1632 re-review nit) 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 * Add trigger_invalid_params showcase tool + Invalid Parameters screenshot (#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 --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
2259b1a3e1
commit
e70a11360c
44 changed files with 1610 additions and 86 deletions
|
|
@ -31,6 +31,9 @@ inspector/
|
|||
│ │ │ # runner-interactive-oauth loopback callback flow)
|
||||
│ │ └── remote/ # Remote OAuth storage (delegates to the remote server)
|
||||
│ ├── json/ # JSON utilities and parameter/argument conversion
|
||||
│ │ # (xMcpHeader.ts: SEP-2243 `x-mcp-header`
|
||||
│ │ # annotation scan/validation + mirrored-param
|
||||
│ │ # derivation, used by the Tools tab — #1632)
|
||||
│ ├── logging/ # Silent pino logger singleton
|
||||
│ ├── mcp/ # InspectorClient runtime + state stores
|
||||
│ │ # (modernTaskSchemas.ts: SEP-2663 modern Tasks
|
||||
|
|
|
|||
|
|
@ -114,11 +114,13 @@ A streamable-HTTP server can also serve the **modern (2026-07-28) protocol era**
|
|||
|
||||
`test-servers/configs/modern-network-http.json` is the **Network-tab showcase** for the standardized HTTP headers and new error taxonomy (SEP-2243 / SEP-2575). It serves a `get_weather` tool whose `city` argument carries an `x-mcp-header: "City"` annotation (so a modern client mirrors it to `Mcp-Param-City`), plus four `trigger_*` tools that the modern leg's spec-error injector (`transport.modern.injectSpecErrors: true`) answers with a real HTTP status + JSON-RPC error body: `trigger_header_mismatch` → `400 / -32020`, `trigger_missing_capability` → `400 / -32021`, `trigger_unsupported_version` → `400 / -32022` (with `data.supported`), `trigger_method_not_found` → `404 / -32601`. Connect to it with **Protocol Era = Modern** and open the Network tab to see the mirrored `Mcp-*` headers highlighted, sentinel values decoded, and each error rendered distinctly. Note: `Mcp-Param-*` mirroring is **skipped by the SDK in the browser** (`detectProbeEnvironment() !== "browser"`), so calling `get_weather` from the **web** client omits `Mcp-Param-City` and the strict server answers `-32020` — the same tool is callable from the Node CLI/TUI, where mirroring is active.
|
||||
|
||||
`test-servers/configs/xmcpheader-modern-http.json` is the **`x-mcp-header` Tools-tab showcase** (#1632). It serves `echo`, a `get_weather` tool with a **valid** `x-mcp-header: "City"` annotation on its `city` argument, an `invalid_header_tool` whose annotation uses the header name `"Bad Header"` (a space makes it an invalid RFC 9110 token, so the whole tool definition is invalid), and a `trigger_invalid_params` tool that the modern leg's spec-error injector (`transport.modern.injectSpecErrors: true`) answers with a real `-32602 Invalid params` JSON-RPC error whose message is not about a missing tool. Connect with **Protocol Era = Modern** and open the Tools tab: `get_weather`'s detail panel shows a **"Mirrored request headers (SEP-2243)"** section (`city → Mcp-Param-City`), and `invalid_header_tool` appears struck-through under an **"Excluded (SEP-2243)"** divider in the sidebar with the reason on hover (a conforming Streamable HTTP client MUST drop it from `tools/list`; the Inspector surfaces _why_). Under SDK v2 a `tools/call` that rejects with **`-32602`** now renders as a distinct error panel rather than an `isError` result — headed **"Unknown Tool"** when the message names a missing tool (reproduce by calling a tool the server dropped from its list), or **"Invalid Parameters"** for any other `-32602` (run `trigger_invalid_params`).
|
||||
|
||||
`test-servers/configs/pagination-http.json` is the **page-by-page fetch showcase** (#1721). It serves 12 tools, 12 resources, and 12 prompts (presets `numbered_tools` / `numbered_resources` / `numbered_prompts`, `count: 12`) with `maxPageSize` of 4 for each, so every list paginates into three pages. Turn on **"Fetch Lists One Page at a Time"** (Server Settings — the `paginatedLists` setting, or the **Paginated** switch in a list sidebar) and the Tools/Resources/Prompts lists load page 1 only (4 items) with a **Load next page** control and an _N pages loaded_ status; each click fetches the next 4 and appends them, and Refresh resets to page 1. With the switch off (the default), the same lists auto-aggregate all three pages on connect.
|
||||
|
||||
`test-servers/configs/logging-legacy-http.json` and `test-servers/configs/logging-modern-http.json` are the **logging era-fork showcase** (#1629). Both serve `logging: true` plus a `send_notification` tool that emits a `notifications/message` at a chosen level; the legacy one is a plain streamable-HTTP server (`logging/setLevel` era) and the modern one sets `transport.modern: true`. Connect to the legacy server and open the **Logs** tab to get the session-scoped **Set Active Level** selector + **Set** button; calling `send_notification` streams the log into the panel. Connect to the modern one with **Protocol Era = Modern** and the same tab instead shows the **Log Level per Request** control — pick a level to opt in and the client stamps `_meta["io.modelcontextprotocol/logLevel"]` on every subsequent request (verify in the Network tab's request body); calling `send_notification` then streams the log into the panel over the request's SSE response. Set the control back to **Off** and the same call is silently gated — the request omits the `logLevel` key, so the log never arrives. That gating is faithful to the spec ("a server MUST NOT emit `notifications/message` for a request that didn't opt in") because `send_notification` emits through the SDK's request-scoped, threshold-aware `extra.log` (`ctx.mcpReq.log`): on the modern leg it reads the per-request `logLevel` opt-in from the request envelope and drops the message when the client didn't opt in or the level is below the requested severity; on legacy it honors the session level from `logging/setLevel`. Because it emits through the request's `notify`, the modern response upgrades to SSE and the log rides the originating request's stream.
|
||||
|
||||
`test-servers/configs/subscriptions-legacy-http.json` and `test-servers/configs/subscriptions-modern-http.json` are the **resource-subscription era-fork showcase** (#1630). Both serve three `numbered_resources` with `subscriptions: true`; the legacy one also serves an `update_resource` tool, and the modern one sets `transport.modern: true`. Connect to the **legacy** server, open a resource in the **Resources** tab and click **Subscribe** — the client sends `resources/subscribe` (Network/Protocol view) and the Subscriptions section lists the URI with no stream chrome; call `update_resource` with that URI and the server updates the content and emits `notifications/resources/updated`, stamping the subscribed tile's last-updated time. Connect to the **modern** server with **Protocol Era = Modern** and the same Subscribe instead sends **`subscriptions/listen`** (its filter carries `resourceSubscriptions` + the `resourcesListChanged` opt-in) and resolves on `notifications/subscriptions/acknowledged`; the Subscriptions section then shows the stream-status badge (`Connecting…` → `Listening`) in its header, and if the long-lived stream drops it reconnects by re-listing. The modern config deliberately **omits** `update_resource`: the SDK's modern leg is stateless/per-request (`createMcpHandler(() => createMcpServer(config))`), so the tool would run against a throwaway server instance — the content change wouldn't persist for the next `resources/read`, and its `resources/updated` wouldn't reach the (separate) listen stream — which is more confusing than useful. The live update-notification round-trip is therefore demonstrated on the legacy (stateful-session) server; the modern server is for the subscribe/listen/badge behavior. (The Inspector's *receive* path is era-transparent, so a real stateful modern server that routes `resources/updated` onto the listen stream drives the subscribed tile the same way.)
|
||||
`test-servers/configs/subscriptions-legacy-http.json` and `test-servers/configs/subscriptions-modern-http.json` are the **resource-subscription era-fork showcase** (#1630). Both serve three `numbered_resources` with `subscriptions: true`; the legacy one also serves an `update_resource` tool, and the modern one sets `transport.modern: true`. Connect to the **legacy** server, open a resource in the **Resources** tab and click **Subscribe** — the client sends `resources/subscribe` (Network/Protocol view) and the Subscriptions section lists the URI with no stream chrome; call `update_resource` with that URI and the server updates the content and emits `notifications/resources/updated`, stamping the subscribed tile's last-updated time. Connect to the **modern** server with **Protocol Era = Modern** and the same Subscribe instead sends **`subscriptions/listen`** (its filter carries `resourceSubscriptions` + the `resourcesListChanged` opt-in) and resolves on `notifications/subscriptions/acknowledged`; the Subscriptions section then shows the stream-status badge (`Connecting…` → `Listening`) in its header, and if the long-lived stream drops it reconnects by re-listing. The modern config deliberately **omits** `update_resource`: the SDK's modern leg is stateless/per-request (`createMcpHandler(() => createMcpServer(config))`), so the tool would run against a throwaway server instance — the content change wouldn't persist for the next `resources/read`, and its `resources/updated` wouldn't reach the (separate) listen stream — which is more confusing than useful. The live update-notification round-trip is therefore demonstrated on the legacy (stateful-session) server; the modern server is for the subscribe/listen/badge behavior. (The Inspector's _receive_ path is era-transparent, so a real stateful modern server that routes `resources/updated` onto the listen stream drives the subscribed tile the same way.)
|
||||
|
||||
`test-servers/configs/tasks-legacy-http.json` and `test-servers/configs/tasks-modern-http.json` are the **Tasks era-fork showcase** (#1631). The legacy server advertises `capabilities.tasks` (`tasks: { list, cancel }`) with the `simple_task` / `progress_task` / `elicitation_task` presets — connect to it, run one of those tools with **Run as task** on, and the **Tasks** tab lists it (populated via `tasks/list`), polls `tasks/get`, fetches the payload with the blocking `tasks/result`, and cancels with `tasks/cancel`. The modern server sets `transport.modern: true` and `tasksExtension: true`, advertising the `io.modelcontextprotocol/tasks` extension (SEP-2663) and serving the `modern_task` / `modern_input_task` tools. Connect with **Protocol Era = Modern**: the **Tasks** tab is now gated on the negotiated extension (not `capabilities.tasks`). Run `modern_task` as a task — the `tools/call` returns a `CreateTaskResult` (`resultType: "task"`, visible in the Protocol/Network tabs), the client polls **`tasks/get`** (no `tasks/list`), and the completed task inlines its result (no blocking `tasks/result`). Run `modern_input_task` and the task moves to `input_required`, surfacing an embedded elicitation through the pending-request modal; answering it sends **`tasks/update`** with the `inputResponses`, and the next poll completes. SDK v2 removed all tasks support **and** era-gates the `tasks/*` spec methods out of the modern era on both sides — so the Inspector drives the extension itself (the `resultType: "task"` frame is rewritten at the transport into a `CallToolResult` carrying the handle; `tasks/get`/`update`/`cancel` ride a raw-wire request channel with the full modern envelope), and the test server serves `tasks/*` from an Express interceptor ahead of the SDK handler (the SDK's modern leg would answer them `-32601`). The Tasks tab's **Refresh** re-polls the handles already known to the client (modern has no server-side task list).
|
||||
|
||||
|
|
|
|||
38
clients/cli/package-lock.json
generated
38
clients/cli/package-lock.json
generated
|
|
@ -8,10 +8,10 @@
|
|||
"name": "@modelcontextprotocol/inspector-cli",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@modelcontextprotocol/client": "2.0.0-beta.4",
|
||||
"@modelcontextprotocol/core": "2.0.0-beta.4",
|
||||
"@modelcontextprotocol/server": "2.0.0-beta.4",
|
||||
"@modelcontextprotocol/server-legacy": "2.0.0-beta.4",
|
||||
"@modelcontextprotocol/client": "2.0.0-beta.5",
|
||||
"@modelcontextprotocol/core": "2.0.0-beta.5",
|
||||
"@modelcontextprotocol/server": "2.0.0-beta.5",
|
||||
"@modelcontextprotocol/server-legacy": "2.0.0-beta.5",
|
||||
"@napi-rs/keyring": "^1.3.0",
|
||||
"ajv": "^8.17.1",
|
||||
"atomically": "^2.1.1",
|
||||
|
|
@ -859,12 +859,12 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@modelcontextprotocol/client": {
|
||||
"version": "2.0.0-beta.4",
|
||||
"resolved": "https://registry.npmjs.org/@modelcontextprotocol/client/-/client-2.0.0-beta.4.tgz",
|
||||
"integrity": "sha512-VNHA/UXDk7mCpVl+jOg5B4WMRRD2OEl+it360Lhi6HiCbrIB2f6pZ0cqSDKXQVUtZvqnhdQHzZAM9h8EKWhq/A==",
|
||||
"version": "2.0.0-beta.5",
|
||||
"resolved": "https://registry.npmjs.org/@modelcontextprotocol/client/-/client-2.0.0-beta.5.tgz",
|
||||
"integrity": "sha512-YuuNm5f2TMoFQRje1UqVP8TJRjijCXMz4ckvoVpx1cUXuBEmykWQ2d8R536pek6UKcXT41T5nWc4qR1JFIbEmg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@modelcontextprotocol/core": "2.0.0-beta.4",
|
||||
"@modelcontextprotocol/core": "2.0.0-beta.5",
|
||||
"cross-spawn": "^7.0.5",
|
||||
"eventsource": "^3.0.2",
|
||||
"eventsource-parser": "^3.0.0",
|
||||
|
|
@ -877,9 +877,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@modelcontextprotocol/core": {
|
||||
"version": "2.0.0-beta.4",
|
||||
"resolved": "https://registry.npmjs.org/@modelcontextprotocol/core/-/core-2.0.0-beta.4.tgz",
|
||||
"integrity": "sha512-nsMXd4wQBKzmph6r+WOhum+mXjDYljTAqwY/XUg3hLtvNOQ8+JVqBSJOVCMJvx9lXhTpTOPrGZ3BuNiaNPjSvg==",
|
||||
"version": "2.0.0-beta.5",
|
||||
"resolved": "https://registry.npmjs.org/@modelcontextprotocol/core/-/core-2.0.0-beta.5.tgz",
|
||||
"integrity": "sha512-HKbY9XTbsDy1Y6r2I55TGE3JEapM0vg96e1MUmBIF9LGjos5gjhcIrTz1yvBPLg2aFKHjwhUAQfRdrCEnPxNew==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"zod": "^4.2.0"
|
||||
|
|
@ -889,12 +889,12 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@modelcontextprotocol/server": {
|
||||
"version": "2.0.0-beta.4",
|
||||
"resolved": "https://registry.npmjs.org/@modelcontextprotocol/server/-/server-2.0.0-beta.4.tgz",
|
||||
"integrity": "sha512-pjMZcNEt1dOq0aJCcY3b7w1Ayh+qmQN2xlfTELcGV9yiAjEGIczBPBLWWW0k0zzo5T8kiv15jtKPsWeHGxLvLg==",
|
||||
"version": "2.0.0-beta.5",
|
||||
"resolved": "https://registry.npmjs.org/@modelcontextprotocol/server/-/server-2.0.0-beta.5.tgz",
|
||||
"integrity": "sha512-i1E5l75rQKsgY/AKAIspgMBH1vEL7dqiK7tHr0L+raYcb0SWOziqNGJXGIG6NY4AlXDWIKGJQGB7Nqfs3oUi5g==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@modelcontextprotocol/core": "2.0.0-beta.4",
|
||||
"@modelcontextprotocol/core": "2.0.0-beta.5",
|
||||
"zod": "^4.2.0"
|
||||
},
|
||||
"engines": {
|
||||
|
|
@ -902,13 +902,13 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@modelcontextprotocol/server-legacy": {
|
||||
"version": "2.0.0-beta.4",
|
||||
"resolved": "https://registry.npmjs.org/@modelcontextprotocol/server-legacy/-/server-legacy-2.0.0-beta.4.tgz",
|
||||
"integrity": "sha512-GaEa7mfjTqevGuz2taFj2fqb3FthxFvWOmoI/wbLmiK1XRnxdYsAaaJG/lgSlA+W6XWJ1+u+6oZ7610TowkjMA==",
|
||||
"version": "2.0.0-beta.5",
|
||||
"resolved": "https://registry.npmjs.org/@modelcontextprotocol/server-legacy/-/server-legacy-2.0.0-beta.5.tgz",
|
||||
"integrity": "sha512-8BemN4avQnG6Fu660fZCqnPGpeyL7gg5kxUceZQh7JCt8oqzX1bwJkNV+cKS01LPAaPbl93INneD+mBtJWKWvQ==",
|
||||
"deprecated": "This package is a frozen copy of v1's SSE transport and OAuth Authorization Server helpers for migration purposes only. Use StreamableHTTP from @modelcontextprotocol/server and a dedicated OAuth server in production. Will not receive new features.",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@modelcontextprotocol/core": "2.0.0-beta.4",
|
||||
"@modelcontextprotocol/core": "2.0.0-beta.5",
|
||||
"content-type": "^1.0.5",
|
||||
"cors": "^2.8.5",
|
||||
"express-rate-limit": "^8.2.1",
|
||||
|
|
|
|||
|
|
@ -31,10 +31,10 @@
|
|||
"format:check": "prettier --check src __tests__"
|
||||
},
|
||||
"dependencies": {
|
||||
"@modelcontextprotocol/client": "2.0.0-beta.4",
|
||||
"@modelcontextprotocol/core": "2.0.0-beta.4",
|
||||
"@modelcontextprotocol/server": "2.0.0-beta.4",
|
||||
"@modelcontextprotocol/server-legacy": "2.0.0-beta.4",
|
||||
"@modelcontextprotocol/client": "2.0.0-beta.5",
|
||||
"@modelcontextprotocol/core": "2.0.0-beta.5",
|
||||
"@modelcontextprotocol/server": "2.0.0-beta.5",
|
||||
"@modelcontextprotocol/server-legacy": "2.0.0-beta.5",
|
||||
"@napi-rs/keyring": "^1.3.0",
|
||||
"ajv": "^8.17.1",
|
||||
"atomically": "^2.1.1",
|
||||
|
|
|
|||
18
clients/tui/package-lock.json
generated
18
clients/tui/package-lock.json
generated
|
|
@ -8,8 +8,8 @@
|
|||
"name": "@modelcontextprotocol/inspector-tui",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@modelcontextprotocol/client": "2.0.0-beta.4",
|
||||
"@modelcontextprotocol/core": "2.0.0-beta.4",
|
||||
"@modelcontextprotocol/client": "2.0.0-beta.5",
|
||||
"@modelcontextprotocol/core": "2.0.0-beta.5",
|
||||
"@napi-rs/keyring": "^1.3.0",
|
||||
"ajv": "^8.17.1",
|
||||
"atomically": "^2.1.1",
|
||||
|
|
@ -1108,12 +1108,12 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@modelcontextprotocol/client": {
|
||||
"version": "2.0.0-beta.4",
|
||||
"resolved": "https://registry.npmjs.org/@modelcontextprotocol/client/-/client-2.0.0-beta.4.tgz",
|
||||
"integrity": "sha512-VNHA/UXDk7mCpVl+jOg5B4WMRRD2OEl+it360Lhi6HiCbrIB2f6pZ0cqSDKXQVUtZvqnhdQHzZAM9h8EKWhq/A==",
|
||||
"version": "2.0.0-beta.5",
|
||||
"resolved": "https://registry.npmjs.org/@modelcontextprotocol/client/-/client-2.0.0-beta.5.tgz",
|
||||
"integrity": "sha512-YuuNm5f2TMoFQRje1UqVP8TJRjijCXMz4ckvoVpx1cUXuBEmykWQ2d8R536pek6UKcXT41T5nWc4qR1JFIbEmg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@modelcontextprotocol/core": "2.0.0-beta.4",
|
||||
"@modelcontextprotocol/core": "2.0.0-beta.5",
|
||||
"cross-spawn": "^7.0.5",
|
||||
"eventsource": "^3.0.2",
|
||||
"eventsource-parser": "^3.0.0",
|
||||
|
|
@ -1126,9 +1126,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@modelcontextprotocol/core": {
|
||||
"version": "2.0.0-beta.4",
|
||||
"resolved": "https://registry.npmjs.org/@modelcontextprotocol/core/-/core-2.0.0-beta.4.tgz",
|
||||
"integrity": "sha512-nsMXd4wQBKzmph6r+WOhum+mXjDYljTAqwY/XUg3hLtvNOQ8+JVqBSJOVCMJvx9lXhTpTOPrGZ3BuNiaNPjSvg==",
|
||||
"version": "2.0.0-beta.5",
|
||||
"resolved": "https://registry.npmjs.org/@modelcontextprotocol/core/-/core-2.0.0-beta.5.tgz",
|
||||
"integrity": "sha512-HKbY9XTbsDy1Y6r2I55TGE3JEapM0vg96e1MUmBIF9LGjos5gjhcIrTz1yvBPLg2aFKHjwhUAQfRdrCEnPxNew==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"zod": "^4.2.0"
|
||||
|
|
|
|||
|
|
@ -26,8 +26,8 @@
|
|||
"format:check": "prettier --check src __tests__ index.ts tui.tsx dev.ts"
|
||||
},
|
||||
"dependencies": {
|
||||
"@modelcontextprotocol/client": "2.0.0-beta.4",
|
||||
"@modelcontextprotocol/core": "2.0.0-beta.4",
|
||||
"@modelcontextprotocol/client": "2.0.0-beta.5",
|
||||
"@modelcontextprotocol/core": "2.0.0-beta.5",
|
||||
"@napi-rs/keyring": "^1.3.0",
|
||||
"ajv": "^8.17.1",
|
||||
"atomically": "^2.1.1",
|
||||
|
|
|
|||
38
clients/web/package-lock.json
generated
38
clients/web/package-lock.json
generated
|
|
@ -16,11 +16,11 @@
|
|||
"@mantine/form": "^8.3.17",
|
||||
"@mantine/hooks": "^8.3.17",
|
||||
"@mantine/notifications": "^8.3.17",
|
||||
"@modelcontextprotocol/client": "2.0.0-beta.4",
|
||||
"@modelcontextprotocol/core": "2.0.0-beta.4",
|
||||
"@modelcontextprotocol/client": "2.0.0-beta.5",
|
||||
"@modelcontextprotocol/core": "2.0.0-beta.5",
|
||||
"@modelcontextprotocol/ext-apps": "^1.7.4",
|
||||
"@modelcontextprotocol/server": "2.0.0-beta.4",
|
||||
"@modelcontextprotocol/server-legacy": "2.0.0-beta.4",
|
||||
"@modelcontextprotocol/server": "2.0.0-beta.5",
|
||||
"@modelcontextprotocol/server-legacy": "2.0.0-beta.5",
|
||||
"@napi-rs/keyring": "^1.3.0",
|
||||
"ajv": "^8.17.1",
|
||||
"atomically": "^2.1.1",
|
||||
|
|
@ -1441,12 +1441,12 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@modelcontextprotocol/client": {
|
||||
"version": "2.0.0-beta.4",
|
||||
"resolved": "https://registry.npmjs.org/@modelcontextprotocol/client/-/client-2.0.0-beta.4.tgz",
|
||||
"integrity": "sha512-VNHA/UXDk7mCpVl+jOg5B4WMRRD2OEl+it360Lhi6HiCbrIB2f6pZ0cqSDKXQVUtZvqnhdQHzZAM9h8EKWhq/A==",
|
||||
"version": "2.0.0-beta.5",
|
||||
"resolved": "https://registry.npmjs.org/@modelcontextprotocol/client/-/client-2.0.0-beta.5.tgz",
|
||||
"integrity": "sha512-YuuNm5f2TMoFQRje1UqVP8TJRjijCXMz4ckvoVpx1cUXuBEmykWQ2d8R536pek6UKcXT41T5nWc4qR1JFIbEmg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@modelcontextprotocol/core": "2.0.0-beta.4",
|
||||
"@modelcontextprotocol/core": "2.0.0-beta.5",
|
||||
"cross-spawn": "^7.0.5",
|
||||
"eventsource": "^3.0.2",
|
||||
"eventsource-parser": "^3.0.0",
|
||||
|
|
@ -1459,9 +1459,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@modelcontextprotocol/core": {
|
||||
"version": "2.0.0-beta.4",
|
||||
"resolved": "https://registry.npmjs.org/@modelcontextprotocol/core/-/core-2.0.0-beta.4.tgz",
|
||||
"integrity": "sha512-nsMXd4wQBKzmph6r+WOhum+mXjDYljTAqwY/XUg3hLtvNOQ8+JVqBSJOVCMJvx9lXhTpTOPrGZ3BuNiaNPjSvg==",
|
||||
"version": "2.0.0-beta.5",
|
||||
"resolved": "https://registry.npmjs.org/@modelcontextprotocol/core/-/core-2.0.0-beta.5.tgz",
|
||||
"integrity": "sha512-HKbY9XTbsDy1Y6r2I55TGE3JEapM0vg96e1MUmBIF9LGjos5gjhcIrTz1yvBPLg2aFKHjwhUAQfRdrCEnPxNew==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"zod": "^4.2.0"
|
||||
|
|
@ -1541,12 +1541,12 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@modelcontextprotocol/server": {
|
||||
"version": "2.0.0-beta.4",
|
||||
"resolved": "https://registry.npmjs.org/@modelcontextprotocol/server/-/server-2.0.0-beta.4.tgz",
|
||||
"integrity": "sha512-pjMZcNEt1dOq0aJCcY3b7w1Ayh+qmQN2xlfTELcGV9yiAjEGIczBPBLWWW0k0zzo5T8kiv15jtKPsWeHGxLvLg==",
|
||||
"version": "2.0.0-beta.5",
|
||||
"resolved": "https://registry.npmjs.org/@modelcontextprotocol/server/-/server-2.0.0-beta.5.tgz",
|
||||
"integrity": "sha512-i1E5l75rQKsgY/AKAIspgMBH1vEL7dqiK7tHr0L+raYcb0SWOziqNGJXGIG6NY4AlXDWIKGJQGB7Nqfs3oUi5g==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@modelcontextprotocol/core": "2.0.0-beta.4",
|
||||
"@modelcontextprotocol/core": "2.0.0-beta.5",
|
||||
"zod": "^4.2.0"
|
||||
},
|
||||
"engines": {
|
||||
|
|
@ -1554,13 +1554,13 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@modelcontextprotocol/server-legacy": {
|
||||
"version": "2.0.0-beta.4",
|
||||
"resolved": "https://registry.npmjs.org/@modelcontextprotocol/server-legacy/-/server-legacy-2.0.0-beta.4.tgz",
|
||||
"integrity": "sha512-GaEa7mfjTqevGuz2taFj2fqb3FthxFvWOmoI/wbLmiK1XRnxdYsAaaJG/lgSlA+W6XWJ1+u+6oZ7610TowkjMA==",
|
||||
"version": "2.0.0-beta.5",
|
||||
"resolved": "https://registry.npmjs.org/@modelcontextprotocol/server-legacy/-/server-legacy-2.0.0-beta.5.tgz",
|
||||
"integrity": "sha512-8BemN4avQnG6Fu660fZCqnPGpeyL7gg5kxUceZQh7JCt8oqzX1bwJkNV+cKS01LPAaPbl93INneD+mBtJWKWvQ==",
|
||||
"deprecated": "This package is a frozen copy of v1's SSE transport and OAuth Authorization Server helpers for migration purposes only. Use StreamableHTTP from @modelcontextprotocol/server and a dedicated OAuth server in production. Will not receive new features.",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@modelcontextprotocol/core": "2.0.0-beta.4",
|
||||
"@modelcontextprotocol/core": "2.0.0-beta.5",
|
||||
"content-type": "^1.0.5",
|
||||
"cors": "^2.8.5",
|
||||
"express-rate-limit": "^8.2.1",
|
||||
|
|
|
|||
|
|
@ -41,11 +41,11 @@
|
|||
"@mantine/form": "^8.3.17",
|
||||
"@mantine/hooks": "^8.3.17",
|
||||
"@mantine/notifications": "^8.3.17",
|
||||
"@modelcontextprotocol/client": "2.0.0-beta.4",
|
||||
"@modelcontextprotocol/core": "2.0.0-beta.4",
|
||||
"@modelcontextprotocol/client": "2.0.0-beta.5",
|
||||
"@modelcontextprotocol/core": "2.0.0-beta.5",
|
||||
"@modelcontextprotocol/ext-apps": "^1.7.4",
|
||||
"@modelcontextprotocol/server": "2.0.0-beta.4",
|
||||
"@modelcontextprotocol/server-legacy": "2.0.0-beta.4",
|
||||
"@modelcontextprotocol/server": "2.0.0-beta.5",
|
||||
"@modelcontextprotocol/server-legacy": "2.0.0-beta.5",
|
||||
"@napi-rs/keyring": "^1.3.0",
|
||||
"ajv": "^8.17.1",
|
||||
"atomically": "^2.1.1",
|
||||
|
|
|
|||
|
|
@ -563,6 +563,7 @@ const DEFAULT_USE_INSPECTOR_CLIENT: ReturnType<typeof useInspectorClient> = {
|
|||
clientCapabilities: {},
|
||||
serverInfo: undefined,
|
||||
instructions: undefined,
|
||||
excludedTools: [],
|
||||
appRendererClient: null,
|
||||
connect: vi.fn().mockResolvedValue(undefined),
|
||||
disconnect: vi.fn().mockResolvedValue(undefined),
|
||||
|
|
|
|||
|
|
@ -463,6 +463,18 @@ function errorMessage(err: unknown): string {
|
|||
return err instanceof Error ? err.message : String(err);
|
||||
}
|
||||
|
||||
// The numeric JSON-RPC code of a thrown protocol error (e.g. a `ProtocolError`
|
||||
// carrying `-32602`), or undefined for a plain Error. Duck-typed like
|
||||
// `formatErrorDetails` so we don't couple to the SDK's error class here — the
|
||||
// only consumer is the Tools error panel's unknown-tool (`-32602`) hint (#1632).
|
||||
function errorCodeOf(err: unknown): number | undefined {
|
||||
if (err && typeof err === "object") {
|
||||
const code = (err as { code?: unknown }).code;
|
||||
if (typeof code === "number") return code;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// Pretty-print a thrown error for the URL-elicitation details modal: a ProtocolError
|
||||
// carries a `code`/`data` worth showing alongside the message, so include them
|
||||
// when present; otherwise fall back to the plain message.
|
||||
|
|
@ -935,6 +947,7 @@ function App() {
|
|||
protocolVersion,
|
||||
protocolEra,
|
||||
discoverResult,
|
||||
excludedTools,
|
||||
lastError,
|
||||
} = useInspectorClient(inspectorClient);
|
||||
const {
|
||||
|
|
@ -2933,6 +2946,7 @@ function App() {
|
|||
setToolCallState({
|
||||
status: "error",
|
||||
error: errorMessage(err),
|
||||
errorCode: errorCodeOf(err),
|
||||
});
|
||||
}
|
||||
},
|
||||
|
|
@ -4198,6 +4212,7 @@ function App() {
|
|||
initializeResult={initializeResult}
|
||||
latencyMs={latencyMs}
|
||||
tools={tools}
|
||||
excludedTools={excludedTools}
|
||||
prompts={prompts}
|
||||
resources={resources}
|
||||
resourceTemplates={resourceTemplates}
|
||||
|
|
|
|||
|
|
@ -135,4 +135,52 @@ describe("ToolControls", () => {
|
|||
expect(screen.getByText("Tools")).toBeInTheDocument();
|
||||
expect(screen.queryByText("git_status")).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
const excludedFixture = [
|
||||
{
|
||||
tool: {
|
||||
name: "invalid_header_tool",
|
||||
inputSchema: { type: "object" as const },
|
||||
},
|
||||
reason:
|
||||
"value: x-mcp-header 'Bad Header' is not a valid RFC 9110 token (no spaces, control characters or HTTP delimiters)",
|
||||
},
|
||||
];
|
||||
|
||||
it("renders excluded tools with a header and the tool name (#1632)", () => {
|
||||
renderWithMantine(
|
||||
<ToolControls {...baseProps} excludedTools={excludedFixture} />,
|
||||
);
|
||||
expect(screen.getByText("Excluded (SEP-2243)")).toBeInTheDocument();
|
||||
expect(screen.getByText("invalid_header_tool")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("does not render the excluded section when there are none", () => {
|
||||
renderWithMantine(<ToolControls {...baseProps} excludedTools={[]} />);
|
||||
expect(screen.queryByText("Excluded (SEP-2243)")).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("filters excluded tools by the search text (#1632)", () => {
|
||||
renderWithMantine(
|
||||
<ToolControls
|
||||
{...baseProps}
|
||||
excludedTools={excludedFixture}
|
||||
searchText="git"
|
||||
/>,
|
||||
);
|
||||
// The search matches no excluded tool, so the section is hidden.
|
||||
expect(screen.queryByText("Excluded (SEP-2243)")).not.toBeInTheDocument();
|
||||
expect(screen.queryByText("invalid_header_tool")).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("keeps a matching excluded tool visible under search (#1632)", () => {
|
||||
renderWithMantine(
|
||||
<ToolControls
|
||||
{...baseProps}
|
||||
excludedTools={excludedFixture}
|
||||
searchText="invalid"
|
||||
/>,
|
||||
);
|
||||
expect(screen.getByText("invalid_header_tool")).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,6 +1,18 @@
|
|||
import { Group, ScrollArea, Stack, TextInput, Title } from "@mantine/core";
|
||||
import {
|
||||
Divider,
|
||||
Group,
|
||||
ScrollArea,
|
||||
Stack,
|
||||
Text,
|
||||
TextInput,
|
||||
ThemeIcon,
|
||||
Title,
|
||||
Tooltip,
|
||||
} from "@mantine/core";
|
||||
import { RiErrorWarningLine } from "react-icons/ri";
|
||||
import { ClearButton } from "../../elements/ClearButton/ClearButton";
|
||||
import type { Tool } from "@modelcontextprotocol/client";
|
||||
import type { ExcludedTool } from "@inspector/core/mcp/types.js";
|
||||
import { ListChangedIndicator } from "../../elements/ListChangedIndicator/ListChangedIndicator";
|
||||
import {
|
||||
ListPaginationControls,
|
||||
|
|
@ -11,6 +23,9 @@ import { useScrollMemory } from "../../../hooks/useScrollMemory";
|
|||
|
||||
export interface ToolControlsProps {
|
||||
tools: Tool[];
|
||||
/** Tools the SDK excluded from `tools/list` for invalid `x-mcp-header`
|
||||
* annotations (SEP-2243), shown below the list with the reason (#1632). */
|
||||
excludedTools?: ExcludedTool[];
|
||||
selectedName?: string;
|
||||
// Search text is controlled by the parent (App, via ToolsScreen) so it
|
||||
// persists across tab navigation within a live session — see #1417.
|
||||
|
|
@ -23,8 +38,31 @@ export interface ToolControlsProps {
|
|||
onSelectTool: (name: string) => void;
|
||||
}
|
||||
|
||||
// One excluded tool: a warning icon, the tool name (struck through, since it is
|
||||
// not callable), and its reason on hover. `wrap: nowrap` keeps the icon pinned.
|
||||
const ExcludedRow = Group.withProps({
|
||||
gap: "xs",
|
||||
wrap: "nowrap",
|
||||
align: "center",
|
||||
});
|
||||
|
||||
const ExcludedWarningIcon = ThemeIcon.withProps({
|
||||
size: "sm",
|
||||
variant: "transparent",
|
||||
c: "var(--inspector-log-warning)",
|
||||
"aria-hidden": true,
|
||||
});
|
||||
|
||||
const ExcludedName = Text.withProps({
|
||||
size: "sm",
|
||||
td: "line-through",
|
||||
c: "var(--inspector-text-secondary)",
|
||||
truncate: "end",
|
||||
});
|
||||
|
||||
export function ToolControls({
|
||||
tools,
|
||||
excludedTools = [],
|
||||
selectedName,
|
||||
searchText = "",
|
||||
listChanged,
|
||||
|
|
@ -42,6 +80,15 @@ export function ToolControls({
|
|||
(tool.title?.toLowerCase().includes(query) ?? false),
|
||||
)
|
||||
: tools;
|
||||
// Excluded tools are searchable too, matching name AND title like the main
|
||||
// list above, so a filtered view stays consistent.
|
||||
const filteredExcluded = searchText
|
||||
? excludedTools.filter(
|
||||
({ tool }) =>
|
||||
tool.name.toLowerCase().includes(query) ||
|
||||
(tool.title?.toLowerCase().includes(query) ?? false),
|
||||
)
|
||||
: excludedTools;
|
||||
|
||||
return (
|
||||
// Fill the full-height `sidebar` Card (a flex column) so the scroll region
|
||||
|
|
@ -81,6 +128,32 @@ export function ToolControls({
|
|||
}}
|
||||
/>
|
||||
))}
|
||||
{filteredExcluded.length > 0 && (
|
||||
<>
|
||||
<Divider
|
||||
label="Excluded (SEP-2243)"
|
||||
labelPosition="left"
|
||||
mt="sm"
|
||||
/>
|
||||
{filteredExcluded.map(({ tool, reason }) => (
|
||||
<Tooltip
|
||||
key={tool.name}
|
||||
label={reason}
|
||||
multiline
|
||||
w={280}
|
||||
withArrow
|
||||
position="right"
|
||||
>
|
||||
<ExcludedRow>
|
||||
<ExcludedWarningIcon>
|
||||
<RiErrorWarningLine />
|
||||
</ExcludedWarningIcon>
|
||||
<ExcludedName>{tool.name}</ExcludedName>
|
||||
</ExcludedRow>
|
||||
</Tooltip>
|
||||
))}
|
||||
</>
|
||||
)}
|
||||
</Stack>
|
||||
</ScrollArea>
|
||||
</Stack>
|
||||
|
|
|
|||
|
|
@ -469,4 +469,37 @@ describe("ToolDetailPanel", () => {
|
|||
expect(onExecute).toHaveBeenCalledWith(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("mirrored request headers (SEP-2243, #1632)", () => {
|
||||
const mirroredTool: Tool = {
|
||||
name: "get_weather",
|
||||
inputSchema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
city: { type: "string", "x-mcp-header": "City" },
|
||||
country: { type: "string", "x-mcp-header": "Country" },
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
it("lists each mirrored arg and its Mcp-Param header", () => {
|
||||
renderWithMantine(<ToolDetailPanel {...baseProps} tool={mirroredTool} />);
|
||||
expect(
|
||||
screen.getByText("Mirrored request headers (SEP-2243)"),
|
||||
).toBeInTheDocument();
|
||||
// The header names are unique to this section (the arg names `city` /
|
||||
// `country` also appear as form-field labels below).
|
||||
expect(screen.getByText("Mcp-Param-City")).toBeInTheDocument();
|
||||
expect(screen.getByText("Mcp-Param-Country")).toBeInTheDocument();
|
||||
// The arg path renders in a <code> alongside its header.
|
||||
expect(screen.getAllByText("city").length).toBeGreaterThanOrEqual(1);
|
||||
});
|
||||
|
||||
it("omits the section for a tool without x-mcp-header annotations", () => {
|
||||
renderWithMantine(<ToolDetailPanel {...baseProps} tool={simpleTool} />);
|
||||
expect(
|
||||
screen.queryByText("Mirrored request headers (SEP-2243)"),
|
||||
).not.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import {
|
||||
ActionIcon,
|
||||
Button,
|
||||
Code,
|
||||
Collapse,
|
||||
Divider,
|
||||
Group,
|
||||
|
|
@ -19,6 +20,7 @@ import type {
|
|||
} from "@modelcontextprotocol/client";
|
||||
import { resolveDisplayLabel } from "../../../utils/toolUtils";
|
||||
import { toFormSchema } from "../../../utils/jsonUtils";
|
||||
import { getMirroredHeaderParams } from "@inspector/core/json/xMcpHeader.js";
|
||||
import { AnnotationBadge } from "../../elements/AnnotationBadge/AnnotationBadge";
|
||||
import { ProgressDisplay } from "../../elements/ProgressDisplay/ProgressDisplay";
|
||||
import { SchemaForm } from "../SchemaForm/SchemaForm";
|
||||
|
|
@ -139,6 +141,34 @@ const RunAsTaskSwitch = Switch.withProps({
|
|||
label: "Run as task",
|
||||
});
|
||||
|
||||
// Header-mirroring section (SEP-2243): lists which args mirror their value into
|
||||
// an `Mcp-Param-{Name}` header on `tools/call`. `Stack` (not `Box`) so the
|
||||
// constant can carry props; the heading + note pin above the mapping rows.
|
||||
const HeaderParamsSection = Stack.withProps({
|
||||
gap: "xs",
|
||||
});
|
||||
|
||||
const HeaderParamsTitle = Text.withProps({
|
||||
size: "sm",
|
||||
fw: 600,
|
||||
});
|
||||
|
||||
const HeaderParamsNote = Text.withProps({
|
||||
size: "xs",
|
||||
c: "var(--inspector-text-secondary)",
|
||||
});
|
||||
|
||||
// One `arg → Mcp-Param-{Name}` mapping row.
|
||||
const HeaderParamRow = Group.withProps({
|
||||
gap: "xs",
|
||||
wrap: "nowrap",
|
||||
});
|
||||
|
||||
const HeaderParamArrow = Text.withProps({
|
||||
size: "sm",
|
||||
c: "var(--inspector-text-secondary)",
|
||||
});
|
||||
|
||||
// A tool's per-tool task support, defaulting to "forbidden" (the SDK default
|
||||
// when `execution` is absent) so tools that say nothing can't be run as tasks.
|
||||
type TaskSupport = "forbidden" | "optional" | "required";
|
||||
|
|
@ -173,6 +203,9 @@ export function ToolDetailPanel({
|
|||
// Narrow the SDK protocol schema to the form renderer's schema type.
|
||||
const formSchema = toFormSchema(inputSchema) ?? {};
|
||||
const iconSrc = icons?.[0]?.src;
|
||||
// SEP-2243: args this tool declares as `x-mcp-header` — their values mirror
|
||||
// into `Mcp-Param-{Name}` headers on a `tools/call` (#1632).
|
||||
const mirroredParams = getMirroredHeaderParams(tool);
|
||||
|
||||
// Descriptions are shown by default (most are short); the chevron lets the
|
||||
// user hide a long one to keep the form and Execute footer in view. Reset to
|
||||
|
|
@ -259,6 +292,26 @@ export function ToolDetailPanel({
|
|||
|
||||
<Divider />
|
||||
|
||||
{mirroredParams.length > 0 && (
|
||||
<HeaderParamsSection>
|
||||
<HeaderParamsTitle>
|
||||
Mirrored request headers (SEP-2243)
|
||||
</HeaderParamsTitle>
|
||||
{mirroredParams.map((param) => (
|
||||
<HeaderParamRow key={param.path}>
|
||||
<Code>{param.path}</Code>
|
||||
<HeaderParamArrow>→</HeaderParamArrow>
|
||||
<Code>{param.header}</Code>
|
||||
</HeaderParamRow>
|
||||
))}
|
||||
<HeaderParamsNote>
|
||||
These argument values are mirrored into HTTP headers on the
|
||||
call. The SDK sends them only on a Node/proxy transport — the
|
||||
browser omits <Code>Mcp-Param-*</Code> headers.
|
||||
</HeaderParamsNote>
|
||||
</HeaderParamsSection>
|
||||
)}
|
||||
|
||||
<SchemaForm
|
||||
schema={formSchema}
|
||||
values={formValues}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,44 @@
|
|||
import type { Decorator, Meta, StoryObj } from "@storybook/react-vite";
|
||||
import { Card, Flex } from "@mantine/core";
|
||||
import { fn } from "storybook/test";
|
||||
import { ToolCallErrorPanel } from "./ToolCallErrorPanel";
|
||||
|
||||
// Frame the panel in the same result card the Tools screen uses, so the story
|
||||
// shows it at its real width/height.
|
||||
const inCardDecorators: Decorator[] = [
|
||||
(Story) => (
|
||||
<Flex h={360} direction="column" align="stretch">
|
||||
<Card withBorder padding="lg" variant="preview">
|
||||
<Story />
|
||||
</Card>
|
||||
</Flex>
|
||||
),
|
||||
];
|
||||
|
||||
const meta: Meta<typeof ToolCallErrorPanel> = {
|
||||
title: "Groups/ToolCallErrorPanel",
|
||||
component: ToolCallErrorPanel,
|
||||
args: {
|
||||
onClear: fn(),
|
||||
},
|
||||
decorators: inCardDecorators,
|
||||
};
|
||||
|
||||
export default meta;
|
||||
type Story = StoryObj<typeof ToolCallErrorPanel>;
|
||||
|
||||
// A generic thrown protocol/SDK error (no special code).
|
||||
export const GenericError: Story = {
|
||||
args: {
|
||||
error: "MCP error -32603: Internal error while executing the tool",
|
||||
},
|
||||
};
|
||||
|
||||
// SDK v2's unknown-tool rejection: `-32602` arrives as a thrown error, not an
|
||||
// `isError` result, so it renders here with the targeted "Unknown Tool" hint.
|
||||
export const UnknownTool: Story = {
|
||||
args: {
|
||||
error: "MCP error -32602: Invalid params: unknown tool 'ghost_tool'",
|
||||
errorCode: -32602,
|
||||
},
|
||||
};
|
||||
|
|
@ -0,0 +1,78 @@
|
|||
import { describe, it, expect, vi } from "vitest";
|
||||
import userEvent from "@testing-library/user-event";
|
||||
import { renderWithMantine, screen } from "../../../test/renderWithMantine";
|
||||
import { ToolCallErrorPanel } from "./ToolCallErrorPanel";
|
||||
import { classifyToolCallError } from "./toolResultUtils";
|
||||
|
||||
describe("ToolCallErrorPanel", () => {
|
||||
it("renders a generic thrown error with the plain title and message", () => {
|
||||
renderWithMantine(
|
||||
<ToolCallErrorPanel error="Internal error" onClear={vi.fn()} />,
|
||||
);
|
||||
expect(screen.getByText("Tool Call Failed")).toBeInTheDocument();
|
||||
expect(screen.getByText("Tool Error")).toBeInTheDocument();
|
||||
expect(screen.getByText("Internal error")).toBeInTheDocument();
|
||||
// No -32602 hints for a generic error.
|
||||
expect(screen.queryByText(/does not recognize this tool/)).toBeNull();
|
||||
expect(screen.queryByText(/against the tool/)).toBeNull();
|
||||
});
|
||||
|
||||
it("renders the unknown-tool heading + hint when the message names it (#1632)", () => {
|
||||
renderWithMantine(
|
||||
<ToolCallErrorPanel
|
||||
error="MCP error -32602: Tool echo not found"
|
||||
errorCode={-32602}
|
||||
onClear={vi.fn()}
|
||||
/>,
|
||||
);
|
||||
expect(screen.getByText("Unknown Tool")).toBeInTheDocument();
|
||||
expect(
|
||||
screen.getByText(/does not recognize this tool/),
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("renders Invalid Parameters for a -32602 that is NOT an unknown tool (#1632)", () => {
|
||||
// Same code, but the message is about bad arguments for a known tool — must
|
||||
// not be mislabelled "Unknown Tool".
|
||||
renderWithMantine(
|
||||
<ToolCallErrorPanel
|
||||
error="MCP error -32602: Invalid params: 'count' must be a number"
|
||||
errorCode={-32602}
|
||||
onClear={vi.fn()}
|
||||
/>,
|
||||
);
|
||||
expect(screen.getByText("Invalid Parameters")).toBeInTheDocument();
|
||||
expect(screen.getByText(/against the tool/)).toBeInTheDocument();
|
||||
expect(screen.queryByText(/does not recognize this tool/)).toBeNull();
|
||||
});
|
||||
|
||||
it("invokes onClear when the close button is clicked", async () => {
|
||||
const user = userEvent.setup();
|
||||
const onClear = vi.fn();
|
||||
renderWithMantine(<ToolCallErrorPanel error="boom" onClear={onClear} />);
|
||||
await user.click(screen.getByRole("button", { name: "Close error" }));
|
||||
expect(onClear).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it("classifyToolCallError narrows -32602 by message", () => {
|
||||
expect(classifyToolCallError(-32602, "Tool foo not found")).toBe(
|
||||
"unknown-tool",
|
||||
);
|
||||
expect(classifyToolCallError(-32602, "unknown tool: foo")).toBe(
|
||||
"unknown-tool",
|
||||
);
|
||||
// -32602 without an unknown-tool marker → invalid params, not unknown tool.
|
||||
expect(classifyToolCallError(-32602, "bad argument type")).toBe(
|
||||
"invalid-params",
|
||||
);
|
||||
expect(classifyToolCallError(-32602)).toBe("invalid-params");
|
||||
// A tool-less "does not exist" (arg-validation message) must NOT read as an
|
||||
// unknown tool — the match is tool-scoped.
|
||||
expect(
|
||||
classifyToolCallError(-32602, "property 'region' does not exist in enum"),
|
||||
).toBe("invalid-params");
|
||||
// Any other code (or none) is generic.
|
||||
expect(classifyToolCallError(-32601, "Tool not found")).toBe("generic");
|
||||
expect(classifyToolCallError(undefined)).toBe("generic");
|
||||
});
|
||||
});
|
||||
|
|
@ -0,0 +1,99 @@
|
|||
import {
|
||||
Alert,
|
||||
CloseButton,
|
||||
Code,
|
||||
Group,
|
||||
Stack,
|
||||
Text,
|
||||
Title,
|
||||
} from "@mantine/core";
|
||||
import { classifyToolCallError } from "./toolResultUtils";
|
||||
|
||||
export interface ToolCallErrorPanelProps {
|
||||
/** The thrown error's message (already stringified in App). */
|
||||
error: string;
|
||||
/**
|
||||
* The JSON-RPC error code, when the throw was a `ProtocolError`. Under SDK v2
|
||||
* an unknown-tool `tools/call` REJECTS with `-32602 Invalid params` instead of
|
||||
* resolving an `isError` result, so it arrives here as a thrown error rather
|
||||
* than a `CallToolResult` (which the ToolResultPanel would render). The same
|
||||
* `-32602` is also thrown for a known tool called with invalid arguments, so
|
||||
* the heading/hint are chosen from the message, not the code alone.
|
||||
*/
|
||||
errorCode?: number;
|
||||
/** Dismiss the error and return to the input form (mirrors ToolResultPanel). */
|
||||
onClear: () => void;
|
||||
}
|
||||
|
||||
// Mirrors ToolResultPanel's column so an error dismisses the same way a result
|
||||
// does: header with the close X pins, the alert fills and scrolls below it.
|
||||
const PanelStack = Stack.withProps({
|
||||
gap: "md",
|
||||
miw: 0,
|
||||
mih: 0,
|
||||
flex: 1,
|
||||
});
|
||||
|
||||
const HeaderRow = Group.withProps({
|
||||
gap: "xs",
|
||||
wrap: "nowrap",
|
||||
flex: "0 0 auto",
|
||||
});
|
||||
|
||||
const HintText = Text.withProps({
|
||||
size: "sm",
|
||||
c: "var(--inspector-text-secondary)",
|
||||
});
|
||||
|
||||
/**
|
||||
* Renders a thrown tool-call error (a protocol/SDK-level rejection) as a
|
||||
* distinct error panel. This is separate from ToolResultPanel, which renders a
|
||||
* `CallToolResult` (including a tool-level `isError` result). An `-32602`
|
||||
* rejection carries no result, so it would otherwise be invisible.
|
||||
*/
|
||||
const ERROR_TITLES: Record<string, string> = {
|
||||
"unknown-tool": "Unknown Tool",
|
||||
"invalid-params": "Invalid Parameters",
|
||||
generic: "Tool Error",
|
||||
};
|
||||
|
||||
export function ToolCallErrorPanel({
|
||||
error,
|
||||
errorCode,
|
||||
onClear,
|
||||
}: ToolCallErrorPanelProps) {
|
||||
const kind = classifyToolCallError(errorCode, error);
|
||||
return (
|
||||
<PanelStack>
|
||||
<HeaderRow>
|
||||
<CloseButton aria-label="Close error" onClick={onClear} />
|
||||
{/* h3 (not h4), size h4: request modals open over the Tools screen with
|
||||
an `h2` `Modal.Title`, so an `h4` here would skip a level (axe
|
||||
`heading-order`); `size="h4"` keeps the visual size. */}
|
||||
<Title order={3} size="h4">
|
||||
Tool Call Failed
|
||||
</Title>
|
||||
</HeaderRow>
|
||||
<Alert color="red" variant="light" title={ERROR_TITLES[kind]}>
|
||||
<Stack gap="xs">
|
||||
<Text size="sm">{error}</Text>
|
||||
{kind === "unknown-tool" && (
|
||||
<HintText>
|
||||
The server rejected this call with <Code>-32602</Code> (Invalid
|
||||
params) — it does not recognize this tool. It may have been
|
||||
excluded for an invalid <Code>x-mcp-header</Code> annotation or
|
||||
removed since the list was last fetched. Try refreshing the tools
|
||||
list.
|
||||
</HintText>
|
||||
)}
|
||||
{kind === "invalid-params" && (
|
||||
<HintText>
|
||||
The server rejected this call with <Code>-32602</Code> (Invalid
|
||||
params). Check the argument values against the tool's schema.
|
||||
</HintText>
|
||||
)}
|
||||
</Stack>
|
||||
</Alert>
|
||||
</PanelStack>
|
||||
);
|
||||
}
|
||||
|
|
@ -1,4 +1,45 @@
|
|||
import type { CallToolResult } from "@modelcontextprotocol/client";
|
||||
import { ProtocolErrorCode } from "@modelcontextprotocol/client";
|
||||
|
||||
/** How a thrown `tools/call` error should be presented in the error panel. */
|
||||
export type ToolCallErrorKind = "unknown-tool" | "invalid-params" | "generic";
|
||||
|
||||
/**
|
||||
* Whether a `-32602` message names the *tool itself* as unrecognized, as
|
||||
* opposed to reporting bad arguments for a known tool. Both reject with the same
|
||||
* `-32602 Invalid params` code under SDK v2, so the code alone can't tell them
|
||||
* apart — matching the message lets us pick the right heading instead of
|
||||
* labelling every `-32602` "Unknown Tool" (which would mislabel a known tool
|
||||
* called with invalid arguments).
|
||||
*
|
||||
* The match is deliberately tool-scoped so it doesn't INVERSELY mislabel: an
|
||||
* argument-validation message like `"property 'region' does not exist"` must
|
||||
* NOT read as "Unknown Tool". So the "not found / does not exist / unknown /
|
||||
* unrecognized" family only counts when the word "tool" is in the same clause
|
||||
* (the SDK's own message is `Tool <name> not found`); `unknown tool` / `no such
|
||||
* tool` are unambiguous on their own. Case-insensitive; best-effort — the fully
|
||||
* unambiguous signal would be a tool name in `error.data`, which the SDK does
|
||||
* not currently surface here.
|
||||
*/
|
||||
const UNKNOWN_TOOL_MESSAGE =
|
||||
/\b(unknown tool|no such tool)\b|\btool\b[^.!?]*\b(not found|not recognized|does not exist|is unknown|unrecognized)\b/i;
|
||||
|
||||
/**
|
||||
* Classify a thrown tool-call error for display (#1632). Under SDK v2 an
|
||||
* unknown-tool `tools/call` REJECTS with `-32602 Invalid params` instead of
|
||||
* resolving an `isError` result — but so does a *known* tool called with
|
||||
* invalid arguments (server-side schema validation). We narrow the ambiguous
|
||||
* `-32602` to `"unknown-tool"` only when the message says so; any other
|
||||
* `-32602` is `"invalid-params"`, and every other code is `"generic"`.
|
||||
*/
|
||||
export function classifyToolCallError(
|
||||
errorCode?: number,
|
||||
message?: string,
|
||||
): ToolCallErrorKind {
|
||||
if (errorCode !== ProtocolErrorCode.InvalidParams) return "generic";
|
||||
if (message && UNKNOWN_TOOL_MESSAGE.test(message)) return "unknown-tool";
|
||||
return "invalid-params";
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether a result renders a "Resource Links" box — i.e. a non-error result
|
||||
|
|
|
|||
|
|
@ -319,4 +319,54 @@ describe("ToolsScreen", () => {
|
|||
await user.click(screen.getByRole("button", { name: "Close results" }));
|
||||
expect(screen.getByText("Results")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("renders a thrown error (no result) as an error panel (#1632)", () => {
|
||||
renderWithMantine(
|
||||
<ToolsScreen
|
||||
{...baseProps}
|
||||
callState={{ status: "error", error: "boom", errorCode: -32603 }}
|
||||
/>,
|
||||
);
|
||||
expect(screen.getByText("Tool Call Failed")).toBeInTheDocument();
|
||||
expect(screen.getByText("boom")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("renders the unknown-tool hint for a -32602 rejection (#1632)", async () => {
|
||||
const user = userEvent.setup();
|
||||
const onClearResult = vi.fn();
|
||||
renderWithMantine(
|
||||
<ToolsScreen
|
||||
{...baseProps}
|
||||
onClearResult={onClearResult}
|
||||
callState={{
|
||||
status: "error",
|
||||
error: "MCP error -32602: Tool ghost_tool not found",
|
||||
errorCode: -32602,
|
||||
}}
|
||||
/>,
|
||||
);
|
||||
expect(screen.getByText("Unknown Tool")).toBeInTheDocument();
|
||||
await user.click(screen.getByRole("button", { name: "Close error" }));
|
||||
expect(onClearResult).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it("renders excluded tools in the sidebar with the reason (#1632)", () => {
|
||||
renderWithMantine(
|
||||
<ToolsScreen
|
||||
{...baseProps}
|
||||
excludedTools={[
|
||||
{
|
||||
tool: {
|
||||
name: "invalid_header_tool",
|
||||
inputSchema: { type: "object" },
|
||||
},
|
||||
reason:
|
||||
"value: x-mcp-header 'Bad Header' is not a valid RFC 9110 token",
|
||||
},
|
||||
]}
|
||||
/>,
|
||||
);
|
||||
expect(screen.getByText("Excluded (SEP-2243)")).toBeInTheDocument();
|
||||
expect(screen.getByText("invalid_header_tool")).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import type {
|
|||
ReadResourceResult,
|
||||
Tool,
|
||||
} from "@modelcontextprotocol/client";
|
||||
import type { ExcludedTool } from "@inspector/core/mcp/types.js";
|
||||
import { ToolControls } from "../../groups/ToolControls/ToolControls";
|
||||
import type { ListPaginationControlsProps } from "../../elements/ListPaginationControls/ListPaginationControls";
|
||||
import {
|
||||
|
|
@ -11,6 +12,7 @@ import {
|
|||
type ToolProgress,
|
||||
} from "../../groups/ToolDetailPanel/ToolDetailPanel";
|
||||
import { ToolResultPanel } from "../../groups/ToolResultPanel/ToolResultPanel";
|
||||
import { ToolCallErrorPanel } from "../../groups/ToolResultPanel/ToolCallErrorPanel";
|
||||
import { resultHasResourceLinks } from "../../groups/ToolResultPanel/toolResultUtils";
|
||||
import { collectSchemaDefaults, toFormSchema } from "../../../utils/jsonUtils";
|
||||
|
||||
|
|
@ -18,6 +20,13 @@ export interface ToolCallState {
|
|||
status: "idle" | "pending" | "ok" | "error";
|
||||
result?: CallToolResult;
|
||||
error?: string;
|
||||
/**
|
||||
* JSON-RPC error code when the call REJECTED (a thrown `ProtocolError`) rather
|
||||
* than resolving a result. SDK v2 rejects an unknown-tool call with `-32602`
|
||||
* instead of returning an `isError` result, so this drives the distinct
|
||||
* "Unknown Tool" rendering in the error panel (#1632).
|
||||
*/
|
||||
errorCode?: number;
|
||||
progress?: ToolProgress;
|
||||
}
|
||||
|
||||
|
|
@ -38,6 +47,9 @@ export interface ToolsUiState {
|
|||
|
||||
export interface ToolsScreenProps {
|
||||
tools: Tool[];
|
||||
/** Tools the SDK excluded from `tools/list` for invalid `x-mcp-header`
|
||||
* annotations (SEP-2243), shown in the sidebar with the reason (#1632). */
|
||||
excludedTools?: ExcludedTool[];
|
||||
callState?: ToolCallState;
|
||||
ui: ToolsUiState;
|
||||
listChanged: boolean;
|
||||
|
|
@ -132,6 +144,7 @@ const EmptyState = Text.withProps({
|
|||
|
||||
export function ToolsScreen({
|
||||
tools,
|
||||
excludedTools,
|
||||
callState,
|
||||
ui,
|
||||
listChanged,
|
||||
|
|
@ -157,6 +170,7 @@ export function ToolsScreen({
|
|||
<SidebarCard>
|
||||
<ToolControls
|
||||
tools={tools}
|
||||
excludedTools={excludedTools}
|
||||
selectedName={selectedToolName}
|
||||
searchText={search}
|
||||
listChanged={listChanged}
|
||||
|
|
@ -211,6 +225,19 @@ export function ToolsScreen({
|
|||
/>
|
||||
</ContentCard>
|
||||
</ContentPane>
|
||||
) : callState?.status === "error" && callState.error ? (
|
||||
// A thrown rejection (no result) — e.g. SDK v2's `-32602` unknown-tool
|
||||
// reject, which no longer arrives as an `isError` CallToolResult. The X
|
||||
// dismisses back to the form, like a result (#1632).
|
||||
<ContentPane mah={SCROLL_MAX_HEIGHT}>
|
||||
<ContentCard>
|
||||
<ToolCallErrorPanel
|
||||
error={callState.error}
|
||||
errorCode={callState.errorCode}
|
||||
onClear={() => onClearResult?.()}
|
||||
/>
|
||||
</ContentCard>
|
||||
</ContentPane>
|
||||
) : selectedTool ? (
|
||||
<ContentPane mah={SCROLL_MAX_HEIGHT}>
|
||||
<ContentCard>
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue