mcp-pr-companion
Fetches pull request metadata, commit history, and diffs from Bitbucket Cloud to generate a compact JSON summary for AI-powered PR description generation.
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., "@mcp-pr-companionGenerate PR payload for https://bitbucket.org/workspace/repo/pull-requests/123"
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.
π mcp-pr-companion
mcp-pr-companion is a Local Model Context Protocol (MCP) Server and Standalone CLI Tool designed to run offline on developer workstations or connect directly to Bitbucket Cloud REST API.
It automatically parses Git diffs, commit histories, and code structures, categorizing changes into architectural layers (Database, API Controllers, Services, gRPC, Unit Tests) via AST/Regex extraction rules. It then packages the extracted data into a compact JSON payload (~1-2KB) tailored for AI PR description generation.
π― Purpose & Key Benefits
Dual-Mode Execution: Works seamlessly as an Automated MCP Server (invoked by AI) OR as a Standalone Terminal CLI (run manually by developers).
Token Optimization: Reduces AI context token consumption by 80% - 90% by eliminating raw diff dumps.
Speed: Accelerates PR description generation by 5x - 10x.
Privacy & Security: Operates 100% locally or via secure read-only Bitbucket API. Raw git diffs remain on your machine; only sanitized JSON summary metadata is passed to the AI.
Auto-Archiving Each Execution: Every execution automatically saves a timestamped JSON snapshot to
./output/description_kb_{PR_ID}_{TIMESTAMP}.jsonfor historical tracking and easy AI retrieval.
Related MCP server: MCP Merge Request Summarizer
π» Manual CLI Execution (Run Directly from Terminal)
You can run mcp-pr-companion manually from your Terminal at any time!
1. Generate via Bitbucket PR URL:
npm run generate -- --url https://bitbucket.org/workspace/repo/pull-requests/1232. Generate via Local Git Branch Comparison:
npm run generate -- --source feature/WCE-815-staging --target main3. Display Help & Options:
npm run generate -- --helpπΎ Automatic JSON File Archiving (./output/)
Every time mcp-pr-companion executes (via CLI or MCP Server), a unique JSON file is automatically written to ./output/:
Filename Pattern:
description_kb_{ticketId_or_prId}_{timestamp}.jsonExample File:
./output/description_kb_WCE-815_pr_123_20260728_181235.json
The./output/ directory is GIT IGNORED via .gitignore to prevent any temporary data files from being committed to your source code repository.
π Bitbucket API Credentials & Token Setup Guide
To fetch Pull Request data directly via Bitbucket PR URLs (https://bitbucket.org/{workspace}/{repo}/pull-requests/{id}), create a Bitbucket App Password with Read-Only permissions.
π How to Generate a Bitbucket App Password (Token):
Log into Bitbucket Cloud.
Click your Avatar profile icon (Settings) -> Select Personal settings.
In the left navigation menu under Access Management, click App Passwords.
Click the Create app password button.
Set a Label (e.g.,
mcp-pr-companion).Check ONLY the following 2 Read permissions for maximum security:
β Pull requests:
Read(pullrequest:read)β Repositories:
Read(repository:read)
Click Create and copy the generated App Password token.
βοΈ Configuring config.json:
Paste your Bitbucket username and the generated App Password token into config.json (which is .gitignore protected):
{
"ticket_prefix": ["WCE-", "PROJ-", "JIRA-"],
"output_language": "vi",
"default_target_branch": "main",
"bitbucket": {
"workspace": "your-company-workspace",
"username": "your_email@company.com",
"app_password": "ATBBxxxxxxxxxxxxxxxxxxxxxxxx"
}
}π‘ Real-Time Console Progress Logs
During execution, mcp-pr-companion outputs detailed step-by-step progress logs to stderr so you can monitor execution status:
[STEP 1/5] π Parsing Bitbucket PR URL: https://bitbucket.org/workspace/repo/pull-requests/123
[STEP 2/5] π Fetching PR Metadata for workspace/repo PR #123...
β Found PR: "[WCE-815] Tiered Call Outcomes" (feature/WCE-815 -> main) by Ninh Duong
[STEP 3/5] π Fetching PR Commit History...
β Retrieved 3 commits
[STEP 4/5] π Fetching PR Diffstat and Raw Code Diff...
β Found 12 changed files (+450 / -60 lines)
[STEP 5/5] π§© Classifying changed files into Modules & extracting Code Highlights...
β
[SUCCESS] Payload generated and saved to: ./output/description_kb_WCE-815_pr_123_20260728_181235.jsonπ Repository Structure & Security Guidelines
mcp-pr-companion/
βββ bin/
β βββ cli.js # CLI execution entrypoint (Supports CLI flags & Stdio)
βββ scripts/
β βββ setup.js # 1-Click Auto-Setup & Healthcheck bootstrapper
βββ src/
β βββ cli/ # Manual Terminal CLI Runner
β β βββ cli.runner.ts
β βββ healthcheck/ # Environment pre-flight check (Node, Git CLI)
β β βββ healthcheck.ts
β βββ config/ # Configuration schema & loader
β β βββ config.loader.ts
β β βββ config.schema.ts
β βββ core/ # Core Git & Bitbucket extraction logic
β β βββ bitbucket/ # Bitbucket REST API v2 connector
β β β βββ bitbucket.service.ts
β β βββ git/ # Local Git CLI runner & parsers
β β βββ analyzer/ # Module classifier & code highlight extractor
β β βββ generator/ # Payload JSON builder (~1-2KB output & file saver)
β βββ mcp/ # MCP Protocol implementation (Stdio Transport)
β β βββ server.ts
β β βββ tools/ # Registered tool: generate_pr_payload
β βββ utils/
β βββ logger.ts # Safe stderr logging (prevents stdio corruption)
β
βββ β οΈ config.json # [SENSITIVE] Local configuration (GIT IGNORED)
βββ config.example.json # Safe default configuration template
βββ π output/ # [GIT IGNORED] Auto-saved PR JSON payload archives
βββ package.json
βββ tsconfig.json
βββ README.mdβοΈ Available Commands & Scripts
Run Manual Payload Generation:
npm run generate -- --url https://bitbucket.org/workspace/repo/pull-requests/1231-Click Setup & Installation Bootstrapper:
npm run setupStart Production MCP Server:
npm startStart Development Mode (Hot Reload / Live TS):
npm run devRun Pre-flight Healthcheck:
npm run healthcheckBuild TypeScript Project:
npm run build
π οΈ MCP Client Integration Setup
Add the relative path execution command to your MCP configuration file:
{
"mcpServers": {
"mcp-pr-companion": {
"command": "node",
"args": [
"./dist/mcp/server.js"
],
"env": {}
}
}
}π Usage Example
Provide a Bitbucket PR link to your AI assistant:
"Here is my PR link:
https://bitbucket.org/workspace/repo/pull-requests/123. Please usegenerate_pr_payloadto fetch data and write a PR description for Bitbucket."
The AI assistant will invoke generate_pr_payload locally, stream step-by-step progress to your console log, save a snapshot file to ./output/description_kb_WCE-815_pr_123_20260728_181235.json, receive a lightweight ~1KB JSON summary, and render a formatted PR description.
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Tools
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/Ninh-Duong/mcp-pr-companion'
If you have feedback or need assistance with the MCP directory API, please join our Discord server