Skip to content

chore(mcp): Add @sentry/mcp package scaffold - #26995

Merged
logaretm merged 3 commits into
developfrom
awad/mcp-package-scaffold
Dec 1, 2026
Merged

logaretm merged 3 commits into
developfrom
awad/mcp-package-scaffold

Conversation

@logaretm

@logaretm logaretm commented Nov 30, 2026 •

Copy link
Copy Markdown
Member

Initial thinking is we create a name-space for MCP related stuff rather than add confusing API names to all of our server SDKs, so a @sentry/mcp package acts as a home for the feedback tool and any other tools we may want to publish in the future.

Secondly, it is a JS framework-and-runtime-agnostic tool so it shouldn't belong to any runtime specific SDK and it should also pair with any SDK the user might be using.

Third reason is we may need to have several sub-export adaptors for each MCP framework to make their wiring easier if we have to.

Also allows us to pull in dependencies when we need to, like zod here.

@logaretm
logaretm added this pull request to stack #26997 November 30, 2026 16:35
@github-actions

github-actions Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

size-limit report 📦

Compared: beb309c (PR test merge using develop at 399a4d5)

Against: 399a4d5 (develop) · base run #68449

✅ Baseline matches: this diff contains only this PR's changes.

Path Size % Change Change
@sentry/browser 30.58 kB - -
@sentry/browser - with treeshaking flags 28.76 kB - -
@sentry/browser - with treeshaking flags tracing without tracing 28.63 kB - -
@sentry/browser (incl. Tracing) 53.72 kB - -
@sentry/browser (incl. Tracing Core) 40.65 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 53.72 kB - -
@sentry/browser (incl. Tracing, Profiling) 56.6 kB - -
@sentry/browser (incl. Tracing, Replay) 93.64 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 82.43 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 98.49 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 111.45 kB - -
@sentry/browser (incl. Feedback) 48.43 kB - -
@sentry/browser (incl. sendFeedback) 31.15 kB - -
@sentry/browser (incl. FeedbackAsync) 36.2 kB - -
@sentry/browser (incl. Metrics) 31.9 kB - -
@sentry/browser (incl. Logs) 32.18 kB - -
@sentry/browser (incl. Metrics & Logs) 32.84 kB - -
@sentry/react 32.6 kB - -
@sentry/react (incl. Tracing) 56.45 kB - -
@sentry/vue 38.78 kB - -
@sentry/vue (incl. Tracing) 56.74 kB - -
@sentry/svelte 30.61 kB - -
@sentry/effect (client) 42.27 kB - -
@sentry/effect (client, incl. Tracing) 55.01 kB - -
@sentry/effect (client, incl. Tracing, Logs, Metrics) 66.34 kB - -
@sentry/remix (Remix 3 client bundle) 59.46 kB - -
CDN Bundle 32.4 kB - -
CDN Bundle (incl. Tracing) 54.09 kB - -
CDN Bundle (incl. Logs, Metrics) 35.16 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 56.55 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 76.12 kB - -
CDN Bundle (incl. Tracing, Replay) 91.88 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 94.41 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 97.35 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 99.82 kB - -
CDN Bundle - uncompressed 94.64 kB - -
CDN Bundle (incl. Tracing) - uncompressed 159.96 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 102.98 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 167.59 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 233.37 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 280.39 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 288.02 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 292.33 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 299.95 kB - -
@sentry/nextjs (client) 60.27 kB - -
@sentry/sveltekit (client) 55.07 kB - -
@sentry/astro (client) - rolldown, without tracing 39.51 kB -0.01% -1 B 🔽
@sentry/core/server 45.91 kB - -
@sentry/core/browser 14.49 kB - -
@sentry/node 157.98 kB -0.01% -2 B 🔽
@sentry/node/import (ESM hook with diagnostics-channel injection) 83.6 kB - -
@sentry/node - without tracing 89.99 kB -0.01% -1 B 🔽
@sentry/node - without channel injection 146.94 kB -0.01% -2 B 🔽
@sentry/aws-serverless 100.64 kB -0.01% -3 B 🔽
@sentry/cloudflare (withSentry) - minified 212.5 kB - -
@sentry/cloudflare (withSentry) 492.68 kB - -
@sentry/cloudflare (withSentry, instrumented CommonJS package) - minified 215.45 kB - -
@sentry/nextjs/cloudflare (withSentry) - minified 237.93 kB - -

View base workflow run

@github-actions

github-actions Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Optional E2E tests

Some optional checks were not successful. They do not block the merge. 3 not successful, 62 successful. See the run.

