Skip to content

fix(mcp): stop Sentry noise for unknown MCP server names - #959

Merged
kody-bot merged 2 commits into
mainfrom
cursor/sentry-triage-kody-cloudflare-29-215a
Jul 26, 2026
Merged

kody-bot merged 2 commits into
mainfrom
cursor/sentry-triage-kody-cloudflare-29-215a

Conversation

@kentcdodds

@kentcdodds kentcdodds commented Jul 26, 2026 •

Copy link
Copy Markdown
Owner

Summary

Sentry KODY-CLOUDFLARE-29 fired when mcp_server_reconnect was called with a server name that is not saved (recipe-keeper; only ha existed). That is a routine caller mistake (stale name / typo), not a platform defect.

resolveMcpServerSetting threw a plain Error, so MCP observability reported it to Sentry. This PR throws McpCallerError instead (same pattern as missing packages/runs), so these stay on mcp-event logs and out of Sentry.

Changes

  • Blank and unknown server identifiers in resolveMcpServerSetting → McpCallerError
  • Unit tests for unknown name, blank id, and happy-path id/name resolution

Test plan

  • shared.node.test.ts (3 tests)
  • CI validate green
System recap — composes existing primitives (low risk)

Mode: recap · Base: main @ 405751b2 · Head: cursor/sentry-triage-kody-cloudflare-29-215a

Classification: composes — reuses existing McpCallerError so caller-resolvable MCP server lookup failures stay off Sentry; no new primitives or contracts.

Primitives touched

Primitive Group Impact
mcp-client-servers assistant composes — unknown/blank server lookup throws McpCallerError

System map

Unknown MCP server names from reconnect/refresh/remove/set-enabled now classify as caller errors instead of platform exceptions.

Legend: green = composes (wiring only) · amber = extended by this PR · red = new primitive · gray = context (unchanged, included only when an edge crosses it).

flowchart LR
	mcpClientServers["mcp-client-servers<br/>MCP client servers"]:::touched
	mcpObs["mcp-server<br/>MCP endpoint"]:::untouched
	mcpClientServers -->|"McpCallerError skips Sentry"| mcpObs
	classDef touched fill:#1a7f37,color:#fff
	classDef extended fill:#9a6700,color:#fff
	classDef added fill:#cf222e,color:#fff
	classDef untouched fill:#57606a,color:#fff
Loading

Before / after

Path Before After
Unknown / blank server in resolveMcpServerSetting Error → Sentry issue McpCallerError → mcp-event only
Open in Web Open in Cursor 

Summary by CodeRabbit

  • Bug Fixes
    • Improved validation for missing or blank MCP server selections, now returning caller-specific errors.
    • Added clearer caller-facing errors when an MCP server cannot be found (including known saved server guidance).
    • Server names are resolved consistently regardless of capitalization.
  • Tests
    • Added Vitest coverage for resolving MCP server settings by ID and case-insensitive name, including invalid and unmatched inputs.

resolveMcpServerSetting threw plain Error for missing/blank server
identifiers, so routine agent typos (e.g. reconnecting a removed
server) opened Sentry issues. Throw McpCallerError so observability
keeps them on mcp-event logs only.
@coderabbitai

coderabbitai Bot commented Jul 26, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

resolveMcpServerSetting now classifies blank and unknown server inputs as McpCallerError. New tests cover error messages, skipped lookups, direct ID resolution, and case-insensitive name fallback.

Changes

MCP caller error handling

Layer / File(s) Summary
Classify invalid server inputs
packages/worker/src/mcp/capabilities/mcp-servers/shared.ts
resolveMcpServerSetting throws McpCallerError for blank input and unresolved server IDs or names.
Test server resolution and errors
packages/worker/src/mcp/capabilities/mcp-servers/shared.node.test.ts
Mocked settings services verify validation behavior, missing-server messages, direct ID lookup, and case-insensitive name fallback.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: unknown MCP server names no longer generate Sentry noise.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch cursor/sentry-triage-kody-cloudflare-29-215a

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@kody-bot
kody-bot marked this pull request as ready for review July 26, 2026 10:53
@github-actions

github-actions Bot commented Jul 26, 2026 •

Copy link
Copy Markdown
Contributor

🔎 Preview deployed: https://kody-pr-959.kody-a99.workers.dev

Worker: kody-pr-959
D1: kody-pr-959-db
KV: kody-pr-959-oauth-kv

Mocks:

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
packages/worker/src/mcp/capabilities/mcp-servers/shared.node.test.ts (1)

65-65: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Also assert that the list lookup is skipped for blank input.

The test guards getMcpServerSettingById, but the blank-input path should avoid both service calls.

Suggested assertion
  expect(mockModule.getMcpServerSettingById).not.toHaveBeenCalled()
+ expect(mockModule.listMcpServerSettings).not.toHaveBeenCalled()
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/worker/src/mcp/capabilities/mcp-servers/shared.node.test.ts` at line
65, Update the blank-input test alongside the existing getMcpServerSettingById
assertion to also verify that the list lookup service is not called. Keep the
test focused on confirming both service calls are skipped when the input is
blank.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@packages/worker/src/mcp/capabilities/mcp-servers/shared.node.test.ts`:
- Line 65: Update the blank-input test alongside the existing
getMcpServerSettingById assertion to also verify that the list lookup service is
not called. Keep the test focused on confirming both service calls are skipped
when the input is blank.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: dfd1ae9f-17d6-4d66-becd-74d6ee68c578

📥 Commits

Reviewing files that changed from the base of the PR and between 405751b and e7f2958.

📒 Files selected for processing (2)
  • packages/worker/src/mcp/capabilities/mcp-servers/shared.node.test.ts
  • packages/worker/src/mcp/capabilities/mcp-servers/shared.ts

Address CodeRabbit feedback on the blank-identifier path.
@kody-bot
kody-bot merged commit 8179950 into main Jul 26, 2026
10 checks passed
@kody-bot
kody-bot deleted the cursor/sentry-triage-kody-cloudflare-29-215a branch July 26, 2026 11:04
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