zero-mcp
by SNIKO·★ 2·综合分 37
Zero MCP 是一个轻量级、零样板代码的工具包,用于构建基于 HTTP 的快速 MCP 服务器,依赖极少。
概述
Zero MCP 提供了与官方 MCP SDK 不同的选择,专注于性能和简洁性。它通过仅使用两个包(zod 和 zod-to-json-schema)消除了依赖臃肿问题,通过使用原生 HTTP 服务器性能避免了 Express 中间件开销,并通过 API 实现了即时服务器设置,减少了样板代码。该工具包通过生命周期钩子提供内置的可观测性,包含生产就绪的 CORS 控制,以及 Zod 集成用于自动生成 JSON Schema。
试试问 AI
装完之后,这里有 3 个你可以让 AI 做的事:
什么时候选它
当您需要基于 HTTP 的快速、轻量级 MCP 服务器,希望避免官方 SDK 的 Express 带来的开销时,选择 Zero MCP。
什么时候不要选它
如果您需要完整的 MCP 规范支持,包括 stdio 传输、prompts API 或身份验证流程,不要选择 Zero MCP,因为它仅支持 HTTP 传输。
此 server 暴露的工具
从 README 抽取出 1 个工具add({ a: number, b: number }) => Promise<Array<{ type: 'text', text: string }>>Simple addition tool that returns the sum of two numbers.
说明:Only one tool example ('add') was explicitly shown in the README code example. No other tools are documented, though the framework allows for creating tools via server.tool().
可对比工具
安装
npm install zero-mcp zod示例服务器实现:
import { McpServer, z } from 'zero-mcp';
const server = new McpServer({
name: 'calculator',
version: '1.0.0',
});
server.tool({
name: 'add',
description: '简单加法工具',
schema: z.object({
a: z.number().describe('第一个加数'),
b: z.number().describe('第二个加数'),
}),
handler: async ({ a, b }) => {
return [{
type: 'text',
text: `${a} 和 ${b} 的和是 ${a + b}。`,
}];
},
});
await server.start({
host: '127.0.0.1',
port: 3000,
path: '/mcp',
});
console.log('服务器已在 http://127.0.0.1:3000/mcp 启动');要在 Claude Desktop 中使用,添加到 claude_desktop_config.json:
{
"mcpServers": {
"zero-mcp": {
"command": "node",
"args": ["/path/to/your/server.js"]
}
}
}zero-mcp 对比
最后更新于 · 由 README + GitHub 公开数据自动生成。