上下文感知mcp
一种可配置的MCP(模型上下文协议)服务器,具有跨微服务的智能API路由。用JSON定义您的服务,服务器会自动将自然语言查询路由到正确的端点。
快速开始
# Initialize config with a template
npx context-aware-mcp init --template openstore
# Or start with a blank config
npx context-aware-mcp init安装
npm install -g context-aware-mcp或直接与 npx:
npx context-aware-mcp CLI命令
| 命令 | 描述 |
|---|---|
init | 创建新 mcp-config.json (空白或来自模板) |
add-service | 向配置中添加服务 |
add-env | 向服务添加环境URL |
set-swagger | 为服务设置招摇路径 |
remove-service | 删除服务 |
remove-env | 从服务中删除环境 |
list | 列出已配置的服务 |
validate | 验证 mcp-config.json |
build | 编译TypeScript |
install | 为Claude代码或VS代码生成MCP配置 |
所有配置命令都支持 --flags 模式和交互模式(运行时没有提示标志)。
配置格式
服务定义见 mcp-config.json:
{
"$schema": "./mcp-config.schema.json",
"version": "1.0",
"defaults": { "environment": "qa", "swaggerPath": "/api/docs-json" },
"services": {
"my-service": {
"keywords": ["order", "checkout"],
"idPrefixes": ["ordr_"],
"type": "rest",
"environments": {
"qa": { "url": "https://qa-my-service.example.com" },
"local": { "url": "http://localhost:3001" }
}
}
},
"environmentKeywords": {
"qa": ["from qa", "in qa"],
"local": ["locally", "from local"]
}
}MCP集成
生成克劳德代码或VS代码配置:
# Project-level Claude Code config (.mcp.json)
npx context-aware-mcp install
# VS Code config (.vscode/mcp.json)
npx context-aware-mcp install --target vscode
# Both
npx context-aware-mcp install --target allMCP工具
服务器将这些工具暴露给AI助手:
- smart_api_call --基于自然语言查询的智能路由
- fetch_swagger --获取并缓存OpenAPI规范
- call_api -将API直接调用到服务端点
- list_services --列出可用服务
- 卡夫卡小说主题 / 卡夫卡主题 / kafka_read_消息 / 卡夫卡消费群体 --Kafka操作
发展
npm install
npm run build
npm test看 贡献.md 了解详情。
许可证
麻省理工学院
