Automatically detects repository information and identifies git references such as commit hashes or branch names within local working directories to resolve them into pull requests.
Retrieves comprehensive GitHub pull request data, including titles, descriptions, labels, and review history, by using the GitHub CLI to resolve commit hashes or PR numbers.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@commit-to-pr-mcpshow me the pull request details for commit 8f2a1b"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
commit-to-pr-mcp
An MCP (Model Context Protocol) server that enables AI agents to extract PR details from git commit hashes using the GitHub CLI.
Features
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
Prerequisites
Node.js >= 18.0.0
GitHub CLI installed and authenticated (
gh auth login)An MCP-compatible client (Cursor, Claude Desktop, VS Code, etc.)
Installation
Getting Started
First, install the commit-to-pr-mcp server with your client.
Standard config works in most tools:
Use the Claude Code CLI to add the server:
Add to your Claude Desktop configuration (~/Library/Application Support/Claude/claude_desktop_config.json on macOS):
Click the button to install:
Or install manually:
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.
Project-Specific Configuration
Create .cursor/mcp.json in your project root:
Follow the MCP install guide, use the standard config above.
Alternatively, install using the VS Code CLI:
Add via the Cline VS Code extension settings or by updating your cline_mcp_settings.json file:
Follow the MCP Servers documentation. Use the standard config above.
Local Development
For local development and testing:
Verify Installation
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! 🎉
Usage
The server provides a single tool: get_pr
Basic Example: Get PR from Commit Hash
Example: Get PR from Branch Name
Example: Get PR by Number Directly
Example: Auto-Detect Repository
When working in a git repository, you can omit the repo parameter:
Tool Parameters
get_pr
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.
Response Format
The tool returns a structured response:
Response Fields
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
How It Works
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 viewIncludes reviews, labels, and metadata
Auto-detect repository:
Reads
git remote get-url originfrom the working directoryExtracts
owner/repoformat from the remote URL
Development
Setup
Testing
For local testing:
Build the project:
npm run buildConfigure your MCP client to use the local build (see Local Development section above)
Test with an MCP Inspector or client
Development Scripts
npm run build: Compile TypeScript to JavaScriptnpm run start: Run the compiled servernpm run dev: Run the server in development mode withtsx
Architecture
License
ISC
Contributing
Contributions welcome! Please read the contributing guidelines and submit a PR.