Check Status
❌ CI: Optional E2E Tests / E2E gen-ai-libraries (latest) Test (optional) Failing after 4m Details
❌ CI: Optional E2E Tests / E2E nuxt-5 (bun) Test (optional) Failing after 2m Details
❌ CI: Optional E2E Tests / E2E node-express-send-to-sentry (static trace lifecycle) Test (optional) Failing after 4m Details
Successful checks
Check Status
✅ CI: Optional E2E Tests / E2E cloudflare-workers-without-tracing-send-to-sentry Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E cloudflare-agent Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nuxt-5 (deno) Test (optional) Successful in 3m Details
✅ CI: Optional E2E Tests / E2E astro-7 (static trace lifecycle) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E hapi-21 (deno) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E cloudflare-flue-send-to-sentry Test (optional) Successful in 4m Details
✅ CI: Optional E2E Tests / E2E nextjs-16 (vinext, bun) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E nuxt-5-sourcemaps (static / nuxt generate) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E tanstackstart-react-sourcemaps (delete all) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nuxt-5-sourcemaps (no upload) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E solidstart-2 (manual upload) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E deno (latest) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E cloudflare-workers-send-to-sentry Test (optional) Successful in 4m Details
✅ CI: Optional E2E Tests / E2E nextjs-15 (latest) Test (optional) Successful in 3m Details
✅ CI: Optional E2E Tests / E2E nuxt-5-sourcemaps (client source maps kept) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nuxt-5-sourcemaps Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nuxt-5-tunnel (cloudflare) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nextjs-14-supabase Test (optional) Successful in 3m Details
✅ CI: Optional E2E Tests / E2E nextjs-16-tunnel (cloudflare) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E hono-5 (deno) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-openai-decisions (latest) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nextjs-15 (turbo) Test (optional) Successful in 3m Details
✅ CI: Optional E2E Tests / E2E nextjs-16 (vinext) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E solidstart-2 (delete all) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E cloudflare-think (ai v6) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E astro-7 Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E tanstackstart-react-sourcemaps (manual upload) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nuxt-5-tunnel Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E nuxt-5-sourcemaps (client source maps enabled by Sentry) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E debug-id-sourcemaps Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E hono-5 Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E cloudflare-pi-durable (latest) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-eve (0.x) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E hono-5 (bun) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-express-mcp-v1 Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E hono-5 (cloudflare) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E node-eve (orchestrion) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E nuxt-5 (cloudflare) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E hapi-21 (bun) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E tanstackstart-react-sourcemaps (no upload) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nuxt-5 (development) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-eve (content off) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E node-fastify-6 Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-express-mcp-v2 Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-mastra (latest) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E tanstackstart-react-cloudflare Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nuxt-5 Test (optional) Successful in 3m Details
✅ CI: Optional E2E Tests / E2E tanstackstart-react-sourcemaps Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nuxt-4-sourcemaps (Vite server) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E solidstart-2 (no upload) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E node-express-mcp-v2 (MCP SDK OpenTelemetry) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E react-router-7-framework-instrumentation Test (optional) Successful in 3m Details
✅ CI: Optional E2E Tests / E2E nuxt-5 (kv-cache) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E node-flue (latest) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E vinext-cf-workers (workers cache) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-pi-durable (latest) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E react-send-to-sentry Test (optional) Successful in 4m Details
✅ CI: Optional E2E Tests / E2E node-express-send-to-sentry Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E tanstackstart-react (latest) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E solidstart-2 Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E solidstart-2-tunnel Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E vue-3 (no Options API) Test (optional) Successful in 1m Details

@logaretm
logaretm marked this pull request as ready for review November 30, 2026 19:36
@logaretm
logaretm requested a review from isaacs November 30, 2026 19:43
Comment thread packages/mcp/LICENSE Resolved
Comment thread package.json Resolved
Comment thread pnpm-workspace.yaml Resolved
@logaretm
logaretm force-pushed the awad/mcp-package-scaffold branch from 830e1e7 to cd17cbd Compare December 1, 2026 14:27
…mplate

Publish @sentry/mcp to npm and the release registry, list it in the root README,
and add it to the bug report package dropdown.
@logaretm
logaretm force-pushed the awad/mcp-package-scaffold branch from cd17cbd to b5185af Compare December 1, 2026 19:01
@logaretm
logaretm merged commit e1e8bb9 into develop Dec 1, 2026
527 of 530 checks passed
@logaretm
logaretm deleted the awad/mcp-package-scaffold branch December 1, 2026 19:08
logaretm added a commit that referenced this pull request Dec 1, 2026
For context on why this is its own package, refer to
#26995

