使用说明
MCP GITHUB企业版🌉
一个模型上下文协议(MCP)服务器,允许AI代理(Claude、ChatGPT等)查询您的GitHub Enterprise许可证数据。通过以下方式安全地获取许可证摘要、每个用户的详细信息、组织成员资格和企业角色 /consumed-licenses 终点。
📊 能力和示例提示
-
许可证摘要
•"Show me our GitHub Enterprise license summary"
•"How many licenses are we currently using?" -
详细的许可证使用情况
•"List all consumed GitHub licenses"
•"Do we have any unused GitHub licenses?" -
用户查找
•"What GitHub orgs does johndoe belong to?"
•"What enterprise roles does johndoe have?"
•"Is johndoe an owner in our enterprise?"
•"Get detailed info about johndoe"
•"Does johndoe have 2FA enabled?"
🌟 特性
- 许可证分析:总座位数与消耗座位数
- 用户查找:组织成员资格、角色、2FA、SAML ID
- 分页:自动处理大型企业
- 双重运输:stdio用于直接MCP,SSE用于HTTP
- Kubernetes就绪:部署在EKS/GKE或任何K8s集群上
📋 先决条件
- Python 3.9+
- GitHub PAT
read:enterprise/许可证范围 - GitHub企业云租户
🚀 快速开始
1.克隆和安装
git clone https://github.com/vipink1203/mcp-github-enterprise.git
cd mcp-github-enterprise
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
2.配置
cp .env.example .env
# Edit .env: set GITHUB_TOKEN and GITHUB_ENTERPRISE_URL
3.跑步
stdio传输
export TRANSPORT=stdio
python main.py
SSE 运输
export TRANSPORT=sse PORT=8050
python main.py
🐳 Docker和n8n
将此服务与n8n一起添加到您的docker-compose.yml中:
services:
github-mcp:
image: ghcr.io/vipink1203/mcp-github-enterprise:latest
environment:
- GITHUB_TOKEN=${GITHUB_TOKEN}
- GITHUB_ENTERPRISE_URL=${GITHUB_ENTERPRISE_URL}
- TRANSPORT=sse
- PORT=8050
ports:
- "8050:8050"
restart: unless-stopped
networks:
- n8n-network
在n8n的用户界面中,启用MCP客户端:
- 设置→ 凭证→ 新建凭据
- 选择MCP客户端API,将URL设置为http://github-mcp:8050/sse
🔌 客户端配置
克劳德桌面/风帆/光标
将此配置添加到您的Claude Desktop设置中:
{
"mcpServers": {
"github-ent": {
"command": "/path/to/your/venv/python",
"args": ["/path/to/main.py"],
"env": {
"GITHUB_TOKEN": "",
"GITHUB_ENTERPRISE_URL": "https://api.github.com/enterprises/{enterprise_name}",
"TRANSPORT": "stdio"
}
}
}
SSE配置
{
"mcpServers": {
"github": {
"transport": "sse",
"url": "http://localhost:8050/sse"
}
}
}
📊 示例用例
- 企业用户管理:自动化用户入职和离职
- 许可证监控:许可证接近到期时收到警报
- 组织分析:分析组织结构和关系
- 用户访问审核:跟踪用户权限和访问级别
- 人工智能驱动的GitHub Insights:让AI分析您的企业GitHub数据
🔌 MCP工具和资源
工具
| 名称 | 描述 |
|---|---|
list_consumed_licenses |
总结许可证,可选择包括用户 |
get_user_organizations |
列出用户的GitHub组织成员资格 |
get_user_enterprise_roles |
列出用户的企业角色 |
get_user_detail |
用户的完整许可证详细信息 |
资源
| URI | 描述 |
|---|---|
github://consumed-licenses/{dummy} |
完整许可证使用+用户详细信息 |
github://user/{username}/roles |
用户的组织和企业角色 |
🔒 安全考虑
- 安全地存储您的GitHub令牌
- 为您的GitHub令牌使用适当的范围
- 对于生产,考虑使用AWS Secrets Manager或类似工具
- 在Kubernetes部署中实施网络策略
🤝 贡献
欢迎投稿!请随时提交拉取请求。
- 分叉存储库
- 创建功能分支(
git checkout -b feature/amazing-feature) - 提交您的更改(
git commit -m 'Add some amazing feature') - 推到分支(
git push origin feature/amazing-feature) - 打开拉取请求
📜 许可证
此项目根据MIT许可证获得许可-请参阅 许可证 文件以获取详细信息。
🙏 致谢
- 模型上下文协议 Python SDK
- MCP-Mem0 用于提供出色的模板结构
- GitHub API API综合
内置于❤️ 无缝AI↔️ GitHub企业集成。
