Overview
The Sentry integration pulls production error data into PR reviews. When Nectr reviews a PR, it queries the Sentry MCP server for recent errors related to the files being changed. This helps reviewers catch regressions before merging. Example: A PR modifiesapp/services/auth.py. Nectr fetches Sentry errors where culprit contains auth.py and includes them in the review context:
- “OAuth token validation failed (seen 127 times in the last 24h)”
- “Redis connection timeout in session refresh (seen 43 times)“
How It Works
Sentry integration uses the Model Context Protocol (MCP) — Nectr acts as an MCP client and calls a Sentry MCP server to fetch errors.Graceful Degradation
IfSENTRY_MCP_URL is not set or the Sentry MCP server is offline:
- Nectr logs an info message:
"SENTRY_MCP_URL not configured — skipping Sentry error fetch" - Returns an empty list
[] - Review continues without Sentry context
Prerequisites
- Sentry Account (free or paid plan)
- Sentry Auth Token (sentry.io/settings/account/api/auth-tokens/)
- Sentry MCP Server (self-hosted or cloud-deployed)
Setup Guide
1. Generate a Sentry Auth Token
Navigate to Sentry API Settings
2. Deploy a Sentry MCP Server
You need an external MCP server that implements thesearch_errors tool. This server bridges Sentry’s REST API and the MCP protocol.
- Docker (Recommended)
- Self-Hosted Python
- Hosted Service
3. Set Environment Variables
Add the following to Nectr’s.env:
.env
4. Restart Nectr
Usage
Automatic Error Fetching
When a PR is opened, Nectr automatically:- Extracts changed files from the PR diff
- Calls Sentry MCP server for each file:
search_errors(project, filename) - Includes error context in the AI prompt
Manual Testing
Test the Sentry MCP server directly:Implementation Details
MCPClientManager
File:app/mcp/client.py:70
MCP Request Format
File:app/mcp/client.py:116
Configuration Reference
Base URL of the Sentry MCP server (e.g.,
http://sentry-mcp-server:8002)Sentry auth token for API access. Generate at sentry.io/settings/account/api/auth-tokens/.Required scopes:
event:read, project:read, org:readTroubleshooting
No errors returned
No errors returned
Cause: Sentry MCP server is not running or
SENTRY_MCP_URL is incorrect.Fix:- Test the MCP server directly:
curl http://sentry-mcp-server:8002/ - Check logs:
docker logs sentry-mcp-server - Verify
SENTRY_MCP_URLis set in Nectr’s.env
Error: HTTP 401 Unauthorized
Error: HTTP 401 Unauthorized
Timeout errors
Timeout errors
Cause: Sentry API is slow or MCP server is overloaded.Fix:
- Increase timeout: Edit
_MCP_TIMEOUTinapp/mcp/client.py(default: 10s) - Add caching to the MCP server (cache error queries for 60s)
- Filter errors by date range (last 7 days instead of all-time)
Errors not relevant to PR
Errors not relevant to PR
Cause:
culprit matching is too broad (e.g., “auth.py” matches “oauth.py”).Fix:- Use full file paths in MCP server:
app/services/auth.pyinstead ofauth.py - Filter errors by
first_seenorlast_seendate (only recent errors)
Next Steps
MCP Protocol
Understand how MCP connects Nectr with Sentry
Slack Integration
Fetch relevant channel messages as review context
Environment Variables
Full configuration reference