代码解释器 MCP 是一个 Cloudflare Worker,作为代码解释的模型上下文协议(MCP)服务器。它能够对代码进行分析和解释,提供代码全面的结构和功能分解,助力开发者更好地理解代码。
代码解释器通过以下步骤对源代码进行分析:
git clone https://github.com/BillDuke13/code-explainer-mcp.git
cd code-explainer-mcp
npm install
wrangler dev
curl -X POST http://localhost:8787 \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_SECRET_KEY_HERE" \
-d '{"method":"explainCode","params":["function hello() { return \"Hello World\"; }","javascript"]}'
POSTContent-Type: application/jsonAuthorization: Bearer YOUR_SECRET_KEY_HERE{
"method": "explainCode",
"params": [
"<代码内容>",
"<编程语言>"
]
}
{
"result": {
"architecture": {
"components": ["主要组件1", "主要组件2"],
"relations": {"组件A": ["依赖组件B", "调用组件C"]}
},
"functions": [
{
"name": "函数名",
"purpose": "函数作用描述",
"parameters": ["参数1", "参数2"],
"returnType": "返回类型"
}
],
"documentation": "自动生成的文档内容..."
},
"status": "success"
}
本项目遵循 Apache License 2.0 协议,详情请参阅LICENSE文件。