Get the FREE Ultimate OpenClaw Setup Guide →

bitbucket-automatic-pr-reviewer

🤖 Automated PR reviews using Claude CLI with Bitbucket webhooks. Features sequential processing, MCP integration, Prometheus metrics, and secure webhook validation. Perfect for teams wanting AI-powered code reviews without API costs.

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio tintinwinata-bitbucket-automatic-pr-reviewer docker compose up -d \
  --env WORKSPACE="yourworkspace" \
  --env WEBHOOK_SECRET="your-webhook-secret"

How to use

This MCP server provides a Docker-based PR automation service that listens for Bitbucket pull request webhooks and processes each PR using Claude CLI (not the API). When a PR is opened, the service validates the webhook signature, ensures the repository is cloned under the configured projects directory, updates the repository if needed, and then runs Claude CLI to generate a text-based code review. The workflow supports webhook validation, workspace scoping, and optional template-driven reviews, with results logged to the console and exportable metrics via Prometheus integration. You can extend functionality to post comments or release notes based on Claude’s output.

How to install

Prerequisites:

  • Docker and Docker Compose installed on the host
  • Bitbucket repository with webhook access and credentials
  • Node.js environment previously used for setup (optional, since this is Docker-based)

Installation steps:

  1. Clone the repository: git clone https://github.com/<org>/<repo>.git cd <repo>

  2. Copy the example environment file and tailor it to your environment: cp .env.example .env

    Edit .env to set WORKSPACE and WEBHOOK_SECRET and any other needed vars

  3. Build and run with Docker Compose: docker-compose up -d

  4. Optional: Run an initial setup to configure Claude CLI in the container (if applicable): npm install npm run setup

  5. Verify the server is running: curl http://localhost:3000/health

Notes:

  • The service uses Claude CLI installed inside the Docker image; there is no external API key required for Claude API usage.
  • Ensure your Bitbucket webhook is configured to point to http://your-server:3000/webhook/bitbucket/pr and that firewall rules allow inbound traffic on port 3000.

If you modify configuration or templates, restart the service with: docker-compose restart pr-automation

Additional notes

Tips and common issues:

  • Ensure the WORKSPACE value matches your intended workspace for Bitbucket scope restrictions.
  • If webhook validation fails, confirm the webhook secret matches the one configured in your Bitbucket webhook and in the environment variable WEBHOOK_SECRET.
  • The repository will be cloned under /app/projects inside the container (adjust volume mapping in docker-compose if you need persistence on the host).
  • Claude CLI is used with the --dangerously-skip-permissions flag; be mindful of the security implications and ensure proper workspace restrictions.
  • If you want to extend functionality to post PR comments, you can wire the Claude output back to Bitbucket using the existing webhook handling code path.
  • Prometheus metrics can be enabled to monitor queue length, processing times, and error rates by exposing /metrics in the Express server.

Related MCP Servers

Sponsor this space

Reach thousands of developers