Get the GitHub MCP Server running in 5 minutes.
- Node.js 18 or higher
- GitHub Personal Access Token
# Install dependencies
npm install
# Build project
npm run build-
Create a GitHub Personal Access Token:
- Go to https://github.com/settings/tokens
- Click "Generate new token (classic)"
- Select scopes:
repo(andread:orgfor organization repos) - Copy the token
-
Set the environment variable:
export GITHUB_TOKEN="ghp_your_token_here"
Start the MCP server locally:
npm run devThe server is now running and listening on stdio for MCP protocol requests.
In a new terminal:
export GITHUB_TOKEN="ghp_your_token_here"
npm run clientYou should see:
- ✅ Connection confirmation
- 📋 List of 9 available tools
- 📦 Example PR listing
- 📝 Example PR details
- 🔧 Tool schema information
Add to your Cursor MCP settings:
{
"mcpServers": {
"github": {
"command": "node",
"args": ["/absolute/path/to/mcp-deployable/dist/server/index.js"],
"env": {
"GITHUB_TOKEN": "ghp_your_token_here"
}
}
}
}Then restart Cursor and ask:
"List the open PRs in my repository"
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
import { StdioClientTransport } from '@modelcontextprotocol/sdk/client/stdio.js';
import OpenAI from 'openai';
// Connect to MCP server
const client = new Client(
{ name: 'openai-github', version: '1.0.0' },
{ capabilities: {} }
);
const transport = new StdioClientTransport({
command: 'node',
args: ['dist/server/index.js'],
env: { GITHUB_TOKEN: process.env.GITHUB_TOKEN } as Record<string, string>,
});
await client.connect(transport);
// Get tools for OpenAI
const { tools } = await client.listTools();
// Use with OpenAI
const openai = new OpenAI();
const response = await openai.chat.completions.create({
model: 'gpt-4',
messages: [{ role: 'user', content: 'List open PRs in owner/repo' }],
tools: tools.map(tool => ({
type: 'function',
function: {
name: tool.name,
description: tool.description,
parameters: tool.inputSchema,
},
})),
});
// Execute tool if requested
if (response.choices[0].message.tool_calls) {
const toolCall = response.choices[0].message.tool_calls[0];
const result = await client.callTool({
name: toolCall.function.name,
arguments: JSON.parse(toolCall.function.arguments),
});
console.log(result);
}# Install Wrangler globally
npm install -g wrangler
# Login to Cloudflare
wrangler login
# Set GitHub token as secret
wrangler secret put GITHUB_TOKEN
# Deploy
npm run deployYour MCP server is now live at:
https://github-mcp-server.your-subdomain.workers.dev
curl -X POST https://your-worker.workers.dev/invoke \
-H "Content-Type: application/json" \
-d '{
"tool": "list_prs",
"arguments": {
"owner": "modelcontextprotocol",
"repo": "typescript-sdk",
"state": "open"
}
}'curl -X POST https://your-worker.workers.dev/invoke \
-H "Content-Type: application/json" \
-d '{
"tool": "get_pr",
"arguments": {
"owner": "modelcontextprotocol",
"repo": "typescript-sdk",
"pull_number": 1
}
}'- Read README.md for full documentation
- Check EXAMPLES.md for more usage examples
- Review DEPLOYMENT.md for production deployment
- Explore ARCHITECTURE.md to understand the design
Make sure you've exported the token:
export GITHUB_TOKEN="ghp_your_token_here"Your token needs the repo scope. Create a new token with proper permissions.
Ensure all dependencies are installed:
npm install
npm run build
npm test- Use absolute paths in the configuration
- Verify the build completed: check
dist/server/index.jsexists - Check Cursor's MCP logs for error messages
- GitHub Issues: Report bugs or request features
- MCP Protocol: https://modelcontextprotocol.io
- GitHub API: https://docs.github.com/rest