MCP server authors have no easy way to hear from agents that get stuck
on their tools, this PR adds `addFeedbackTool` and `createFeedbackTool`
to cater for both simple setups and more dynamic ones like ours in
sentry mcp server.

Two ways to set it up for now:

```ts
import * as Sentry from '@sentry/node';
import { McpServer } from '@modelcontextprotocol/server';
import { addFeedbackTool } from '@sentry/mcp';

Sentry.init({ dsn: process.env.SENTRY_DSN, tracesSampleRate: 1 });

// Whatever MCP setup they have, as long as we have the `server`
const server = Sentry.wrapMcpServerWithSentry(new McpServer({ name: 'orders', version: '1.0.0' }));

// user adds tools and other stuff...
// ...

// Adds the feedback tool, wraps other tools with a "honey pot" hint on error.
addFeedbackTool(server, { serverName: 'Orders' });
```

Or, for servers that register tools through their own catalog, create
the tool and register it like any other:

```ts
import { createFeedbackTool } from '@sentry/mcp';

// Same options as addFeedbackTool. `server` is optional: it names the agent on each report and adds the error hints
const tool = createFeedbackTool({ serverName: 'Orders', server });

server.registerTool(tool.name, tool.config, tool.handler);
```

The tool returns the feedback ID as `structuredContent` with a matching
`outputSchema`, next to the text.

### Error Hints

Failing tools get this sentence appended to their error:

```
If this keeps failing after you adjust your request, report it to the Orders team with `submit_feedback`.
└─────────────────── condition ───────────────────┘               └─ recipient ─┘      └── toolName ───┘
```

With `serverName: 'Orders'` the recipient becomes "the Orders team", and
the tool name follows `name`. Successful results are never modified,
error results get the hint as an extra text block so `structuredContent`
is never touched, and errors that already mention the feedback tool
don't get a second hint.

Only these errors receive the hint:

| Failure | Hint? |
| --- | --- |
| `{ status: 429 }`, `{ statusCode: 404 }`, `{ response: { status: 403 }
}` | No |
| `McpError` with code `-32602` | No |
| `{ status: 502 }`, a plain `Error`, `ECONNREFUSED` (string `code`), an
`isError` result | Yes |

The user can also customize which errors get hinted with `errorHints`
option:

```ts
addFeedbackTool(server);                        // default: shouldHintFeedback
addFeedbackTool(server, { errorHints: false }); // no hints
addFeedbackTool(server, {
  // (toolName, failure) => boolean; failure is the thrown Error or the isError result
  errorHints: (toolName, failure) => shouldHintFeedback(failure) && toolName !== 'search_orders',
});
```

### Hints on other results

For results that aren't errors but still suggest a problem, like an
empty search, authors add the hint themselves. Both helpers use the name
and `serverName` of the tool `addFeedbackTool` or `createFeedbackTool`
made, and add nothing until that tool exists and Sentry has a client:

```ts
import { feedbackHint, withFeedbackHint } from '@sentry/mcp';

// adds the hint as its own text block, leaves structuredContent and the existing content alone
return orders.length ? result : withFeedbackHint(result, 'If this stays empty after you broaden the query');

// or just the sentence, for your own messages
throw new Error(`Index is rebuilding. ${feedbackHint('If this keeps failing after the rebuild')}`);
```

### Custom handler

If the user wants their own handler, for example to name the agent from
their own per-call context, `captureAgentFeedback` does the filler
check, scrubbing and sending:

```ts
import { captureAgentFeedback, createFeedbackTool } from '@sentry/mcp';

const tool = createFeedbackTool({ serverName: 'Orders' });

server.registerTool(tool.name, tool.config, input => {
  const result = captureAgentFeedback(input, {
    clientName: 'cursor',             // shown as "MCP agent (cursor)"
    userId: 'user-42',                // dropped from the name when dataCollection.userInfo is false
    scrub: msg => msg.replace(/s3:\/\/\S+/g, '[REDACTED]'), // runs after built-in token/email scrubbing
  });
  if (!result.ok) {
    return { isError: true, content: [{ type: 'text', text: result.error }] }; // filler like "N/A"
  }

  return { content: [{ type: 'text', text: 'Feedback sent.' }], structuredContent: { feedbackId: result.feedbackId } };
});
```

---

The e2e tests call the tool over MCP SDK v1 with zod 3.25 and over v2,
and check the feedback envelope it sends and the structured result.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants