Provides comprehensive tools for analyzing developer activity and contributions, including pull request analysis, code review tracking, comment analysis, impact assessment, and repository statistics through GitHub's REST and GraphQL APIs.
Uses GraphQL queries to efficiently fetch nested GitHub data such as reviews, comments, and files in a single request with cursor-based pagination.
GitHub MCP Server
A production-ready MCP (Model Context Protocol) server that exposes employee-centric GitHub activity APIs for AI agents and agent orchestration systems. This server abstracts GitHub REST & GraphQL APIs and provides semantic endpoints for analyzing developer contributions, code reviews, and impact over time ranges.
🎯 For AI Agents & Agent Orchestration
Quick Start for Agents: See AGENT_GUIDE.md for comprehensive agent-focused documentation, use cases, and examples.
Recommended Tool for Quick Overview: Use github.getUserRepoStats to get comprehensive metrics in a single call (PRs, comments, reviews, code changes).
Tool Discovery: All tools include detailed descriptions, examples, and use cases in their schemas for easy agent discovery.
Features
Pull Request Analysis: Fetch PRs authored by employees with detailed metadata
Review Tracking: Get PR reviews with states (APPROVED, CHANGES_REQUESTED, COMMENTED)
Comment Analysis: Extract inline and general review comments with file/line context
User Comments: Fetch all comments (review and issue) by a user for a repository within a time range
Repository Statistics: Get comprehensive stats (PRs, comments, reviews, code changes) for a user in a repository
Impact Assessment: Analyze whether review comments led to code changes
Code Statistics: Get detailed diff metadata and code stats for PRs
Architecture
Prerequisites
Node.js 20+
GitHub Personal Access Token with appropriate permissions:
repo(REQUIRED for private repos)read:org(REQUIRED for organization repositories)read:user(for user data)
For Private Organization Repositories
If you're querying private organization repositories (e.g., radireddy/AiApps), ensure:
Token has both scopes:
repoANDread:orgAccount membership: Your account must be a member of the organization
Organization settings: Organization must allow third-party access (if using OAuth)
Repository access: You must have at least read access to the repository
To verify your token has access, run:
Installation
Configuration
Option 1: Using .env file (Recommended)
Copy the example file:
cp .env.example .envEdit
.envand add your GitHub token:GITHUB_TOKEN=ghp_your_token_here
The .env file is automatically loaded and is excluded from git (already in .gitignore).
Option 2: Environment Variable
Note: The .env file approach is recommended as it keeps your token local and secure.
Usage
MCP Configuration
Add to your MCP client configuration (mcp.json):
Running the Server
The server communicates via stdio, so it should be launched by your MCP client.
MCP Tools
1. github.getAuthoredPRs
Fetch all PRs authored by a user in a time range.
Input:
Note: from and to are optional. If omitted, defaults to last 3 months. repos is required (at least one repository).
Output:
2. github.getPRReviews
Fetch PR reviews submitted by the employee. Filters by repository.
Input:
Note: from and to are optional. If omitted, defaults to last 3 months. repos is required (at least one repository).
Output:
3. github.getReviewComments
Fetch inline and general review comments. Returns structured JSON with PR-level grouping, totals, and date range. Filters by repository.
Input:
Note: from and to are optional. If omitted, defaults to last 3 months. repos is required (at least one repository).
Note: The repos parameter is required (at least one repository). Only comments on PRs in the specified repositories will be included. from and to are optional (defaults to last 3 months if omitted).
Output:
Note: All comment bodies are properly JSON-escaped to handle newlines (\n), quotes, and other special characters. The response is 100% valid JSON format.
4. github.getCommentImpact
Analyze whether review comments resulted in code changes. Filters by repository.
Input:
Note: from and to are optional. If omitted, defaults to last 3 months. repos is required (at least one repository).
Output:
Note:
Only comments with actual impact (commits found after comment) are included in the
impactsarrayThe
statsobject is only included if data is available (i.e., if comments were analyzed)Statistics are calculated from existing data without additional API calls
5. github.getUserComments
Fetch all comments (review comments and issue comments) added by a user for a given repository within a time duration. This tool combines PR review comments and PR issue comments, filters by comment.createdAt and author, normalizes the results, and deduplicates them.
Input:
Note: from and to are optional. If omitted, defaults to last 3 months. repos is required (at least one repository).
Output:
Note: This tool uses GitHub GraphQL APIs directly and filters by comment.createdAt client-side for accurate time-based filtering. It combines both review comments (inline comments from PR reviews) and issue comments (general comments on PRs), normalizes them into a unified format, and deduplicates by comment ID.
6. github.getUserRepoStats
Get comprehensive repository statistics for a user within a time frame. Aggregates all activity metrics including PRs, comments, reviews, and code changes.
Input:
Note: from and to are optional. If omitted, defaults to last 3 months. repos is required (at least one repository).
Output:
Note: This tool combines data from multiple sources (getAuthoredPRs, getUserComments, getPRReviews) to provide a complete overview of user activity in a repository. All statistics are filtered by the specified time range and repository.
Important: When comparing with github.getReviewComments:
getUserRepoStats.comments.totalincludes both review comments AND issue comments, whilegetReviewComments.totalCommentsincludes only review commentsgetUserRepoStats.comments.reviewshould matchgetReviewComments.totalCommentswhen both are filtered by the same repositorygetUserRepoStats.reviews.totalPRsReviewedcounts unique PRs reviewed, whilegetUserRepoStats.reviews.totalcounts total review submissions (a user can review the same PR multiple times)
Agent Orchestration
This MCP server is designed for use by AI agents and agent orchestration systems. All tools include:
Detailed descriptions with use cases and examples
Parameter examples in tool schemas
Consistent response formats for easy parsing
Automatic filtering of auto-generated content
Error handling with clear error messages
Quick Reference for Agents
Tool | Best For | Returns |
| Quick overview - Single call for all metrics | Complete stats (PRs, comments, reviews, code changes) |
| PR analysis | Array of PRs with metadata |
| Review participation | Array of reviews with states |
| Comment analysis | Grouped comments by PR |
| Review effectiveness | Impact assessments with confidence scores |
| All comments | Combined review + issue comments |
See
See
Example Agent Call
Here's an example of how an AI agent might use this MCP server:
Design Decisions
GraphQL over REST
More efficient for nested data (reviews, comments, files)
Single request for complex queries
Better type safety
Cursor-based Pagination
Handles large datasets efficiently
No duplicate results
Predictable performance
Normalized DTOs
Consistent data structure for agents
Hides GitHub API complexity
Easy to extend
Rate Limit Handling
Automatic detection and waiting
Request ID logging for debugging
Graceful error messages
Case-Insensitive Usernames
User-friendly (handles @ prefix, case variations)
Normalizes to lowercase for consistency
Error Handling
The server handles:
Authentication errors: Clear messages about GITHUB_TOKEN
Rate limits: Automatic waiting and informative errors
Invalid timestamps: Validation with helpful error messages
Missing data: Graceful defaults (null, empty arrays)
Extensibility
The architecture supports easy extension:
New Tools: Add to
tools.tsand register inserver.tsNew Queries: Add GraphQL queries to
queries.tsNew Mappers: Extend
mapper.tswith new DTOsCaching: Add caching layer in
client.ts(extension point)
Development
Agent Integration Examples
Example 1: Performance Review Data Collection
Example 2: Code Review Quality Assessment
Example 3: Multi-Repository Analysis
For more examples and workflows, see
License
MIT