Overview
Nectr exposes its own review database via the Model Context Protocol (MCP) so external tools can pull PR verdicts, contributor stats, and repository health metrics. This is the outbound direction — Nectr acts as an MCP server that other agents (Linear bots, Claude Desktop, Slack apps) can query. Transport: Server-Sent Events (SSE) at/mcp/sse
Implementation: app/mcp/server.py (FastMCP)
Architecture
Nectr’s MCP server provides:- 4 Tools — callable functions for fetching review data
- 1 Resource — streaming recent reviews as JSON
Quick Start
1. Nectr MCP Server is Always Running
The MCP server is automatically mounted at/mcp when Nectr starts. No additional configuration needed.
File: app/mcp/router.py mounts the SSE endpoint
2. Connect from Claude Desktop
Add Nectr to Claude Desktop’s MCP configuration:~/Library/Application Support/Claude/claude_desktop_config.json
For production deployments
For production deployments
3. Test with Claude Desktop
Ask Claude:“What are the recent reviews for acme/backend?”Claude will call Nectr’s
get_recent_reviews tool and display results.
Available Tools
Nectr exposes 4 MCP tools. See MCP Tools Reference for detailed signatures.get_recent_reviews
Fetch recent PR reviews with verdicts and summaries
get_contributor_stats
Get top contributors with PR-touch counts from Neo4j
get_pr_verdict
Retrieve AI verdict for a specific PR
get_repo_health
Calculate repository health score (0-100)
Manual Testing
Using curl (SSE Stream)
Using MCP Inspector
Install the MCP Inspector CLI:Configuration
No Environment Variables Needed
The MCP server is automatically enabled when Nectr starts. It reads data from:- PostgreSQL (via
app/core/database.py) — PR reviews and verdicts - Neo4j (via
app/services/graph_builder.py) — Contributor stats
Optional: Restrict Access
By default, the MCP server is publicly accessible at/mcp/sse. To restrict access:
- API Key Middleware (Recommended)
- IP Allowlist (Infrastructure)
Add a middleware to Set
app/mcp/router.py that checks for a bearer token:MCP_API_KEY in .env:Deployment
Docker Compose
The MCP server is included in the defaultdocker-compose.yml. No changes needed.
Railway / Render / Fly.io
Deploy the backend service as usual. The MCP server will be available at:Kubernetes
Expose the/mcp path via an Ingress:
Connecting External Clients
Claude Desktop
See Quick Start above.Custom Python Client
Usehttpx with SSE:
Linear Bot Integration
Create a Linear bot that queries Nectr’s MCP server when an issue is created:Troubleshooting
Error: Connection refused
Error: Connection refused
Cause: Nectr backend is not running or
/mcp endpoint is not mounted.Fix:- Verify Nectr is running:
curl http://localhost:8000/health - Check logs:
docker logs nectr-backend - Ensure
app/mcp/router.pyis imported inapp/main.py
Error: No tools available
Error: No tools available
Cause: MCP server failed to register tools (likely import error).Fix:
- Check logs for
ImportErrororNameError - Verify
app/mcp/server.pyis not crashing on import - Test locally:
python -c "from app.mcp.server import mcp; print(mcp.list_tools())"
Empty results from tools
Empty results from tools
Cause: Database is empty or Neo4j is not configured.Fix:
- Check database connection:
DATABASE_URLin.env - Verify Neo4j connection:
NEO4J_URI,NEO4J_USERNAME,NEO4J_PASSWORD - Run a review to populate the database
SSE connection drops
SSE connection drops
Cause: Reverse proxy or firewall is closing long-lived connections.Fix:
- Configure nginx to allow SSE:
proxy_buffering off; proxy_read_timeout 3600s; - Use HTTP/2 (automatically keeps connections alive)
Next Steps
MCP Tools Reference
Browse all available MCP tools and signatures
MCP Resources
Understand MCP resources for streaming data
MCP Protocol
Deep dive into how MCP works in Nectr