Skip to main content
Glama
punyprogrammer

GitHub PR Analyzer MCP Server

README.md
# GitHub PR Analyzer MCP Server

MCP server that fetches GitHub pull request details and saves reviews to Notion. Built with FastMCP (stdio transport) for clients like Claude Desktop.

## Tools

| Tool | Description |
|------|-------------|
| `fetch_pr_changes` | Fetch PR metadata and file changes from GitHub |
| `create_notion_page` | Create a child page under a shared Notion parent page |

## Setup

```bash
cd pr_reviewer
python -m venv .venv
source .venv/bin/activate   # Windows: .venv\Scripts\activate
pip install -r requirements.txt
```

Or with `uv`:

```bash
uv venv && source .venv/bin/activate
uv pip install -r requirements.txt
```

## Environment

Copy `.env` (do not commit secrets):

```env
GITHUB_TOKEN=ghp_your_github_pat
NOTION_API_KEY=ntn_your_notion_integration_secret
NOTION_PAGE_ID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
```

| Variable | Notes |
|----------|--------|
| `GITHUB_TOKEN` | GitHub PAT with access to the repos you want to review |
| `NOTION_API_KEY` | Internal integration secret from [Notion integrations](https://www.notion.so/my-integrations) |
| `NOTION_PAGE_ID` | Parent page UUID (or page URL). New reviews are created under this page |

### Notion: share the page

The parent page **must** be connected to your integration:

1. Open the parent page in Notion  
2. `···` → **Connect to** / **Add connections**  
3. Select your integration (e.g. `PR Review Server Demo`)

Without this, Notion returns “Could not find page… shared with your integration”.

## Run locally

```bash
python pr_analyzer.py
```

This starts an stdio MCP server and waits for a client. Prefer launching it from Claude Desktop rather than testing alone in a terminal.

## Claude Desktop config

Add to `~/Library/Application Support/Claude/claude_desktop_config.json` (macOS):

```json
{
  "mcpServers": {
    "github_pr_analyzer": {
      "command": "/ABS/PATH/TO/pr_reviewer/.venv/bin/python",
      "args": ["/ABS/PATH/TO/pr_reviewer/pr_analyzer.py"],
      "cwd": "/ABS/PATH/TO/pr_reviewer"
    }
  }
}
```

Quit Claude completely (`Cmd+Q`) and reopen after editing.

## Example prompt

```text
Use github_pr_analyzer:
1) fetch_pr_changes for owner / repo / PR number
2) create_notion_page with a short title and the review summary
```

## Logs

```bash
tail -f ~/Library/Logs/Claude/mcp-server-github_pr_analyzer.log
```

## Project layout

```text
pr_reviewer/
├── pr_analyzer.py         # MCP server + tools
├── github_integration.py  # GitHub API helper
├── requirements.txt
├── .env                   # secrets (gitignored)
└── README.md
```

## Notes

- Notion paragraph text is limited to 2000 characters; long content is split into multiple blocks.
- Keep `.env` and `.venv` out of git (see `.gitignore`).