·

Sentry MCP With Claude Code Cli And Vs Code

Sentry MCP With Claude Code Cli And Vs Code

Claude Code is Anthropic's official CLI and VS Code extension for AI-assisted development. It supports MCP servers natively — both in the terminal and inside the VS Code sidebar — making it one of the most capable environments for Sentry-driven debugging workflows. This topic walks through the full setup and practical usage of Sentry MCP with Claude Code, from config file to deployed fix.


Installing and Connecting Sentry MCP to Claude Code

Sentry provides an official MCP server at https://mcp.sentry.dev/mcp. Claude Code connects to it over HTTP — no local server process, no npx command, no manual settings.json editing.

Prerequisites
- Claude Code CLI installed (npm install -g @anthropic-ai/claude-code or via the Anthropic installer)
- A Sentry account (see Module 3, Topic 1 for authentication details)

Step 1: Connect to the Sentry MCP server

claude mcp add --scope user --transport http sentry https://mcp.sentry.dev/mcp

The --scope user flag makes this available across all your Claude Code projects.

Step 2: Trigger authentication

Start a Claude Code session:

claude

Authenticate by running a Sentry tool inside the session:

List the top 5 unresolved Sentry issues in my organization

Claude Code will pause, display an authorization URL, and open your browser for Sentry OAuth. Complete the login — Claude Code stores the resulting auth token and reuses it in all future sessions.

Step 3: Verify the connection

claude mcp list

You should see sentry listed as an active MCP server. You can also verify inside a session:

List available MCP tools

You should see sentry_list_issues, sentry_get_event, and other Sentry tools listed.

VS Code integration

The Claude Code VS Code extension shares the same MCP configuration as the CLI. No additional VS Code configuration is needed — the Sentry MCP server is automatically available in extension-initiated sessions.

Tips
- Use --scope user for personal Sentry access, or --scope project to scope the connection to a specific project.
- If you work with multiple Sentry organizations, you can specify the org when querying — the MCP server will prompt for disambiguation or you can include the org slug in your prompts.
- Run claude mcp list to verify which MCP servers are active before starting an error investigation session.
- If the connection fails, run claude mcp remove sentry and repeat Steps 1–2 to reconnect.


Querying Sentry Issues and Reading Stack Traces from the Terminal

Once Sentry MCP is connected, you can run full error investigation workflows entirely from your terminal without opening a browser. Claude Code will call the Sentry MCP tools, retrieve the data, and reason about it inline.

Basic issue listing:

List the top 10 unresolved issues in the "backend-api" project. Sort by frequency (events). Show issue ID, title, and event count.

Drilling into a specific issue:

Get Sentry issue BACKEND-4521. Show me the full stack trace, request context, and all breadcrumbs in chronological order.

Filtering by time range and severity:

Show me all unresolved Sentry issues in the "payment-service" project that appeared in the last 24 hours and have severity level "error" or "fatal".

Cross-referencing with local code: Because Claude Code has access to your project files alongside Sentry MCP, it can read the exact source files mentioned in the stack trace:

Get Sentry issue PAYMENT-882. Read the stack trace, then open the referenced source files in this project and identify the line that caused the error. Suggest a fix.

Searching by user, release, or transaction:

Find all Sentry events for issue CHECKOUT-301 where the affected user email matches "[email protected]". What breadcrumbs did she hit before the crash?
List all Sentry issues in project "web-frontend" that first appeared in release v5.3.0.

Working with distributed traces:

Get the Sentry trace with ID "d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9". Show me the full span tree and identify which service and span contains the error.

Tips
- Paste the Sentry issue URL directly into the prompt — Claude Code can extract the issue ID from URLs like https://acme-corp.sentry.io/issues/4521/.
- Ask Claude Code to output a Markdown table of issues — it makes the output much easier to scan in the terminal: "Format the results as a Markdown table with columns: Issue ID | Title | Events | Last Seen".
- Use is:unresolved !has:assignee in your Sentry query string when asking for issues to prioritize — it surfaces bugs that no one has claimed yet.
- Chain prompts: first get the issue list, then in the same session ask "now investigate issue #3 from that list in detail." Claude Code retains context across the session.


Sentry MCP in the Claude Code VS Code Extension for In-Editor Debugging

