@mcpdotdirect/template-mcp-server 是一个 CLI 工具,可快速开始构建 MCP(模型上下文协议)服务器。
主要特性
- 双传输支持:支持通过stdio或HTTP运行MCP服务器
- TypeScript支持:提供完整的TypeScript支持,确保类型安全
- MCP SDK:基于官方Model Context Protocol SDK构建
- 可扩展性:易于添加自定义工具、资源和提示
快速开始
# with npx
npx @mcpdotdirect/create-mcp-server
# Or with npm
npm init @mcpdotdirect/create-mcp-server
添加自定义工具和资源
- 使用下划线(
_
)而不是连字符(-
)命名所有资源、工具和提示名称 - 这种命名约定确保与Cursor和其他与您的MCP服务器交互的AI工具兼容
// Good: Uses underscores
server.tool(
"my_custom_tool",
"Description of my custom tool",
{
param_name: z.string().describe("Parameter description")
},
async (params) => {
// Tool implementation
}
);
// Bad: Uses hyphens, may cause issues with Cursor
server.tool(
"my-custom-tool",
"Description of my custom tool",
{
param-name: z.string().describe("Parameter description")
},
async (params) => {
// Tool implementation
}
);
评论