使用说明
MCP开发工具服务器
一个MCP(Model Context Protocol)服务器,集成了GitHub和Gitlab,在Node.js中实现,并在AWS Lambda中部署了TypeScript。
特点
- ✅ 完整的TypeScript配置
- ✅ MCP官方SDK
- ✅ 与GitHub的集成 (API REST)
- ✅ GitHub上的Herramientas(仓库、问题、PR、提交)
- ✅ 基本工具(Echo,Get_Time)
- ✅ 开发和生产脚本
- ✅ 热重载节点
- ✅ 错误处理
🚀 部署到AWS Lambda
安装
npm install
配置
- 配置器AWS CLI:
aws configure
- 配置环境变量:
export GITHUB_TOKEN="tu_token_de_github"
export GITLAB_TOKEN="tu_token_de_gitlab" # Opcional
export GITLAB_HOST="https://gitlab.com"
- 部署:
# Opción 1: Script automático
./deploy.sh
# Opción 2: Manual
npm run lambda:build
npm run lambda:deploy
地方发展
# Modo desarrollo con hot reload
npm run dev
# Probar Lambda localmente
npm run lambda:offline
# Compilar TypeScript
npm run build
可用的工具
基本工具
回声
他呼应了传递给他的信息。
参数:
message(字符串):要回音的消息
获取时间
获取当前日期和时间。
参数: 无
基本工具
回声
他呼应了传递给他的信息。
参数:
message(字符串):要回音的消息
示例:
{
"name": "echo",
"arguments": {
"message": "¡Hola desde Cursor!"
}
}
获取时间
获取当前日期和时间。
参数: 无
GitHub工具
github _用户
获取经过验证的GitHub用户的信息。
参数: 无
github _仓库
获取经过身份验证的用户的存储库。
参数: 无
github _ getrepo
从特定存储库获取信息。
参数:
owner(字符串):存储库所有者repo(字符串):存储库名称
github _ _问题
获取存储库中的问题。
参数:
owner(字符串):存储库所有者repo(字符串):存储库名称state(字符串,可选):问题状态(打开,关闭,全部)
github创建问题
在存储库中创建新问题。
参数:
owner(字符串):存储库所有者repo(字符串):存储库名称title(字符串):问题的标题body(字符串,可选):问题描述labels(数组,可选):问题的标签
github_get_pull_requests
从存储库中获取拉动请求。
参数:
owner(字符串):存储库所有者repo(字符串):存储库名称state(字符串,可选):PRS状态(打开,关闭,全部)
github创建包请求
创建新的拉动请求。
参数:
owner(字符串):存储库所有者repo(字符串):存储库名称title(字符串):拉动请求的标题head(字符串):源分支base(字符串):目标分支body(字符串,可选):拉动请求的描述
github _提交
获取存储库的提交。
参数:
owner(字符串):存储库所有者repo(字符串):存储库名称branch(字符串,可选):存储库分支(默认:main)
github _文件_内容
获取存储库中文件的内容。
参数:
owner(字符串):存储库所有者repo(字符串):存储库名称path(字符串):文件路径branch(字符串,可选):存储库分支(默认:main)
github搜索返回
在GitHub中搜索存储库。
参数:
query(字符串):搜索查询sort(字符串,可选):排序标准(Stars,Forks,Updated)
github _发布
获取存储库的发布。
参数:
owner(字符串):存储库所有者repo(字符串):存储库名称
github_get_report_stats
从存储库中获取统计信息。
参数:
owner(字符串):存储库所有者repo(字符串):存储库名称
github _用户_用户名
按用户名获取特定用户的信息。
参数:
username(字符串):GitHub用户名
github_get_user_repos
获取特定用户的存储库。
参数:
username(字符串):GitHub用户名
项目结构
src/
index.ts # Servidor MCP principal
github.ts # Integración con GitHub
dist/ # Código compilado (generado automáticamente)
tsconfig.json # Configuración de TypeScript
package.json # Dependencias y scripts
github-config.example # Guía de configuración de GitHub
使用
该MCP服务器可由实现MCP协议的客户机使用,以访问定义的工具。
MCP客户端配置示例
要将此服务器与MCP客户端一起使用,请添加以下设置:
{
"mcpServers": {
"mcp-github-server": {
"command": "node",
"args": ["/ruta/completa/a/tu/proyecto/dist/index.js"],
"env": {
"GITHUB_TOKEN": "ghp_tu_token_aqui"
}
}
}
}
可用命令
# Desarrollo con hot reload
npm run dev
# Compilar el proyecto
npm run build
# Ejecutar versión compilada
npm start
# Limpiar archivos compilados
npm run clean
项目结构
mcp-github-server/
├── src/
│ ├── index.ts # Servidor MCP principal
│ └── github.ts # Integración con GitHub
├── dist/ # Código compilado (generado)
├── package.json # Dependencias y scripts
├── tsconfig.json # Configuración TypeScript
├── nodemon.json # Configuración desarrollo
├── github-config.example # Guía de configuración
└── README.md # Este archivo
下一步
- 添加更多GitHub工具:扩展数组
tools英语src/index.ts - 实施资源:添加处理程序
ListResourcesRequestSchemayReadResourceRequestSchema - 添加提示:Implementa
ListPromptsRequestSchemayGetPromptRequestSchema - 配置程序日志记录:添加更强大的日志系统
- 测试:使用JEST或类似工具实现单元测试
- 整合更多服务:GitLab、Bitbucket、Jira、Slack等。
