Repository navigation
feat(mcp): Expose every tool directly and rely on harness tool search - #1868
Merged
Merged
Conversation
Tier 1 harnesses now defer MCP tool schemas behind their own tool search, so the search_sentry_tools/execute_sentry_tool gateway is redundant there. EXPOSE_ALL_TOOLS (on by default, a code constant, not a runtime option) registers every available tool in tools/list and drops the two gateway tools. Skill, constraint, capability, and experimental filters still apply. Setting it to false restores the gateway surface. Directly exposed schemas must pass the union check, so the metric monitor literal unions become z.literal([...]) enums. Hard-coded execute_sentry_tool references in descriptions and prompts now name the tool directly, and generated skill descriptions only treat a skill's own direct tools as available. server.test.ts pins the gateway surface with vi.mock so it stays covered; server.all-tools.test.ts covers the default surface. Co-Authored-By: David Cramer <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…ools # Conflicts: # ast-grep-rules/no-expand-top-level-tools.yml # packages/mcp-core/src/tools/surfaces.ts Co-Authored-By: David Cramer <[email protected]>
Contributor
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit b51ad8c. Configure here.
Co-Authored-By: David Cramer <[email protected]>
With EXPOSE_ALL_TOOLS, optional-skill tools are no longer reachable through execute_sentry_tool, so the plugin agents' allowedTools must list them directly or granted triage and project-management tools cannot be called.
sentry-junior Bot
added a commit
that referenced
this pull request
Nov 3, 2026
main now exposes every tool directly (#1868), so create_monitor's surface is direct and it joins the plugin agents' allowedTools. Co-Authored-By: David Cramer <[email protected]>
dcramer
added a commit
that referenced
this pull request
Nov 3, 2026
… tools (#1906) Follow-up to #1868. Now that every tool is listed directly, the harness picks tools with its own search over tool names and descriptions. Codex uses local BM25 and returns 8 matches. VS Code returns its top 5 by embeddings. Claude Code and Cursor show the model only tool names until it searches. So the metadata has to match the words people actually use, and must not return two tools for the same job. ## Deprecated tools are no longer listed `get_ai_conversation_details`, `search_ai_conversations` and `search_events` are deprecated, but they were in `tools/list` next to the tools that replaced them. Each one now has a `deprecated: { replacedBy: [...] }` field on its tool config that names its replacements, and deprecated tools aren't listed in `tools/list`. `toolDefinitions.json` carries the same field. They were only ever reachable through `execute_sentry_tool(name: ...)`, and that tool isn't registered with the flag on. So hiding them doesn't break any working call. With the flag off they stay reachable through the gateway, just as before. ## Description audit I checked about 56 realistic queries against a BM25 index of the tool names and descriptions, for example "sentry client key", "list projects", "notify slack when new issue" and "cron job failed check in". Before this change, 7 of them didn't put the right tool in the top 3. After it, 2 still miss the top 3, and both are in the top 8 that Codex returns. This was a scratch approximation of Codex's search, not the real harness, so the results are directional. Only first lines and pointers to sibling tools changed: - **`find_projects`, `find_teams`, `find_organizations`, `find_releases`:** they now start with "List or search…", because "list X" is the most common way to ask and none of them contained the word. - **`find_dsns`:** mentions client keys, `SENTRY_DSN` and SDK setup. - **Monitors:** `find_monitors` and `get_monitor_details` say "cron / scheduled jobs / check-ins". `find_monitors` now points to `find_uptime_monitors` and `find_metric_monitors`, since all three names look alike. - **`create_metric_monitor`:** now says what a monitor does in plain words: it detects when an error count or latency crosses a threshold. - **`create_alert_rule`:** names its notification channels: Slack, email and PagerDuty. - **`get_profile` / `get_profile_details`:** `get_profile` is for aggregated flamegraph data across a transaction, and `get_profile_details` is for one profile by ID or URL. Each now points to the other. - **`get_event_stacktrace`:** says "stack trace" as well as "stacktrace". - **`get_sentry_resource`:** says to use it when a user shares a Sentry link. `docs/contributing/adding-tools.md` now covers writing descriptions for harness search, plus the `deprecated` field. ## Not in this PR - `_meta["anthropic/alwaysLoad"]` on core tools. - Hands-on checks in Claude Code, Codex and Cursor that their search finds these tools. Checks: `tsc`, `lint`, and the logger, toolkit-core, local, docs-mcp, mcp-core, mcp-test-client and mcp-cloudflare test suites pass. The `packages/cli` suite didn't finish because the sandbox timed out. This PR doesn't touch CLI code. <!-- junior-session-footer:start --> <!-- junior-conversation-id:slack%3AC08J1NSPU6S%3A1793727467.701089 --> -- [View Session](https://junior-prod.sentry.dev/conversations/slack%3AC08J1NSPU6S%3A1793727467.701089) [[Sentry]](https://sentry.sentry.io/explore/conversations/slack%3AC08J1NSPU6S%3A1793727467.701089/?project=4510944073809921) <!-- junior-session-footer:end --> --------- Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: David Cramer <[email protected]> Co-authored-by: David Cramer <[email protected]>
dcramer
added a commit
that referenced
this pull request
Nov 4, 2026
## Summary Since #1868 turned on `EXPOSE_ALL_TOOLS`, `search_sentry_tools` and `execute_sentry_tool` are no longer registered, but clients still call them (~200/hour each on the hosted server). The MCP SDK rejects these calls with JSON-RPC `-32602 Tool … not found`. Sentry's MCP instrumentation treats `-32602` as a client error and leaves the `tools/call` span status unset, so these failures were recorded as `ok` 0ms spans and didn't show up in tool failure rates. They also lacked `app.transport`, because we set it only inside tool handlers, and those never run for unknown names. This wraps the SDK's `tools/call` handler. When a call names a tool this server did not register, the wrapper marks the active span as failed (`error.type: unknown_tool`, status `not_found`) and adds the usual request attributes (`app.transport`, `app.client.family`, constraints, skills). The removed gateway tools get a clear message: > Tool execute_sentry_tool was removed from the Sentry MCP server. Call Sentry tools directly by name. If they are missing from your tool list, reconnect the Sentry MCP server to refresh it. Other unknown names keep the SDK's error. The response stays a `-32602` JSON-RPC error, which the MCP spec prescribes for unknown tools. No Sentry issue is created: this is a client mistake, and neither our code nor the SDK captures `-32602`. The SDK has no hook for unknown tool names, so the wrapper uses the Protocol's private `_requestHandlers` map. If an SDK upgrade changes that map, the wrapper does nothing (it checks `instanceof Map` and that a handler exists) and the new span test fails. ### Evidence `sentry/mcp-server` spans, 2026-11-03T20:15Z–2026-11-04T17:15Z: | `mcp.tool.name` | `span.status` | `rpc.response.status_code` | `app.transport` | count | | --- | --- | --- | --- | --- | | execute_sentry_tool | ok | -32602 | – | 4,853 | | search_sentry_tools | ok | -32602 | – | 4,047 | All of them have `network.transport: tcp` and an HTTP `mcp.transport` (`WebStandardStreamableHTTPServerTransport` or `PerRequestHTTPServerTransport`), and their parent `http.server POST /mcp/…` spans carry `app.transport: http`. They come from hosted HTTP clients across many client families, not from stdio. The missing `app.transport` only means our handler never ran. The `cli` project has no `mcp.*` spans in the last 30 days. The same gap also hid other unknown names, mostly the deprecated `search_events` (~1.2k calls in the same window). Local repro with `@sentry/node` 11.6.0 and the real `wrapMcpServerWithSentry`: - Before: the `tools/call execute_sentry_tool` span is `ok` with `rpc.response.status_code: -32602`. - After: it is `error` with `error.type: unknown_tool` and `app.transport: http`, and no error events are sent. `telem/unknown-tool.test.ts` covers the same path. It uses a real `ServerRuntimeClient` and the real MCP instrumentation under an AsyncLocalStorage context strategy, and asserts the finished span's status and `error.type`. It fails without the `server.ts` change. ### Deploy note This adds roughly 400–500 failed `tools/call` spans per hour, which were previously recorded as `ok`. Most of them (~420/hour) are the removed gateway names, and the rest are other unknown names such as `search_events`. Tool failure-rate alerts and dashboards for mcp-server may jump after deploy. These are failures that were already happening and are now visible, not a regression. ### SDK follow-up The root behavior is in getsentry/sentry-javascript. `completeSpanWithResults` (`packages/core/src/integrations/mcp-server/correlation.ts`) sets an error status only when `isJsonRpcServerError` (`errorCapture.ts`) is true, and that check excludes `-32602`. Not capturing an exception for client errors makes sense, but the span should probably still get an error status, and `error.type` should be the JSON-RPC code, so `tools/call` failure rates include protocol-level client errors. ### Out of scope - Spans for tool calls that fail SDK input validation (an SDK `isError` result) also lack `app.transport`, for the same reason: our handler never runs. - Whether deprecated names like `search_events` should get a replacement hint is a separate product decision. ### Review Independent review: ready, no must-fix. - The reviewer confirmed the root cause and verified it end to end with a real `ServerRuntimeClient`, the real `wrapMcpServerWithSentry` and an async context. Main records the call as `ok` without `app.transport`. This branch records it as `error` with `error.type=unknown_tool` and `app.transport=http`, and sends 0 error events. Registered tools are unaffected. - All transports dispatch through `_requestHandlers`. - Applied optional items 1–4: - The span test now uses real instrumentation instead of a mocked `getActiveSpan`. - The wrapper checks `instanceof Map` and that a handler exists before wrapping. - The not-found test runs regardless of `EXPOSE_ALL_TOOLS`. - The span attributes are computed once. `pnpm run tsc`, `pnpm run lint`, and the `mcp-core` (2,044 tests) and `mcp-cloudflare` (447 tests) suites pass locally. In the sandbox, some `packages/cli` filesystem-permission tests fail on clean `main` too. <!-- junior-request-attribution:start --> via @dcramer. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:agent%3A1705a58f04a5e5f269a14f334e6e1eed --> -- [View Session](https://junior-prod.sentry.dev/conversations/agent%3A1705a58f04a5e5f269a14f334e6e1eed) [[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3A1705a58f04a5e5f269a14f334e6e1eed/?project=4510944073809921) <!-- junior-session-footer:end --> --------- Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: David Cramer <[email protected]>
7 tasks done
This was referenced Nov 11, 2026
This branch was successfully deployed
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.

We're moving the MCP server away from its own tool search. All tier 1 harnesses (Codex, Claude Code, Cursor) now defer MCP tool schemas behind their own native tool search (#1862,
docs/mcp/harnesses.md). Oursearch_sentry_tools/execute_sentry_toolgateway now does the same job a second time and hides tools from the harness.This PR lists every tool the session is granted directly in
tools/listand lets the harness handle discovery. Skill, constraint, and capability gating still apply.Fixes #1844. Tools like
create_projectare no longer hidden behind the gateway, so harness search can find them.Rollout
This change is temporary while we roll it out and confirm that harness tool search behaves the way we expect. The old gateway stays behind a code-level switch (
EXPOSE_ALL_TOOLSintools/exposure.ts), so we can revert quickly. It's not meant to be a long-term option. We may remove the search/execute concepts entirely later instead of keeping both surfaces.What changed to support it
execute_sentry_tool.allowedToolsnow includes every tool, so tools from optional skills are still callable without the gateway.Follow-ups
Harness search is only as good as our tool metadata:
_meta["anthropic/alwaysLoad"].via @dcramer.
--
View Session [Sentry]