GitHub PR MCP Server
# GitHub PR MCP Server
Un servidor MCP (Model Context Protocol) mínimo para interactuar con Pull Requests de GitHub. Está pensado como ejemplo didáctico para entender cómo crear un MCP server desde cero.
## Qué hace
Expone 6 herramientas:
- `list_pull_requests` — Lista los PRs de un repositorio.
- `get_pull_request` — Muestra el detalle de un PR.
- `list_pull_request_comments` — Lista los comentarios de un PR.
- `create_pull_request_comment` — Publica un comentario en un PR.
- `create_pull_request_review` — Aprueba, pide cambios o comenta un PR.
- `merge_pull_request` — Mergea un PR.
## Requisitos
- Node.js 20 o superior
- Un token de GitHub con permisos para leer/escribir PRs (repo o repo:read + repo:write según la operación)
## Instalación
```bash
npm install
```
## Configuración
Exporta tu token de GitHub:
```bash
export GITHUB_TOKEN="ghp_xxxxxxxxxxxxxxxxxxxx"
```
## Ejecución
```bash
npm run dev
```
> **Importante:** el servidor usa `stdio` como transporte MCP. No escribe nada a `stdout` excepto el protocolo; los logs van a `stderr`.
## Probar con MCP Inspector
El inspector te permite probar las herramientas sin necesidad de un host como Claude o Cursor:
```bash
npm run inspect
```
Luego abre la URL que indica, conecta el servidor y prueba las tools.
## Configurar en un host MCP
Añade esto a tu cliente MCP (Claude Code, Cursor, VS Code, etc.):
```json
{
"mcpServers": {
"github-pr": {
"command": "npx",
"args": ["tsx", "/ruta/al/proyecto/src/index.ts"],
"env": {
"GITHUB_TOKEN": "ghp_xxxxxxxxxxxxxxxxxxxx"
}
}
}
}
```
## Estructura del proyecto
```
.
├── src/
│ └── index.ts # Todo el servidor
├── package.json
├── tsconfig.json
└── README.md
```
## Notas para un video tutorial
- El archivo `src/index.ts` es autónomo: configura el cliente de GitHub, define los schemas con Zod, registra las tools y arranca el transporte stdio.
- El SDK de MCP valida los argumentos automáticamente con los schemas; si falla, la tool no se ejecuta.
- Para demostraciones, usa un repo de prueba y un PR que no importe romper.
TDQS
Scored across 6 tools
Each tool performs a distinct action on pull requests: listing, retrieving, commenting, reviewing, and merging. There is no overlap in purpose, making it easy for an agent to select the correct tool.
All tool names follow a consistent verb_noun pattern (list_pull_requests, get_pull_request, create_pull_request_comment, merge_pull_request). The naming is uniform and predictable, with only minor singular/plural variations that are appropriate.
With 6 tools, the server is well-scoped for a PR-focused MCP server. Each tool covers a core PR interaction without unnecessary bloat or redundancy.
The tool surface covers the main PR lifecycle: list, get, comment, review, and merge. Minor gaps like updating a PR title/body or listing reviews exist, but agents can typically work around them, and the core workflows are well covered.