Skip to main content
Glama

πŸš€ 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}.json for 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/123

2. Generate via Local Git Branch Comparison:

npm run generate -- --source feature/WCE-815-staging --target main

3. 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}.json

  • Example File: ./output/description_kb_WCE-815_pr_123_20260728_181235.json

NOTE

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):

  1. Log into Bitbucket Cloud.

  2. Click your Avatar profile icon (Settings) -> Select Personal settings.

  3. In the left navigation menu under Access Management, click App Passwords.

  4. Click the Create app password button.

  5. Set a Label (e.g., mcp-pr-companion).

  6. Check ONLY the following 2 Read permissions for maximum security:

    • βœ… Pull requests: Read (pullrequest:read)

    • βœ… Repositories: Read (repository:read)

  7. 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/123
  • 1-Click Setup & Installation Bootstrapper:

    npm run setup
  • Start Production MCP Server:

    npm start
  • Start Development Mode (Hot Reload / Live TS):

    npm run dev
  • Run Pre-flight Healthcheck:

    npm run healthcheck
  • Build 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 use generate_pr_payload to 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.

Install Server
F
license - not found
A
quality
B
maintenance

Maintenance

–Maintainers
–Response time
–Release cycle
–Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Latest Blog Posts

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