Skip to main content
Glama

šŸš€ mcp-pr-companion

mcp-pr-companion is a dual-interface local pre-processing system (supporting Bitbucket Cloud REST API v2 & local Git diffs) designed to convert Pull Requests into compact, Adaptive AI Context Packs optimized for AI Coding Assistants and AI Agents.


šŸ“Œ 1. Features Overview

  • Adaptive AI Context Strategy:

    • Dynamically tailors context pack structures based on PR size and risk level across 4 modes: skim, standard, inspect_priority_files, and deep_review.

    • Automatically generates an explicit Read Strategy section guiding AI agents on required next files, optional next files, and skipped categories to optimize token efficiency (70% - 95% token savings).

    • Moves full file lists into files.md, keeping context.md ultra-compact (0.5 – 1KB for comment-only PRs).

  • Schema v4 & Atomic Revision Storage:

    • Multi-revision storage engine featuring atomic write staging to prevent partial writes.

    • Manages active revision pointers via current.json (context_path, files_summary_path, actions_path, manifest_path, ai_reading_mode).

  • MCP Server & Dual-Interface Architecture:

    • Local MCP Server over stdio: Exposes MCP tools (get_pr_context_pack, get_pr_file_context, search_pr_files, get_pr_manifest, get_pr_sync_status, refresh_pr_data) for direct integration with AI IDEs and Agents.

    • Terminal UI (npm run cmd): Interactive TUI for token configuration, PR link registry management, cache warming, and log inspection.

    • One-Command Auto Sync (npm run mcp-pr-companion): Automated sequential discovery, filtering, and context pack generation for all OPEN pull requests owned by the user.

  • AST Analyzer & Secret Redacting Security:

    • Classifies change kinds (comment_only, functional_logic, public_api, database_schema, auth_security, configuration, etc.).

    • Extracts source code AST symbols (functions, methods, HTTP routes).

    • Automatically scans and redacts tokens/passwords via Redactor (ATBB****abcd).

    • Enforces account identity locking (author.uuid) to prevent cross-account PR data leakage.


Related MCP server: MCP Merge Request Summarizer

šŸ› ļø 2. Available Commands

Command

Description

npm run cmd

Launches the interactive Terminal UI (TUI) to configure API tokens, manage PR link registry, warm local cache, and inspect sync logs.

npm run cmd:prod

Launches the Terminal UI using compiled JavaScript assets in dist/.

npm run mcp-pr-companion

Runs the One-Command Auto Runner: Authenticates session, discovers all OPEN pull requests for the active user, and syncs/generates context packs automatically.

npm run mcp-pr-companion:prod

Runs the One-Command Auto Runner using compiled JavaScript assets in dist/.

npm start

Starts the Local MCP Server in production mode over stdio transport for AI Agent connections.

npm run dev

Starts the MCP Server in development mode with tsx hot reloading.

npm run build

Compiles TypeScript source files (src/) into JavaScript (dist/).

npm test

Runs the complete Automated Test Suite (Unit tests, Schema Contract validation, Referential Integrity, Aggregate validation, 9 Golden Scenarios, Atomic Write Rollback, and Orchestration tests).

npm run setup

Initializes local environment, directory structures, and default configuration templates.

npm run check-deps

Verifies required Node.js package dependencies.

npm run install-deps

Automatically installs missing Node.js dependencies.

npm run healthcheck

Performs pre-flight environment checks (Node.js version, Git CLI availability).

npm run generate

CLI runner for generating single PR payloads.


šŸ”„ 3. Feature Workflow

The diagram below illustrates the end-to-end pipeline from PR request to Adaptive AI Context Pack generation and MCP serving:

flowchart TD
    A[PR Sync Request / MCP Tool Call] --> B{Request Source}
    B -- Terminal UI / CLI --> C[Bitbucket API / Local Git]
    B -- MCP Server Tool Call --> C

    C --> D[Authenticate & Filter Author UUID]
    D --> E[Fetch Diffs, Commits & Metadata]
    
    E --> F[AST Analyzer & Risk Analyzer]
    F --> G[Classify Change Kind & Risk Tags]
    
    G --> H[ContextModeClassifier]
    H -->|Evaluate File Count & Risk Level| I{Select Context Mode}
    
    I -- total_files <= 3 & comment_only --> J[Mode: skim]
    I -- standard logic changes --> K[Mode: standard]
    I -- public_api / database_schema --> L[Mode: inspect_priority_files]
    I -- overall_risk high/critical or files > 30 --> M[Mode: deep_review]

    J --> N[Generate Read Strategy & Markdown Context]
    K --> N
    L --> N
    M --> N

    N --> O[Atomic Revision Writer]
    O --> P[Persist Staging Directory Atomically]
    P --> P1[context.md - Adaptive Pack]
    P --> P2[files.md - Full File Index]
    P --> P3[files/file_XXXX.md - File Details]
    P --> P4[manifest.json & current.json]

    P1 & P2 & P3 --> Q[Serve MCP Client / AI Agent]

