](https://www.npmjs.com/package/easy-mcp-server)   
编写一次处理程序,得到
- MCP工具
- REST端点
- n8n个节点
- 自动切换开关/OpenAPI。
______________________________________________________________________
1.这是什么?
easy-mcp-server 观看 api/ 文件夹,并将每个文件转换为:
| 您提供 | 您将自动获得 |
|---|---|
api/foo/get.ts 样式处理程序 | MCP工具(api__foo__get) |
REST路由 GET /foo | |
| 请求/响应类 | MCP工具和OpenAPI模式+Swagger UI |
npm run n8n:generate | n8n个节点,用于镜像您的API |
所有热重加载的东西都是零配置的。
______________________________________________________________________
2.快速入门
npx easy-mcp-server init my-project
cd my-project
./start.sh| 服务 | URL |
|---|---|
| MCP服务器 | http://localhost:8888 |
| REST API | http://localhost:8887 |
| Swagger用户界面 | http://localhost:8887/docs |
| OpenAPI规范 | http://localhost:8887/openapi.json |
停止堆栈 ./stop.sh.
______________________________________________________________________
3.定义端点
文件名=路由(示例)
| 文件 | 方法 | 路由 |
|---|---|---|
api/users/get.ts | 得到 | /users |
api/users/post.ts | 职位 | /users |
api/users/[id]/get.ts | 得到 | /users/:id |
最小处理程序模板
请求块
// @description('Incoming payload')
class Request {
// @description('User name')
name: string;
// @description('User email')
email: string;
}响应块
// @description('Response payload')
class Response {
success: boolean;
data: { id: string; name: string; email: string };
}处理器块
// @summary('Create a user')
// @tags('users')
function handler(req: any, res: any) {
const { name, email } = req.body;
if (!name || !email) {
res.status(400).json({ success: false, error: 'Name and email required' });
return;
}
res.status(201).json({
success: true,
data: { id: '123', name, email }
});
}出口区块
module.exports = handler;
export {};注释(@description, @summary, @tags)自动提供OpenAPI文档和MCP工具元数据。
______________________________________________________________________
4.系统架构
看 系统架构文件 查看详细的图表和流程说明。
______________________________________________________________________
5.MCP桥(可选)
通过以下方式组合其他MCP服务器 mcp-bridge.json
{
"mcpServers": {
"chrome": {
"command": "npx",
"args": ["-y", "chrome-mcp-server"]
}
}
}热重新加载使桥接工具和API工具在端口上可用 8888.通过添加来禁用任何网桥 "disabled": true.
______________________________________________________________________
6.操作
| 命令 | 目的 |
|---|---|
./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 | 主机绑定 |
______________________________________________________________________
7.资源
- 架构:
docs/ARCHITECTURE.md - 指南:
docs/DEVELOPMENT.md - 示例项目:
example-project/ - 斯瓦格:http://localhost:8887/docs
- OpenAPI:http://localhost:8887/openapi.json
- MCP端点:http://localhost:8888
8.支持与贡献
| 主题 | 详细信息 |
|---|---|
| 问题/企业支持 | info@easynet.world |
| 许可 | 麻省理工学院 |
| 维护人员 | 梁伯强(boqiang.liang@easynet.world) |
