Skip to main content

Overview

The Sentry integration allows Nectr to pull production error data during PR reviews. When reviewing a PR, Nectr checks Sentry for recent errors related to the files being changed, helping reviewers understand:
  • Does this PR fix a known production issue?
  • Are the changed files causing errors in production?
  • Should this PR include additional error handling based on real incidents?
This is an inbound MCP integration — Nectr acts as an MCP client connecting to a Sentry MCP server.

How It Works

1

PR modifies files

Developer submits a PR changing app/services/auth.py and app/api/login.py
2

Nectr extracts changed files

During PR review, Nectr parses the PR diff to identify modified file paths
3

MCP query to Sentry

For each critical file, Nectr calls the Sentry MCP server:
4

Context included in review

Sentry error data is injected into the AI review prompt:
5

AI review considers error context

Claude can now:
  • Verify if the PR fixes the reported error
  • Suggest additional error handling based on production incidents
  • Flag if changes might introduce new error patterns

Setup

1. Deploy Sentry MCP Server

You need a Sentry MCP server running separately from Nectr. Build your own Sentry MCP server:

2. Get Sentry Auth Token

1

Go to Sentry settings

2

Create new auth token

Click “Create New Token” and give it a name like “Nectr MCP”
3

Set scopes

Required scopes:
  • project:read
  • event:read
4

Copy the token

Format: sntrys_... (starts with sntrys_)

3. Configure Nectr

Set environment variables in your Nectr backend:
Both SENTRY_MCP_URL and SENTRY_AUTH_TOKEN must be set for the integration to work. If either is missing, Sentry context will be silently skipped.

API Reference

MCPClientManager.get_sentry_errors()

Get recent Sentry errors related to a file being reviewed. Source: app/mcp/client.py:72 Signature:
Parameters:
  • project (str): Sentry project slug (e.g., "backend", "frontend", "api")
  • filename (str): File path from the PR diff to filter errors by (e.g., "app/services/auth.py")
Returns:
Returns empty list [] if:
  • SENTRY_MCP_URL is not configured
  • Sentry MCP server is unreachable
  • MCP call times out (10-second timeout)
  • No errors found for the file in the last 7 days
Example Usage:

MCP Protocol Details

Nectr calls the Sentry MCP server using JSON-RPC 2.0 over HTTP:

Request Format

Response Format

Nectr’s MCPClientManager unwraps this format automatically (see MCP Overview).

Timeout and Error Handling

The Sentry MCP client has a 10-second timeout to prevent slow external services from blocking PR reviews.
Sentry integration is best-effort. If the MCP server is down or slow, PR reviews continue without Sentry context. External context should enhance reviews, not block them.

Usage in PR Review Flow

Here’s how Sentry context is pulled during a review:

Example Review with Sentry Context

Here’s how Sentry context appears in an AI-generated review:
This should resolve the 47 occurrences reported by Sentry.

Suggestions

  1. Add test case for the Sentry error: Include a test that reproduces the ValueError scenario to prevent regression.
  2. Log error details: Consider adding structured logging when this validation fails to improve debugging:
  3. Monitor after deploy: Track this Sentry issue for 24-48 hours after merge to confirm the fix is effective.

Verdict

APPROVE - Excellent fix for a real production issue. Add tests before merging.

Auto-Detection from Repository Name

Advanced: Multi-File Error Queries

For PRs changing multiple files, query Sentry for each:

Troubleshooting

No Sentry context appearing in reviews

1

Check environment variables

Both must be set and non-empty.
2

Test Sentry MCP server directly

Should return JSON with errors (or empty array if no errors).
3

Check Nectr logs

Look for warnings like “SENTRY_MCP_URL not configured”.
4

Verify file paths match Sentry

Sentry tracks file paths from stack traces. Ensure your MCP server query matches Sentry’s file path format (e.g., app/services/auth.py vs services/auth.py).

Sentry returning no errors

If Sentry has errors but MCP returns []:
  1. Check file path format: Sentry’s file:"..." query is exact match
  2. Check time window: Default is 7 days. Increase if needed:
  3. Test Sentry API directly:

Authentication errors

  • Check token format: Should start with sntrys_
  • Verify scopes: Token needs project:read and event:read scopes
  • Check organization access: Token must have access to the Sentry organization

Best Practices

Limit queries

Only query Sentry for critical files (skip tests, docs). Use the first 1-3 changed files to avoid rate limits.

Cache results

Cache Sentry results for 5-10 minutes to avoid duplicate queries for the same file.

Filter by error level

Focus on error and fatal level issues. Skip warning and info to reduce noise.

Link to Sentry UI

Always include permalink in review so developers can investigate full stack traces.

Linear Integration

Pull linked issues and task context

Slack Integration

Include relevant team messages in review context
  • app/mcp/client.py:72 - get_sentry_errors() implementation
  • app/mcp/client.py:118 - Generic query_mcp_server() method
  • app/services/pr_review_service.py - How Sentry context is used in reviews
  • app/core/config.py:68 - SENTRY_MCP_URL and SENTRY_AUTH_TOKEN settings