The Claude Code VS Code extension brings the same MCP capabilities into the editor sidebar, with the added advantage that Claude Code can see your open files, the active cursor position, selected code, and terminal output simultaneously.

Installing the extension:

  1. Open VS Code and search for "Claude Code" in the Extensions marketplace, or install via CLI:
code --install-extension anthropic.claude-code
  1. The extension shares the same settings files as the CLI (~/.claude/settings.json and .claude/settings.json). No additional MCP configuration is needed.

In-editor workflow:

Open the Claude Code sidebar panel (Cmd+Shift+P > "Claude Code: Open Panel" or click the Claude icon in the activity bar). The MCP servers configured in your settings file are available immediately.

Typical in-editor debugging session:

  1. You receive a Sentry alert for issue API-2091.
  2. Open the Claude Code panel in VS Code.
  3. Type:
Get Sentry issue API-2091. I have the project open in this editor. Find the file and line mentioned in the stack trace and show it to me.
  1. Claude Code uses the Sentry MCP to fetch the event, reads the stack trace, then uses its file access to open and highlight the relevant code.
  2. You select the suspicious function and ask:
This is the function from the Sentry stack trace. The error is a TypeError on line 47. What is wrong with this code and how do I fix it?
  1. Claude Code proposes a diff. You apply it with one click.

Using terminal output as context: If you reproduce the error locally and see a stack trace in the VS Code integrated terminal, you can ask:

I see this stack trace in my terminal [paste]. Cross-reference it with the matching Sentry issue. Are the stack frames the same? Is this the same bug or a different reproduction?

Tips
- Open the relevant source file before asking Claude Code to investigate — it gives the model the file as immediate context and often speeds up the analysis.
- Use VS Code's multi-root workspace feature if your stack spans multiple services. With all services open in one workspace, Claude Code can cross-reference Sentry stack frames across repo boundaries.
- The VS Code extension respects .claude/settings.json in whichever folder is the workspace root. If you have a monorepo, place the config at the monorepo root so it applies to all packages.
- Keyboard shortcut Cmd+Shift+. (macOS) opens the Claude Code quick input for fast one-off queries without switching to the panel.


Prompting AI to Diagnose and Propose Fixes Using Sentry Error Data

Writing effective prompts for Sentry-driven debugging is a skill. The quality of the diagnosis depends heavily on how you frame the request. Below are prompt patterns that consistently produce useful output.

Pattern 1: Issue + codebase context

Get Sentry issue ORDERS-7731. I'm working in the "orders-service" directory. Using the stack trace, identify the root cause and propose a minimal code fix. Show me the fix as a diff.

Pattern 2: Regression detection

I just deployed release v3.5.0. Pull all new Sentry issues in the "api-gateway" project that appeared after 2026-05-01. For each issue, tell me which function is the likely entry point of the regression.

Pattern 3: Prioritization brief

List all unresolved Sentry issues in project "checkout" with more than 100 events. For each issue: (1) summarize the root cause in one sentence, (2) estimate the user-facing impact (blocking vs. degraded), (3) suggest whether it needs a hotfix or can wait for the next sprint.

Pattern 4: Cross-service trace investigation

The Sentry trace ID for a user-reported payment failure is "a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6". Get the full trace. Identify which microservice introduced the latency or error. Then check if there is a matching Sentry issue for that service.

Pattern 5: Writing a reproduction test

Get Sentry issue AUTH-992. Read the breadcrumbs and request context. Write a Jest unit test that reproduces the error condition. Use the actual input values from the event payload.

Pattern 6: Assigning and resolving issues

I've deployed the fix for BACKEND-4521. Check the Sentry issue and tell me if new events have been reported in the last hour under the same issue. If not, draft a Slack message summarizing the fix and its impact.

Tips
- Always specify the project name in your prompt even if you think it's obvious — Sentry MCP may have access to multiple projects and will ask for disambiguation if you don't.
- Request a one-sentence root cause summary before asking for a fix proposal. It forces the AI to commit to a hypothesis first, which makes the fix more targeted and easier to verify.
- For complex bugs, ask the AI to list all the hypotheses it considered and why it ruled them out — this surfaces assumptions and reveals blind spots.
- If the proposed fix looks wrong, share the relevant source file contents explicitly: "Here is the actual implementation of calculateTax(): [paste code]. Does your fix still apply?"