MCP server
repostats exposes its analysis API as a remote MCP (Model Context Protocol) server, so AI coding agents — Claude Code, Cursor, Codex CLI, Aider — can call it as a native tool inside their tool-use loop, no shell-out needed.
Configure it
Claude Code
Add to ~/.config/claude-code/config.json (or your workspace's .mcp.json):
{
"mcpServers": {
"repostats": {
"url": "https://repostats.app/mcp/sse"
}
}
}
Or via the CLI:
claude mcp add --transport sse repostats https://repostats.app/mcp/sse
Cursor
Add to ~/.cursor/mcp.json (or .cursor/mcp.json in a project):
{
"mcpServers": {
"repostats": {
"url": "https://repostats.app/mcp/sse"
}
}
}
Codex CLI / Aider / other MCP clients
Most MCP clients accept an SSE URL directly. Point them at:
https://repostats.app/mcp/sse
Available tools
Once connected, the agent sees six tools:
| Tool | What it does |
|---|---|
analyze_repo | Bootstrap a public GitHub repo (or return the cached SHA). Args: url, optional force. |
get_metrics | Flat headline metrics — LOC, cost, complexity, files, languages, full COCOMO triplet. Args: owner, repo. |
get_language_summary | Per-language aggregate (files, code, comments, complexity). Args: owner, repo. |
get_top_files | Files ranked by code (default) or complexity. Args: owner, repo, optional sort_by, limit. |
list_recent | Recently analyzed repos in the public catalogue. Optional limit. |
compare_repos | Side-by-side metrics for two cached repos with size ratios. Args: repo_a, repo_b. |
Example agent flow
"Compare nodejs/node and dotnet/runtime, then add a repostats badge to my README."
# Agent reasoning (one possible plan): 1. tool: list_recent → confirm both repos are cached 2. tool: compare_repos repo_a=nodejs/node, repo_b=dotnet/runtime 3. (read the ratios; explain to user that dotnet is ~1.8× larger by complexity) 4. tool: get_metrics owner=dotnet repo=runtime 5. (write <!-- repostats:start --> ... <!-- repostats:end --> block to README.md)
Wire format
JSON-RPC 2.0 over Server-Sent Events. Two endpoints:
- GET/mcp/sse — opens the long-lived stream. First event is
event: endpointwith the path the client should POST follow-up requests to (includes a session id). - POST/mcp/messages?sessionId=… — JSON-RPC request body; reply is delivered over the open SSE stream.
Protocol version: 2024-11-05. Implements initialize, tools/list, tools/call, ping, plus the standard notifications/initialized + notifications/cancelled.
Auth, rate limits
Pair with
Already using repostats from REST or CI? Keep doing that — MCP is just a different transport over the same endpoints. See the AI integration guide for the REST-based playbook and CI/CD reference for GitHub Actions / curl patterns.