GitHub, GitLab & PR Code Review MCP Servers: Production Deployment Tutorial
Take a code-review agent from laptop to production: pin the GitHub MCP server to the toolsets you need, receive signed pull request webhooks on Cloudflare Workers, and manage it all with Wrangler.
A production review agent has three parts: an event source (signed GitHub webhooks), a queue so bursts of pushes do not overload anything, and an agent worker that talks to the GitHub MCP server with a narrowly scoped token. This tutorial gives a working Cloudflare Worker webhook receiver with HMAC verification, the exact GitHub MCP configuration for read-only review, and the Wrangler steps to ship it.
Verified Capabilities Benchmarked in This Guide
Inspect Live JSON Feed ↗GitHub Official MCP — Repositories, Pull Requests, Actions & Code Search
Official GitHub MCP server for searching repositories, inspecting PR diffs and review comments, triaging issues, and reading GitHub Actions workflow runs.
Cloudflare Official MCP — Workers, D1, R2, KV & Observability
Official Cloudflare remote Streamable HTTP MCP server: inspect and manage Workers scripts, D1 SQLite databases, R2 buckets, KV namespaces, and production l
Wrangler CLI Deployment & Resource Management Playbook
Deterministic workflow for configuring `wrangler.jsonc`, provisioning D1/KV/R2 bindings, managing secrets, and running preview vs production deployments.
GitHub Actions Matrix Caching, OIDC & Fast CI Pipeline Skill
Cut GitHub Actions CI runtimes by 60%: configure pnpm/Cargo/Docker layer caching, concurrency cancel-in-progress groups, and keyless OIDC cloud deployments
GitLab Merge Requests, CI Pipelines & Issue Tracker MCP Server
Connect AI coding agents to GitLab self-hosted or cloud instances: inspect Merge Request diffs, debug failed GitLab CI jobs, and update issues.
Customer Bug Report to Failing Test & Verified Fix PR Pipeline
Watches the `#bug-reports` Slack channel, correlates stack traces in Sentry, writes a failing regression test, and opens a verified GitHub fix PR.
1. Architecture
Keep the parts separate so each can have its own credentials.
- GitHub sends pull_request webhooks to a Cloudflare Worker. The Worker verifies the HMAC signature and enqueues only the repo, PR number and head SHA.
- A queue consumer (your agent runtime) picks up jobs and connects to the GitHub MCP server.
- The agent reads the PR with read-only tools, drafts a pending review, and a human or a policy step decides whether it is submitted.
- Secrets live in Worker secrets and your agent runtime's secret store, never in the repo.
2. Choose how to run the GitHub MCP server
Both options are documented by GitHub. Remote is simplest; Docker gives you control over version and network egress.
| Option | Endpoint or command | Best for |
|---|---|---|
| Remote (hosted by GitHub) | https://api.githubcopilot.com/mcp/x/pull_requests/readonly | Fast start, no infrastructure, read-only by URL |
| Local Docker | docker run -i --rm -e GITHUB_PERSONAL_ACCESS_TOKEN ghcr.io/github/github-mcp-server | Pinned versions, private networks, GitHub Enterprise Server via GITHUB_HOST |
3. Scope the token
Use a fine-grained personal access token or a GitHub App installation token limited to the repositories the agent reviews. For read-only review you need read access to contents and pull requests; for posting reviews you also need write access to pull requests. Do not grant administration, workflows or secrets permissions to a review agent. GitHub's lockdown mode is a best-effort filter on content from untrusted contributors, not an authorization boundary, so token scope is still your main control.
4. The webhook receiver Worker
This Worker checks GitHub's X-Hub-Signature-256 header (an HMAC SHA-256 of the raw body using your webhook secret) with a constant-time comparison, ignores everything except relevant pull_request actions, and queues a minimal job. Note that only identifiers are forwarded; the PR title and body are re-read later through MCP and treated as untrusted data.
5. Ship it with Wrangler
Create the queue, set the secret, and deploy. The Wrangler playbook on LightState covers wrangler.jsonc bindings and preview deploys in more depth.
6. Operate it with the Cloudflare MCP server
Once deployed, connect your coding agent to Cloudflare's own MCP server so it can inspect the Worker, queues and logs while you debug. It is a remote server with OAuth; our probe on 25 Oct 2026 confirmed it answers with an auth challenge.
7. Production checklist
Run through this before turning the agent on for every repository.
- Webhook signature verified with a constant-time compare; unsigned requests rejected with 401.
- Queue in front of the agent; duplicate jobs for the same head SHA are skipped.
- Token limited to target repositories; no admin, workflow or secrets permissions.
- GitHub MCP toolsets limited to pull_requests and repos; read-only until reviews are approved for posting.
- PR text treated as untrusted data in the agent prompt.
- CI failures routed to a CI skill rather than guessed at (see the GitHub Actions CI skill).
Frequently Asked Questions
Should I self-host the GitHub MCP server or use the remote one?
Use the remote server at api.githubcopilot.com/mcp/ for the quickest start. Self-host with the official Docker image when you need pinned versions, private networking or GitHub Enterprise Server.
How do I verify GitHub webhooks on Cloudflare Workers?
Compute an HMAC SHA-256 of the raw request body with your webhook secret using crypto.subtle, prefix it with sha256=, and compare it to the X-Hub-Signature-256 header with crypto.subtle.timingSafeEqual.
What token permissions does a review agent need?
Read access to repository contents and pull requests for read-only review, plus write access to pull requests if it will post reviews. Nothing else.
Can I deploy the same setup for GitLab?
Yes in outline. GitLab sends merge request webhooks with an X-Gitlab-Token header you compare to a shared secret, and the agent connects to GitLab's built-in MCP server at /api/v4/mcp.