Overview
Nectr’s MCP server exposes 4 tools that external agents can invoke to query review data, contributor statistics, PR verdicts, and repository health metrics. All tools are async functions that return plain Python dicts/lists and implement graceful error handling.get_recent_reviews
Get recent PR reviews for a repository with verdicts and summaries.Full repository name, e.g.,
owner/repoMaximum number of reviews to return (capped at 50)
Returns
List of review objects:Workflow run ID from the database
Full repository name
GitHub pull request number
AI verdict:
APPROVED, CHANGES_REQUESTED, COMMENT, or UNKNOWNPlain-English review summary
ISO 8601 timestamp when the review was created
Workflow status:
completed, failed, processing, or pendingExample
Implementation
Queries theWorkflowRun table filtered by workflow_type = 'pr_review', ordered by created_at DESC:
get_contributor_stats
Get top contributors for a repository with PR-touch counts from the Neo4j knowledge graph.Full repository name, e.g.,
owner/repoReturns
List of contributor objects:GitHub username
Number of PRs that touched files in this repository
Example
Implementation
Queries Neo4j using thegraph_builder.get_file_experts() service:
Returns an empty list if Neo4j is not configured or the query fails. This ensures graceful degradation.
get_pr_verdict
Get Nectr’s AI verdict for a specific pull request.Full repository name, e.g.,
owner/repoGitHub PR number
Returns
Single verdict object or error:Full repository name
GitHub pull request number
AI verdict:
APPROVED, CHANGES_REQUESTED, COMMENT, or UNKNOWNPlain-English review summary
ISO 8601 timestamp when the review was created
Error message if the review is not found or the query fails
Example
Implementation
Queries theWorkflowRun table for the most recent 100 pr_review workflows, then filters by PR number:
The search is limited to the last 100 reviews for performance. If the PR is older, it may not be found.
get_repo_health
Get overall repository health metrics and a 0–100 health score.Full repository name, e.g.,
owner/repoReturns
Health metrics object:Full repository name
Percentage of PRs with AI reviews (0–100)
Average time from PR open to merge in hours. Currently
null (requires merge-event tracking).Number of completed PR reviews in the database
Overall health score (0–100), derived from review activity
Informational note about missing metrics
Error message if the query fails
Example
Health Score Calculation
The health score is derived from the number of completed reviews:- 0 reviews → 0% health
- 10 reviews → 50% health
- 20+ reviews → 100% health
Implementation
avg_merge_time_hours is currently null because Nectr does not track merge events yet. This is a planned feature.Error Handling
All tools implement defensive error handling:- Try to query the database or Neo4j graph
- On exception, log a warning and return:
- Empty list
[]for list-returning tools {"error": "message"}for object-returning tools
- Empty list
- Never crash — external agents always get a valid JSON-RPC response
Example Error
Timeouts
MCP tool calls do not have explicit timeouts. However:- Database queries use SQLAlchemy’s async engine with connection pooling
- Neo4j queries have a default 30-second timeout
- FastMCP handles request cancellation if the client disconnects
Rate Limiting
Source Code
All tools are implemented in:_query_db_reviews()— Database query for reviews (line 33)_query_contributor_stats()— Neo4j query for contributors (line 83)