Sentry CLI for Agentic Debugging

Debugging production errors used to mean switching between your IDE, Sentry's web UI, and a dozen browser tabs. You'd copy issue IDs, dig through stack traces, cross-reference with your code, and lose context every time you switched windows.

Now there's a better way. Sentry's new CLI and MCP server let AI coding agents like Claude Code query your Sentry data directly from the terminal. No tab switching. No copy-pasting. Just ask "what's breaking in production?" and get answers with full stack traces, right where you write code.

Here's how to set it up and use it.

What Changed: The New Sentry CLI

Sentry now has two CLIs. The legacy sentry-cli is the build tool you know — it handles source maps, releases, and debug symbols in CI/CD pipelines. That one stays.

The new sentry CLI is different. It's an interactive developer tool built for both humans and AI agents. It can list issues, inspect events, query the API, and even call Sentry's AI (Seer) for root cause analysis — all from your terminal.

The key distinction: the new CLI is designed to be used by your coding agent as much as by you.

Installation

Install the new CLI:

curl https://cli.sentry.dev/install -fsS | bash

Or if you prefer a package manager:

# bun
bun add -g sentry

# npm
npm install -g sentry

Then authenticate:

sentry auth login

This opens a browser for OAuth. Once you authorize, credentials are stored in ~/.sentry/config.json. Every agent tool that wraps this CLI inherits your auth — no extra tokens to manage.

Verify it works:

sentry auth status

Option 1: Register as a Claude Code Skill

The fastest way to give Claude Code access to Sentry:

npx skills add https://cli.sentry.dev

That's it. Claude Code can now:

  • List and inspect Sentry issues
  • View full error events with stack traces
  • Browse your projects and organizations
  • Execute arbitrary Sentry API calls

This approach uses the CLI under the hood, so it inherits whatever authentication you've already set up.

Option 2: Sentry MCP Server (More Power)

For deeper integration, Sentry offers a full MCP (Model Context Protocol) server with 16+ tools. This gives agents structured access to more of Sentry's capabilities.

Remote Mode (Easiest)

No installation needed. Add this to your Claude Code MCP config:

{
  "mcpServers": {
    "sentry": {
      "url": "https://mcp.sentry.dev/mcp"
    }
  }
}

On first connection, you authenticate via OAuth in your browser. The server is always up to date since Sentry hosts it.

Local Stdio Mode (Self-Hosted / Offline)

If you run a self-hosted Sentry instance or need local control:

{
  "mcpServers": {
    "sentry": {
      "command": "npx",
      "args": ["@sentry/mcp-server"],
      "env": {
        "SENTRY_ACCESS_TOKEN": "your-sentry-user-auth-token"
      }
    }
  }
}

For self-hosted deployments, add --host=sentry.example.com to the args.

Your token needs these scopes: org:read, project:read, project:write, team:read, team:write, event:write.

Claude Code Plugin

You can also install it as a Claude Code plugin:

claude plugin marketplace add getsentry/sentry-mcp
claude plugin install sentry-mcp@sentry-mcp

Real Debugging Workflows

Here's where it gets practical. Once your agent has access to Sentry, you can debug production errors without leaving your editor.

"What's broken right now?"

Just ask:

"Show me the latest unresolved issues in my project"

The agent queries Sentry, returns a list of issues with titles, frequency, and first/last seen timestamps. No browser needed.

Investigate a Specific Error

"What's the full stack trace for PROJ-1234?"

The agent pulls the latest event for that issue, showing the complete stack trace, breadcrumbs, tags, and context. You're looking at the same data you'd see in Sentry's web UI, but right in your terminal alongside your code.

AI-Powered Root Cause Analysis

This is the killer feature. Sentry's Seer AI can analyze issues deeply:

# From the CLI directly
sentry issue explain PROJ-1234

# Or ask your agent
> "Use Sentry's Seer to analyze issue PROJ-1234 and suggest a fix"

Seer doesn't just show you the stack trace — it analyzes the error pattern, identifies the likely root cause, and generates a step-by-step fix plan. When invoked through your coding agent, it can even propose code changes in context.

Cross-Reference Errors with Your Code

"Check Sentry for errors in src/api/auth.ts and propose fixes"

The agent searches for Sentry issues related to that file, pulls the relevant stack traces, and suggests fixes based on both the error data and your actual source code. This is the workflow that used to take 20 minutes of tab-switching, now handled in a single prompt.

Monitor in Real-Time

The new CLI supports log streaming:

sentry log list -f

The -f flag works like tail -f — it streams new log entries as they arrive. Useful during deployments or when you're trying to reproduce an issue.

Tips for Effective Agentic Debugging

Be specific with project names. If you have multiple projects, include the project name or slug in your prompt. The CLI auto-detects from your codebase when possible, but being explicit avoids ambiguity.

Use JSON output for scripting. Every CLI command supports --json:

sentry issue list --json | jq '.[0].title'

Combine with your existing tools. Pipe Sentry data to jq, fzf, or any other CLI tool. The structured output is designed for composition.

Let the agent fix, not just find. The real power isn't just seeing errors — it's having the agent read the stack trace, find the relevant code, and propose a fix in one flow. Don't stop at "show me the error."

MCP vs CLI Skills vs Seer — When to Use What

Approach Best For
CLI Skill Quick setup, basic issue browsing, works with existing CLI auth
MCP Server (Remote) Full-featured agent integration, 16+ tools, zero maintenance
MCP Server (Local) Self-hosted Sentry, offline environments, custom configurations
Seer (via CLI or MCP) Deep root cause analysis, fix generation, complex debugging

You don't have to choose just one. The CLI skill is great for quick lookups, while the MCP server gives agents deeper access for complex investigations. Seer is the specialist you call in when you need AI to analyze the why behind an error.

What This Changes

The traditional debugging loop — see alert, open Sentry, read stack trace, switch to IDE, find file, understand context, write fix — collapses into a single conversation with your coding agent.

You say "there's a TypeError in production, fix it" and the agent:

  1. Queries Sentry for the issue
  2. Reads the full stack trace and breadcrumbs
  3. Opens the relevant file in your codebase
  4. Understands the context around the failing code
  5. Proposes (or writes) a fix

That's the promise of agentic debugging. And with Sentry's CLI and MCP server, it actually works today.


Get started: cli.sentry.dev | MCP Server: docs.sentry.io/product/sentry-mcp