GitHub MCP Control Plane
Provides secure, controlled access to GitHub operations through the Model Context Protocol with enterprise-grade security features including secret detection, vulnerability scanning, rate limiting, and full audit trails. Supports repository management, file operations, branch creation, commits, and GitHub Actions workflows.
README
GitHub MCP Control Plane
A production-ready, enterprise-grade GitHub MCP (Model Context Protocol) server deployed on Cloudflare Workers with zero-idle cost, comprehensive security validation, and full audit trails.
Overview
This MCP server provides secure, controlled access to GitHub operations through the Model Context Protocol. It implements a stateless request/response model with enterprise-grade security features including:
- Multi-layer Security: Secret detection, vulnerability scanning, RBAC, and policy enforcement
- Full Audit Trail: Every action logged with correlation IDs for complete traceability
- Rate Limiting: Distributed rate limiting using Cloudflare KV
- Batch Operations: Handle 100+ files in a single commit
- Delegation: Heavy tasks delegated to GitHub Actions for optimal performance
- Idempotent Operations: Built-in retry logic with exponential backoff
Architecture
┌─────────────┐
│ Client │
└──────┬──────┘
│ MCP Request
▼
┌─────────────────────────────────────┐
│ Cloudflare Worker (Stateless) │
│ ┌───────────────────────────────┐ │
│ │ Entry Point & Routing │ │
│ └──────────────┬────────────────┘ │
│ ▼ │
│ ┌───────────────────────────────┐ │
│ │ Authentication & Authorization│ │
│ └──────────────┬────────────────┘ │
│ ▼ │
│ ┌───────────────────────────────┐ │
│ │ Validation Pipeline │ │
│ │ • Schema Validation │ │
│ │ • Security Scanning │ │
│ │ • Policy Enforcement │ │
│ │ • Dependency Checking │ │
│ └──────────────┬────────────────┘ │
│ ▼ │
│ ┌───────────────────────────────┐ │
│ │ Tool Execution │ │
│ │ • Read-Only Tools │ │
│ │ • Write-Controlled Tools │ │
│ │ • Workflow Tools │ │
│ └──────────────┬────────────────┘ │
│ ▼ │
│ ┌───────────────────────────────┐ │
│ │ Audit Logging & Response │ │
│ └──────────────┬────────────────┘ │
└─────────────────┼────────────────────┘
│
┌─────────┴─────────┐
▼ ▼
┌───────────────┐ ┌──────────────┐
│ GitHub API │ │ GitHub │
│ │ │ Actions │
└───────────────┘ └──────────────┘
Quick Start
Prerequisites
- Node.js 18+
- Wrangler CLI
- GitHub Personal Access Token with appropriate permissions
- Cloudflare account with Workers and KV enabled
Installation
# Install dependencies
npm install
# Configure Wrangler
wrangler login
# Set required secrets
wrangler secret put GITHUB_TOKEN
wrangler secret put GITHUB_WEBHOOK_SECRET
wrangler secret put JWT_SECRET
wrangler secret put ENCRYPTION_KEY
# Validate configuration
npm run validate-config
# Deploy to production
npm run deploy
Local Development
# Start local development server
npm run dev
# The worker will be available at http://localhost:8787
Configuration
Environment Variables
See .env.example for all available configuration options.
Tool Manifest
Configure available tools in src/config/tools-manifest.json:
{
"tools": [
{
"name": "list_repositories",
"category": "read-only",
"description": "List repositories accessible to the authenticated user",
"requiredPermissions": ["read:org", "repo"]
}
]
}
Policy Rules
Define authorization policies in src/config/policy-rules.json:
{
"policies": [
{
"name": "write-restrictions",
"tools": ["create_branch", "create_commit"],
"conditions": {
"repository": {
"allowedPatterns": ["*"],
"blockedPatterns": ["protected-*"]
},
"branch": {
"blockedPatterns": ["main", "master", "production"]
}
}
}
]
}
Security Features
1. Authentication
- JWT token validation
- GitHub permission verification
- Token expiration handling
2. Authorization
- RBAC with fine-grained permissions
- Repository-level access control
- Branch protection rules
3. Validation
- JSON schema validation for all requests
- Secret detection (regex + entropy analysis)
- Dependency vulnerability checking via OSV.dev
- Code policy enforcement
4. Rate Limiting
- Distributed rate limiting with Cloudflare KV
- Configurable windows and thresholds
- Per-client rate tracking
5. Audit Trail
- Every action logged with correlation ID
- Structured JSON logging
- Configurable retention period
Available Tools
Read-Only Tools
list_repositories- List accessible repositoriesfetch_file- Fetch file contents from a repositorylist_files- List files in a directoryget_repository_info- Get repository metadata
Write-Controlled Tools
create_branch- Create a new branchcreate_commit- Create commits with file changesbatch_create_commits- Handle 100+ files in batch operations
Workflow Tools
trigger_workflow- Trigger GitHub Actions workflowsget_workflow_status- Check workflow execution statusget_workflow_logs- Fetch workflow execution logs
API Reference
See docs/API.md for detailed API documentation.
Deployment
Production Deployment
# Deploy to production
npm run deploy
# Deploy to staging
wrangler deploy --env staging
GitHub Actions Integration
For long-running tasks, the worker delegates to GitHub Actions. Configure:
- Add workflow file to your repository (
.github/workflows/execution-handler.yml) - Set
GITHUB_WEBHOOK_SECRETin your repository settings - Configure the worker URL in workflow dispatch
See docs/DEPLOYMENT.md for complete deployment guide.
Monitoring
Health Check
curl https://your-worker-url.workers.dev/health
Expected response:
{
"status": "healthy",
"timestamp": "2024-01-01T00:00:00Z",
"version": "1.0.0"
}
Logs
All logs are emitted in structured JSON format:
{
"level": "info",
"message": "Request received",
"correlationId": "abc-123",
"tool": "list_repositories",
"userId": "user-123",
"timestamp": "2024-01-01T00:00:00Z"
}
Testing
# Run all tests
npm test
# Run tests with coverage
npm run test:coverage
# Run specific test file
npx vitest tests/unit/auth.test.js
Error Handling
All errors follow a consistent format:
{
"error": {
"code": "VALIDATION_ERROR",
"message": "Invalid request payload",
"details": [
{
"field": "repository",
"message": "Repository name is required"
}
],
"correlationId": "abc-123"
}
}
Security Considerations
- Never commit secrets - Use Wrangler secrets for all sensitive data
- Use principle of least privilege - GitHub tokens should have minimal required permissions
- Enable audit logging - Track all operations for compliance
- Regular secret rotation - Rotate JWT and encryption keys regularly
- Monitor rate limits - Set appropriate thresholds to prevent abuse
Troubleshooting
Common Issues
Worker returns 401 Unauthorized
- Check GITHUB_TOKEN is set correctly
- Verify token has required permissions
- Check token hasn't expired
Rate limit errors
- Review rate limiting configuration
- Check KV namespace is properly configured
- Monitor usage patterns
Validation failures
- Review validation logs for specific errors
- Check schema definitions in tools-manifest.json
- Verify secret patterns in secret-patterns.json
Contributing
Contributions are welcome! Please ensure:
- All tests pass
- Code follows existing patterns and style
- New features include tests
- Documentation is updated
License
MIT License - see LICENSE file for details
Support
For issues and questions:
- GitHub Issues: [repository-url]/issues
- Documentation: docs/
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。