MCP示例:stdio上的服务器
此存储库演示了一个简单的MCP(模型上下文协议)服务器实现,该实现使用TypeScript通过stdio进行通信。
特性
- 使用stdio的MCP服务器示例
- 用TypeScript编写
- 可轻松扩展自定义MCP命令
先决条件
- Node.js(建议使用v18或更新版本)
- npm
设置
- 安装依赖项:
npm install- 转到光标设置->MCP->添加新MCP:
{
"mcpServers": {
"Yes or No MCP": {
"command": "npx",
"args": [
"-y",
"tsx",
"/stdio-example.ts",
"--stdio"
]
}
}
}替换 ` 与你的绝对路径 stdio-example.ts` 文件。
- 使用MCP服务器:
在Cursor中询问LLM一些问题,并在最后添加“是或否”,Cursor将调用MCP工具。
文件概述
stdio-example.ts:主MCP服务器实现。copy-this-to-mcp-json.json:MCP服务器设置的示例配置。
许可证
麻省理工学院
