Skip to content

feat(mcp): Expose every tool directly and rely on harness tool search - #1868

Merged
dcramer merged 4 commits into
mainfrom
feat/mcp-expose-all-tools
Nov 3, 2026
Merged

dcramer merged 4 commits into
mainfrom
feat/mcp-expose-all-tools

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

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). Our search_sentry_tools/execute_sentry_tool gateway 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/list and lets the harness handle discovery. Skill, constraint, and capability gating still apply.

Fixes #1844. Tools like create_project are 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_TOOLS in tools/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

  • Prompts, hints, plugin agents, evals, and docs now call tools directly instead of going through execute_sentry_tool.
  • Plugin agent allowedTools now includes every tool, so tools from optional skills are still callable without the gateway.
  • Generated skill descriptions only count each skill's own tools, which stops inspect guidance from leaking into other skills.
  • The metric monitor schemas no longer use nested unions, which some model APIs reject now that those tools are listed directly.
  • Gateway tests pin the old surface, and new tests cover the direct surface.

Follow-ups

Harness search is only as good as our tool metadata:

  • Audit tool descriptions for search quality.
  • Mark core tools with _meta["anthropic/alwaysLoad"].
  • Hide the deprecated AI conversation aliases, which now show up as near-duplicates.
  • Decide whether to remove the gateway once the rollout is verified.

via @dcramer.

--

View Session [Sentry]

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]>
@vercel

vercel Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
sentry-local Ready Ready Preview Nov 3, 2026 6:38pm UTC

Request Review

@github-actions github-actions Bot added the risk: medium PR risk score: medium label Nov 3, 2026
…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]>

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ 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.

Comment thread plugins/sentry-mcp/agents/sentry-mcp.md Resolved
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 sentry-junior Bot changed the title feat(mcp): Expose every tool directly behind EXPOSE_ALL_TOOLS feat(mcp): Expose every tool directly behind temporary EXPOSE_ALL_TOOLS flag Nov 3, 2026
@sentry-junior sentry-junior Bot changed the title feat(mcp): Expose every tool directly behind temporary EXPOSE_ALL_TOOLS flag feat(mcp): Expose every tool directly and rely on harness tool search Nov 3, 2026
@dcramer
dcramer merged commit c5c04ef into main Nov 3, 2026
42 checks passed
@dcramer
dcramer deleted the feat/mcp-expose-all-tools branch November 3, 2026 20:03
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]>

This branch was successfully deployed

1 active and 1 inactive deployments
Preview — 84ae9b9b Deployed Nov 3, 2026 by vercel[bot]
Actions — 84ae9b9b Deployed Nov 3, 2026 by sentry-junior[bot] via eval #1527
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: medium PR risk score: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

create_project is hidden from the default tool list, so agents miss it during setup

1 participant