An MCP (Model Context Protocol) server that enables AI agents to extract PR details from git commit hashes using the GitHub CLI.
- Commit to PR Resolution: Automatically extracts PR numbers from commit hashes, merge commits, and squash commits
- Auto-Detection: Automatically detects GitHub repository from git working directory
- Comprehensive PR Data: Retrieves full PR details including title, description, author, status, labels, and reviews
- Flexible Input: Accepts commit hashes (full or short), branch names, or direct PR numbers
- Type-Safe: Built with TypeScript and Zod for runtime validation
- Node.js >= 18.0.0
- GitHub CLI installed and authenticated (
gh auth login) - An MCP-compatible client (Cursor, Claude Desktop, VS Code, etc.)
First, install the commit-to-pr-mcp server with your client.
Standard config works in most tools:
{
"mcpServers": {
"commit-to-pr": {
"command": "npx",
"args": [
"commit-to-pr-mcp@latest"
]
}
}
}Claude Code
Use the Claude Code CLI to add the server:
claude mcp add commit-to-pr npx commit-to-pr-mcp@latestClaude Desktop
Add to your Claude Desktop configuration (~/Library/Application Support/Claude/claude_desktop_config.json on macOS):
{
"mcpServers": {
"commit-to-pr": {
"command": "npx",
"args": ["commit-to-pr-mcp@latest"]
}
}
}Cursor
Go to Cursor Settings β MCP β Add new MCP Server. Name to your liking, use command type with the command npx commit-to-pr-mcp@latest. You can also verify config or add command arguments via clicking Edit.
Create .cursor/mcp.json in your project root:
{
"mcpServers": {
"commit-to-pr": {
"command": "npx",
"args": ["commit-to-pr-mcp@latest"]
}
}
}VS Code
Follow the MCP install guide, use the standard config above.
Alternatively, install using the VS Code CLI:
code --add-mcp '{"name":"commit-to-pr","command":"npx","args":["commit-to-pr-mcp@latest"]}'Cline
Add via the Cline VS Code extension settings or by updating your cline_mcp_settings.json file:
{
"mcpServers": {
"commit-to-pr": {
"command": "npx",
"args": [
"commit-to-pr-mcp@latest"
]
}
}
}Zed
Follow the MCP Servers documentation. Use the standard config above.
For local development and testing:
{
"mcpServers": {
"commit-to-pr": {
"command": "node",
"args": ["/absolute/path/to/commit-to-pr-mcp/dist/index.js"],
"env": {
"LOG_LEVEL": "debug"
}
}
}
}After installation, verify commit-to-pr-mcp is working:
- Restart your MCP client completely
- Check connection status:
- Cursor: Look for green dot in Settings β Tools & Integrations β MCP Tools
- Claude Desktop: Check for "commit_to_pr" in available tools
- VS Code: Verify in GitHub Copilot settings
- Test with a simple query:
Get PR details for commit abc123
If you see the AI agent use the get_pr tool and return PR information, you're all set! π
The server provides a single tool: get_pr
{
"commit": "abc123def456",
"repo": "owner/repo" // Optional: auto-detected from git working directory
}{
"commit": "feature/new-feature",
"cwd": "/path/to/repo" // Optional: specify working directory for auto-detection
}{
"pr_number": 42,
"repo": "owner/repo" // Optional: auto-detected from git working directory
}When working in a git repository, you can omit the repo parameter:
{
"commit": "abc123"
// Repository is automatically detected from git remote
}Get PR details by commit hash or PR number. Extracts PR number from git commits (merge commits, squash commits) and returns full PR details.
Parameters:
commit(optional): Git commit hash (full or short), branch name, or any git reference. Use this ORpr_number.pr_number(optional): PR number to look up directly. Use this ORcommit.repo(optional): GitHub repository inowner/repoformat. If not provided, auto-detects fromcwdor current working directory.cwd(optional): Working directory path to auto-detect the GitHub repository from git remote.
Note: Either commit or pr_number must be provided.
The tool returns a structured response:
{
"number": 42,
"title": "Add new feature",
"body": "This PR adds a new feature...",
"state": "MERGED",
"url": "https://github.com/owner/repo/pull/42",
"author": "username",
"createdAt": "2025-01-15T10:30:00Z",
"mergedAt": "2025-01-16T14:20:00Z",
"baseRef": "main",
"headRef": "feature/new-feature",
"labels": ["enhancement", "ready-for-review"],
"reviews": [
{
"author": "reviewer1",
"state": "APPROVED",
"submittedAt": "2025-01-16T12:00:00Z"
},
{
"author": "reviewer2",
"state": "CHANGES_REQUESTED",
"submittedAt": "2025-01-16T13:00:00Z"
}
]
}number: PR numbertitle: PR titlebody: PR description/body textstate: PR state (OPEN,CLOSED,MERGED)url: GitHub URL to the PRauthor: PR author usernamecreatedAt: Creation timestamp (ISO 8601)mergedAt: Merge timestamp (ISO 8601),nullif not mergedbaseRef: Target branch nameheadRef: Source branch namelabels: Array of label namesreviews: Array of review objects withauthor,state, andsubmittedAt
The server uses the GitHub CLI (gh) to:
-
Extract PR number from commits:
- Searches PRs containing the commit hash
- Parses merge commit messages (
Merge pull request #123) - Parses squash commit messages (
(#123))
-
Retrieve PR details:
- Fetches comprehensive PR information via
gh pr view - Includes reviews, labels, and metadata
- Fetches comprehensive PR information via
-
Auto-detect repository:
- Reads
git remote get-url originfrom the working directory - Extracts
owner/repoformat from the remote URL
- Reads
npm install
npm run buildFor local testing:
-
Build the project:
npm run build
-
Configure your MCP client to use the local build (see Local Development section above)
-
Test with an MCP Inspector or client
npm run build: Compile TypeScript to JavaScriptnpm run start: Run the compiled servernpm run dev: Run the server in development mode withtsx
src/
βββ index.ts # Main server implementation
βββ Tool handlers # get_pr tool logic
βββ Git utilities # Repository detection
βββ GitHub CLI # PR extraction and details
ISC
Contributions welcome! Please read the contributing guidelines and submit a PR.