MCP instrumentation retries synchronously failing handlers
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 68/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- typescript
- Domain
- observability
Research direction
Start at the wrapMcpServerWithSentry entry point and reproduce the synchronous handler example with the official MCP SDK. Trace the inner and outer wrappers to confirm why the same error causes a second callback invocation. Done means a throwing synchronous handler runs once and its error reaches the MCP client, with coverage for tools, resources, or prompts as appropriate.
Written by the indexing model from the issue text.
Description
Wrapping an MCP server with wrapMcpServerWithSentry can execute a synchronous handler twice when its first invocation throws. This repeats application side effects. If the second invocation succeeds, the MCP client receives that success instead of the original failure.
Reproduced on develop at ceb8517523 with the official TypeScript SDK 1.30.0 and 2.0.0 clients and servers, including in a deployed Cloudflare Worker. Tools, resources, and prompts registered after wrapping are affected; resource callbacks registered before wrapping are also affected. Unwrapped callbacks and asynchronous rejections execute once.
For example, register this tool after wrapping, then call it once through an MCP client:
let calls = 0;
const server = wrapMcpServerWithSentry(new McpServer({ name: 'example', version: '1.0.0' }));
server.registerTool('example', {}, () => {
calls += 1;
if (calls === 1) {
throw new Error('operation failed');
}
return { content: [{ type: 'text', text: 'unexpected retry' }] };
});
Expected: calls === 1 and the tool error reaches the client. Actual: calls === 2 and the client receives unexpected retry as a successful result.
The inner handler wrapper captures and rethrows the application error. The outer fallback catches that same error and invokes the original callback again, treating it as an instrumentation failure.
- Dominant language
- TypeScript
- Stars
- 8.7k
- Forks
- 1.9k
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 576
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from getsentry/sentry-javascript
-
Browser Bug Next.js Traces Waiting for: Product Owner
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
getsentry/sentry-javascript#24672 · 1 comment ·
-
Flaky Test React Router Framework Spans Tests
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
getsentry/sentry-javascript#24348 · 1 comment ·
-
javascript
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
getsentry/sentry-javascript#24200 · 2 comments ·
-
javascript Task
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
getsentry/sentry-javascript#24134 · 1 comment ·
-
Cloudflare Workers javascript Tests
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
getsentry/sentry-javascript#24051 · 1 comment ·
All issues in getsentry/sentry-javascript
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
vercel-labs/just-bash#464 ·
-
looksLikeSlug() is ASCII-only, so non-Latin entity slugs (e.g. Korean) skip exact match and collapse Open
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
TanStack/tanstack.com#1293 ·