Skip to main content

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.
string
required
Full repository name, e.g., owner/repo
integer
default:10
Maximum number of reviews to return (capped at 50)

Returns

List of review objects:
integer
required
Workflow run ID from the database
string
required
Full repository name
integer
GitHub pull request number
string
required
AI verdict: APPROVED, CHANGES_REQUESTED, COMMENT, or UNKNOWN
string
required
Plain-English review summary
string
ISO 8601 timestamp when the review was created
string
required
Workflow status: completed, failed, processing, or pending

Example

Implementation

Queries the WorkflowRun 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.
string
required
Full repository name, e.g., owner/repo

Returns

List of contributor objects:
string
required
GitHub username
integer
required
Number of PRs that touched files in this repository

Example

Implementation

Queries Neo4j using the graph_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.
string
required
Full repository name, e.g., owner/repo
integer
required
GitHub PR number

Returns

Single verdict object or error:
string
required
Full repository name
integer
required
GitHub pull request number
string
AI verdict: APPROVED, CHANGES_REQUESTED, COMMENT, or UNKNOWN
string
Plain-English review summary
string
ISO 8601 timestamp when the review was created
string
Error message if the review is not found or the query fails

Example

Implementation

Queries the WorkflowRun 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.
string
required
Full repository name, e.g., owner/repo

Returns

Health metrics object:
string
required
Full repository name
integer
required
Percentage of PRs with AI reviews (0–100)
number
Average time from PR open to merge in hours. Currently null (requires merge-event tracking).
integer
required
Number of completed PR reviews in the database
integer
required
Overall health score (0–100), derived from review activity
string
Informational note about missing metrics
string
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:
  1. Try to query the database or Neo4j graph
  2. On exception, log a warning and return:
    • Empty list [] for list-returning tools
    • {"error": "message"} for object-returning tools
  3. 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

The MCP server does not implement rate limiting. For production deployments with untrusted clients, add rate limiting middleware at the FastAPI level.

Source Code

All tools are implemented in:
Helper functions:
  • _query_db_reviews() — Database query for reviews (line 33)
  • _query_contributor_stats() — Neo4j query for contributors (line 83)