MCP编码顾问
高级开发人员升级MCP服务器,提供故障排除和实施指导。
概述
此MCP服务器公开了一个 advise 编程代理(如Kilo Code)可以调用该工具来获得高级工程师的指导。它在需要时通过技能查找、Context7文档和网络搜索丰富了请求,然后通过APIPie.ai调用Claude以生成结构化响应。
特性
- 两种模式:排除错误或获取新功能的实施计划
- 浓缩管道:平行技能查找和Context7文档搜索
- 智能回退:未找到丰富数据时的网络搜索增强
- 结构化输出:两种模式的标记格式一致
- 生产就绪:强大的错误处理、超时和记录到stderr
安装
npm install发展
# Run in development mode (uses tsx)
npm run dev
# Type check
npm run type-check
# Build for production
npm run build
# Run built version
npm start配置
环境变量
创建一个 .env 文件(用于开发)或在MCP服务器配置中设置这些:
# Required
APIPIE_API_KEY=your-apipie-key-here
# Optional
APIPIE_MODEL=claude-sonnet-4-5 # or any APIPie-supported model
CONTEXT7_API_KEY=your-context7-key-here # for higher rate limits千码MCP配置
将以下内容添加到您的Kilo Code MCP设置文件中:
Linux: ~/.config/Code/User/globalStorage/kilocode.kilo-code/settings/mcp_settings.json macOS: ~/Library/Application Support/Code/User/globalStorage/kilocode.kilo-code/settings/mcp_settings.json 窗户: %APPDATA%\Code\User\globalStorage\kilocode.kilo-code\settings\mcp_settings.json
{
"mcpServers": {
"coding-advisor": {
"command": "npx",
"args": ["tsx", "/home/kilroy/build/escalate_mcp/src/index.ts"],
"env": {
"APIPIE_API_KEY": "your-apipie-key-here",
"CONTEXT7_API_KEY": "your-context7-key-here"
}
}
}
}重要:使用项目目录的绝对路径。上述示例假设项目位于 /home/kilroy/build/escalate_mcp.用法
代理人打电话给 advise 带有JSON字符串有效载荷的工具。支持两种模式:
故障排除模式
{
"mode": "troubleshoot",
"tech": "nestjs",
"task": "JWT guard blocking WebSocket connections",
"errorOutput": "UnauthorizedException: Unauthorized...",
"failedAttempts": [
{
"description": "Added @UseGuards(JwtAuthGuard) to gateway class",
"outcome": "All connections rejected immediately"
}
],
"codeSnippets": [
{
"filename": "chat.gateway.ts",
"code": "@UseGuards(JwtAuthGuard)\n@WebSocketGateway()\nexport class ChatGateway {}"
}
]
}实施方式
{
"mode": "implement",
"tech": "react",
"featureDescription": "Add dark mode toggle to the header",
"filesTouched": [
{
"path": "src/components/Header.tsx",
"relevantContent": "export default function Header() {\n return (\n \n
My App
\n \n );\n}"
}
],
"constraints": "Must use existing theme context, no new dependencies"
}响应格式
模式响应故障排除
- 问题:一个明确的句子来命名问题
- 为什么之前的尝试失败了:解释为什么每次失败的尝试都不起作用
- 根本原因:具体的实际技术原因
- 解决方案:逐步修复,无绒毛
- 示例:显示修复的最小目标代码片段
- 小心:问题、后续问题、修复后需要验证的事项
实施模式响应
- 概述:关于方法和原因的2-3句话
- 要修改的文件:带文件、更改、原因的Markdown表
- 实施步骤:按实施顺序编号
- 关键代码模式:关键接口、函数签名或棘手的逻辑
- 整合点:此功能如何连接到现有系统
- 风险/注意:特定于此代码库或堆栈的Gotchas
建筑
服务器遵循干净的管道:
- 输入验证:JSON有效负载的Zod模式验证
- 富集:平行技能查找(通过
npx skills find)和Context7文档搜索 - 快速建筑:具有丰富数据的系统提示组装,具有结构化格式要求的用户消息
- LLM电话:带有可选web搜索前缀的APIPie.ai调用
- 响应组件:元数据标头+LLM响应
错误处理
- 架构验证错误会返回明确的消息,以便代理进行自我更正
- 技能和上下文7失败会优雅地降级(视为
found: false) - LLM调用失败返回
isError: true带有描述性信息 - 所有意外错误都会被捕获并记录到stderr
项目结构
src/
index.ts # MCP server entrypoint, tool registration, orchestration
schema.ts # Zod schemas for both request modes
prompt-builder.ts # System prompt + user message assembly
skills.ts # npx skills find subprocess runner
context7.ts # Context7 REST API client
llm.ts # APIPie.ai call (OpenAI-compatible)依赖项
@modelcontextprotocol/sdk:官方MCP服务器SDKzod:运行时模式验证和类型推断typescript,tsx,@types/node:开发工具
许可证
麻省理工学院
