easy-mcp-server 监视 api/ 文件夹,并将每个文件转换为:
| 您提供 | 自动获得 |
|---|---|
api/foo/get.ts 样式的处理器 | MCP 工具 (api__foo__get) |
REST 路由 GET /foo | |
| 请求/响应类 | MCP 工具和 OpenAPI 架构 + Swagger UI |
npm run n8n:generate | 镜像您的 API 的 n8n 节点 |
所有内容都支持热重载,并且无需配置即可使用。
npx easy-mcp-server init my-project
cd my-project
./start.sh
| 服务 | URL |
|---|---|
| MCP 服务器 | http://localhost:8888 |
| REST API | http://localhost:8887 |
| Swagger UI | http://localhost:8887/docs |
| OpenAPI 规范 | http://localhost:8887/openapi.json |
通过 ./stop.sh 停止堆栈。
| 文件 | 方法 | 路由 |
|---|---|---|
api/users/get.ts | GET | /users |
api/users/post.ts | POST | /users |
api/users/[id]/get.ts | GET | /users/:id |
请求块
// @description('传入负载')
class Request {
// @description('用户名')
name: string;
// @description('用户邮箱')
email: string;
}
响应块
// @description('响应负载')
class Response {
success: boolean;
data: { id: string; name: string; email: string };
}
处理器块
// @summary('创建一个用户')
// @tags('users')
function handler(req: any, res: any) {
const { name, email } = req.body;
if (!name || !email) {
res.status(400).json({ success: false, error: '需要名称和邮箱' });
return;
}
res.status(201).json({
success: true,
data: { id: '123', name, email }
});
}
导出块
module.exports = handler;
export {};
注释 (@description, @summary, @tags) 自动填充 OpenAPI 文档和 MCP 工具元数据。
查看 系统架构文档 获取详细图表和流程解释。
mcp-bridge.json 组合其他 MCP 服务器{
"mcpServers": {
"chrome": {
"command": "npx",
"args": ["-y", "chrome-mcp-server"]
}
}
}
热重载保持桥接工具和您的 API 工具在端口 8888 上可用。通过添加 "disabled": true 禁用任何桥接。
| 命令 | 目的 |
|---|---|
./start.sh | 启动 REST + MCP 服务器 |
./stop.sh | 停止它们 |
npm run n8n:generate | 刷新 n8n 节点 |
npm test | 运行测试(按配置) |
| 环境变量 | 默认值 | 备注 |
|---|---|---|
EASY_MCP_SERVER_PORT | 8887 | REST 端口 |
EASY_MCP_SERVER_MCP_PORT | 8888 | MCP 端口 |
EASY_MCP_SERVER_LOG_LEVEL | info | debug, info, warn, error |
EASY_MCP_SERVER_API_PATH | ./api | 监视的文件夹 |
EASY_MCP_SERVER_HOST | 0.0.0.0 | 主机绑定 |
docs/ARCHITECTURE.mddocs/DEVELOPMENT.mdexample-project/| 主题 | 详情 |
|---|---|
| 问题 / 企业支持 | info@easynet.world |
| 许可证 | MIT |
| 维护者 | 梁博强 (boqiang.liang@easynet.world) |