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.py2
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
Navigate to sentry.io/settings/account/api/auth-tokens/
2
Create new auth token
Click “Create New Token” and give it a name like “Nectr MCP”
3
Set scopes
Required scopes:
project:readevent:read
4
Copy the token
Format:
sntrys_... (starts with sntrys_)3. Configure Nectr
Set environment variables in your Nectr backend:API Reference
MCPClientManager.get_sentry_errors()
Get recent Sentry errors related to a file being reviewed.
Source: app/mcp/client.py:72
Signature:
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")
[] if:
SENTRY_MCP_URLis 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
MCP Protocol Details
Nectr calls the Sentry MCP server using JSON-RPC 2.0 over HTTP:Request Format
Response Format
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:Suggestions
-
Add test case for the Sentry error: Include a test that reproduces
the
ValueErrorscenario to prevent regression. -
Log error details: Consider adding structured logging when this
validation fails to improve debugging:
- 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
2
Test Sentry MCP server directly
3
Check Nectr logs
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[]:
-
Check file path format: Sentry’s
file:"..."query is exact match -
Check time window: Default is 7 days. Increase if needed:
-
Test Sentry API directly:
Authentication errors
- Check token format: Should start with
sntrys_ - Verify scopes: Token needs
project:readandevent:readscopes - 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.Related Integrations
Linear Integration
Pull linked issues and task context
Slack Integration
Include relevant team messages in review context
Related Files
app/mcp/client.py:72-get_sentry_errors()implementationapp/mcp/client.py:118- Genericquery_mcp_server()methodapp/services/pr_review_service.py- How Sentry context is used in reviewsapp/core/config.py:68-SENTRY_MCP_URLandSENTRY_AUTH_TOKENsettings