快速搭建MCP服务器模板

快速搭建MCP服务器模板

用于快速搭建您自己的MCP服务器的模板。

快速入门

  1. 使用以下命令创建项目:

    npx @mcpdotdirect/create-mcp-server
    # 或者使用 npm
    npm init @mcpdotdirect/mcp-server
    
  2. 安装依赖:

    npm install
    # 或使用 yarn、pnpm、bun 等包管理工具
    
  3. 启动服务器:

    • stdio 模式(本地 CLI):
      npm start
      
    • HTTP 模式(网络模式):
      npm run start:http
      
  4. 开发模式(支持热重载):

    npm run dev
    # 或 HTTP 模式
    npm run dev:http
    
  5. 配置环境变量,例如更改端口:

    PORT=8080 npm run start:http
    
  6. 在 Cursor 中连接:

    • stdio 模式:添加 npm start 命令。
    • SSE 模式:URL 为 http://localhost:3001/sse

更多信息请参考 FastMCP 文档MCP 协议文档