Content
# mcp-github-server
A self-hosted GitHub MCP (Model Context Protocol) server you deploy to your own Vercel project. Connects to Claude.ai as a custom connector — no more pasting tokens in chat.
## Why
Claude.ai has MCP connectors for Supabase and Vercel. GitHub doesn't have one for the web interface. This fills that gap.
Your GitHub PAT lives in a Vercel environment variable. The MCP server reads it at runtime. Claude.ai connects to the server as a custom connector. You never paste a token in chat again.
## What You Get
Six tools available to Claude:
| Tool | Description |
|------|-------------|
| `git_read` | Read a file or list a directory |
| `git_push` | Create or update a file with a commit |
| `git_push_multi` | Commit multiple files atomically |
| `git_log` | Recent commit history |
| `git_list_branches` | List all branches |
| `git_create_branch` | Create a branch from any ref |
## Setup (5 minutes)
### 1. Install dependencies
In your existing Next.js project on Vercel:
```bash
npm install mcp-handler @octokit/rest zod
```
### 2. Add the route
Copy `src/app/api/mcp/[transport]/route.ts` from this repo into your project at the same path.
Edit the `committer` object in `git_push` and `git_push_multi` to use your git identity:
```typescript
committer: {
name: "your-github-username",
email: "your-username@users.noreply.github.com",
},
```
### 3. Make the route public
If your app has auth middleware or a proxy that protects routes, add `/api/mcp` to the public/unauthenticated paths. The MCP transport handles its own connection model — it doesn't need your app's auth.
Example for a Next.js middleware:
```typescript
// In your middleware or proxy config
const publicPaths = ["/api/mcp"];
```
### 4. Add your GitHub PAT to Vercel
In your Vercel project settings → Environment Variables:
- **Key:** `GITHUB_PAT`
- **Value:** Your fine-grained GitHub PAT with repo access
- **Environments:** Production, Preview, Development
The PAT never touches your code.
### 5. Deploy
Push the code. Vercel deploys.
### 6. Connect to Claude.ai
Settings → Connectors → Add custom connector:
```
https://yourdomain.com/api/mcp/mcp
```
The double `/mcp` is intentional — first segment is the route path, second is the MCP transport endpoint.
Done. Claude can now read, write, branch, and view history across all repos your PAT has access to.
## Credential Rotation
When you need to rotate the PAT:
1. Create a new PAT on GitHub
2. Update the `GITHUB_PAT` env var in Vercel
3. Redeploy (or wait for next deploy)
No code changes. No chat exposure. No ceremony.
## Supabase Edge Functions
This pattern should also work with Supabase Edge Functions (Deno runtime) using the same `mcp-handler` package, though this hasn't been tested. The core approach is identical — read credentials from environment variables, expose tools via MCP, deploy to your existing infrastructure.
## How It Works
The server uses [`mcp-handler`](https://www.npmjs.com/package/mcp-handler) to bridge the MCP protocol to a Next.js API route, and [`@octokit/rest`](https://github.com/octokit/rest.js) for GitHub API calls. Each tool is a thin wrapper: validate input with Zod, call Octokit, return the result.
The server is stateless. It reads `GITHUB_PAT` from `process.env` on every request. It costs nothing beyond your existing Vercel hosting.
## The Pattern
This isn't just a GitHub connector — it's a pattern. Any service with an API and an SDK can become an MCP server in under 100 lines:
1. Install `mcp-handler` + the service's SDK
2. Create the catch-all route at `api/mcp/[transport]/route.ts`
3. Define tools with Zod schemas that delegate to the SDK
4. Store the credential as an env var
5. Deploy and connect
## License
MIT
Connection Info
You Might Also Like
everything-claude-code
Complete Claude Code configuration collection - agents, skills, hooks,...
markitdown
MarkItDown-MCP is a lightweight server for converting URIs to Markdown.
cc-switch
All-in-One Assistant for Claude Code, Codex & Gemini CLI across platforms.
servers
Model Context Protocol Servers
servers
Model Context Protocol Servers
Time
A Model Context Protocol server for time and timezone conversions.