šŸ“ Runtime Directory & Context Output Layout

Generated context packs are structured as follows:

ai-context/{company}/{app}/{feature}/{repo}_{PR-ID}/
ā”œā”€ā”€ context.md          # Primary AI Entrypoint (Adaptive Markdown Context Pack)
ā”œā”€ā”€ files.md            # Complete Changed Files Index & Categorization Table
ā”œā”€ā”€ actions.md          # Tool Action Summary & Coverage Metadata
ā”œā”€ā”€ current.json        # Pointer to Active Revision & Reading Mode
ā”œā”€ā”€ manifest.json       # Structured Metadata Manifest (v4 Schema)
ā”œā”€ā”€ files/              # Per-file AI Detail Markdown Files
│   ā”œā”€ā”€ file_0001.md
│   └── file_0002.md
└── revisions/          # Revision History Subdirectory
    └── rev_xxxx_yyyy/

Available Tools

1 tool
generate_pr_payloadA

Extracts Bitbucket PR or local Git branch diffs, commits, and AST module categorizations into a compact JSON schema (~1-2KB) for AI PR description generation.

ParametersJSON Schema
NameRequiredDescriptionDefault
pr_urlNoFull Bitbucket PR URL (e.g., https://bitbucket.org/workspace/repo/pull-requests/123).
repo_pathNoAbsolute path to target Git repo directory.
source_branchNoSource branch name (e.g., feature/WCE-815). Defaults to currently checked out branch.
target_branchNoTarget branch name (e.g., main or release/staging). Defaults to main.

TDQS

A3.7/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden. The term 'extracts' suggests a read-only operation, but there is no explicit statement about whether the tool modifies any state, requires authentication, or has rate limits. The description is somewhat vague on behavioral traits, earning a moderate score.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single sentence that concisely conveys the tool's purpose, input sources, and output format. It is front-loaded with the key action and resource, with no redundant or extraneous words. Every part of the sentence adds value.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The tool has 4 parameters and no output schema, yet the description only broadly mentions the output as 'diffs, commits, and AST module categorizations' without detailing the exact structure or fields. While it gives a size estimate (~1-2KB), an agent would benefit from knowing the output keys or schema. The description is partially complete but lacks depth for full contextual understanding.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the input schema already documents all four parameters with descriptions. The tool description does not add additional meaning beyond what is in the schema (e.g., example values or relationships). Per guidelines, with high coverage, baseline is 3, and no extra value is provided.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool extracts diffs, commits, and AST categorizations into a compact JSON schema for AI PR description generation. It specifies the resource (Bitbucket PR or local Git branch) and the output format, making the purpose highly specific and unambiguous. No sibling tools exist, so distinction is not needed.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage for generating PR descriptions but lacks explicit guidance on when to use this tool versus alternatives or when not to use it (e.g., for simple commit history). No prerequisites or exclusions are mentioned. Since there are no sibling tools, the lack of comparative guidance is less critical, but still leaves room for improvement.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 1 tool updatev1.0.0
    • First observedgenerate_pr_payload

TDQS

A3.6/5.0

Scored across 1 tool

Disambiguation5/5

With only one tool, there is no possibility of confusion between tools. The single tool's purpose is clearly defined.

Naming Consistency5/5

The single tool name 'generate_pr_payload' follows a consistent verb_noun pattern with underscores, making it clear and predictable.

Tool Count2/5

A single tool feels too few for a server named 'PR companion', which implies a broader set of PR-related operations. This narrow scope limits the server's utility.

Completeness1/5

The server only provides a means to generate a payload for PR description generation, lacking essential operations such as listing PRs, reviewing, merging, or managing comments. This is severely incomplete for a PR companion.

Maintenance

ActivitySlowing
ResponsivenessNo issues

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

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

Related MCP Connectors

Related MCP Servers