MCP起动器-灵活配置系统
一种具有混合3级优先级配置系统的模块化模型上下文协议(MCP)启动器。通过动态工具过滤和灵活的配置管理,为任何API集成(REST、Odoo、Salesforce、定制API)构建可扩展的MCP服务器。
🎯 主要特点
- 三级优先级配置 -标题→ 环境变量→ 默认值
- 动态工具过滤 -通过以下方式根据请求控制可用工具
to-use头球 - REST API客户端 -内置客户端,具有身份验证、重试和错误处理功能
- 模块化架构 -易于扩展和维护
- 生产就绪 -Cloudflare Workers已优化
🚀 快速开始
# Install and run
npm install
npm run type-check
npm run dev # Local development
npm run deploy # Production deployment💡 基本用法
简单请求(使用默认值)
curl http://localhost:8787/mcp按请求配置(标头)
curl -H "api-url: https://api.example.com" \
-H "api-token: your-token" \
-H "to-use: [\"health_check\", \"api_get\"]" \
http://localhost:8787/mcp健康检查
curl -X POST http://localhost:8787/mcp \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "health_check",
"arguments": {"includeConfig": true}
}
}'🏗️ 配置优先
系统使用3级优先级系统自动解析配置:
- 标头 (最高)-通过HTTP标头的每个请求
- 环境 (中)-设置在wrangler.toml或仪表板中
- 默认值 (最低)-硬编码回退
例子:
# Environment: API_URL=https://env-api.com
# Headers override: api-url=https://header-api.com
# Result: Uses https://header-api.com📁 项目结构
src/
├── config/ # 3-level priority configuration
├── tools/ # Tool registry and filtering
├── clients/ # REST API client with auth
├── utils/ # Logging and error handling
├── mcp.ts # MCP agent implementation
└── index.ts # Entry point🔧 延长起动机
添加新工具
- 在中创建工具
src/tools/examples/ - 出口自
src/tools/examples/index.ts - 使用
to-use用于控制可用性的标头
添加新客户
- 扩展
RestApiClient在……里面src/clients/ - 映射构造函数中的配置字段
- 在工具处理程序中使用
自定义配置
通过标头或环境添加任何配置字段:
curl -H "custom-field: value" /mcp
# OR
CUSTOM_FIELD=value npm run deploy🧪 测试与开发
# Local testing
npm run dev
curl http://localhost:8787/mcp
# Test with configuration
curl -H "api-url: https://jsonplaceholder.typicode.com" \
-H "to-use: [\"health_check\"]" \
http://localhost:8787/mcp
# Type checking
npm run type-check🚀 部署
# Configure environment in wrangler.toml
[vars]
API_URL = "https://your-api.com"
API_TOKEN = "your-token"
# Deploy
npm run deploy📚 文档
- 实施指南 -完整的设置和开发指南
- 内置工具 -计算器、健康检查、API工具
- 配置示例 -REST、Odoo、Salesforce集成
- 工具开发 -逐步创建工具
🤝 贡献
- 分叉存储库
- 创建特征分支(
git checkout -b feature/name) - 遵循现有模式并运行
npm run type-check - 提交拉取请求
📄 许可证
MIT许可证-有关详细信息,请参阅许可证文件。
