MCP服务器模板

一个基于TypeScript的生产就绪的MCP服务器启动模板,提供快速开发、测试和部署功能。

  • by StevenStavrakis
  • JavaScript
  • 本地部署
  • 47 星标
  • 更新于
在 GitHub 查看 StevenStavrakis/mcp-starter-template

使用说明

MCP服务器启动器

用于使用TypeScript构建模型上下文协议(MCP)服务器的生产就绪启动模板。

🚀 快速开始

  1. 克隆存储库
  2. 安装依赖项:
    bun install
    

✨ 主要特点

  • Bun用于快速测试和开发
  • 植绒和格式化的生物特征
  • 标准版本的自动化版本管理
  • 干净、可维护的项目结构

📂 项目结构

mcp-starter/
├── src/
│   ├── tools/          # MCP tools implementation
│   ├── utils/          # Shared utilities
│   ├── main.ts         # Server entry point
│   └── types.ts        # Shared type definitions
├── tests/              # Test files
├── biome.json          # Linting configuration
├── tsconfig.json       # TypeScript configuration
└── package.json        # Project dependencies

⚙️ 配置

创建新工具

该项目包括一个脚本,用于帮助创建新的MCP工具:

bun run scripts/create-tool.ts <tool-name>

这将:

  1. 在下创建新的工具目录 src/tools/<tool-name>
  2. 生成基本工具结构,包括:
    • index.ts(主要实现)
    • schema.ts(用于工具参数的JSON模式)
    • test.ts(测试文件)
  3. 更新工具索引文件以导出新工具

例子:

bun run scripts/create-tool.ts weather

🛠️ 发展

  • 运行测试: bun test
  • 格式代码: bun run format
  • Lint代码: bun run lint
  • 生成项目: bun run build

要将您的开发MCP服务器添加到Claude Desktop,请执行以下操作:

  1. 构建项目:
    bun run build
    
  2. 添加到您的Claude Desktop配置中:
    // You only need the argument if you need to pass arguments to your server
    {
      "mcpServers": {
        "your-server-name": {
          "command": "node",
          "args": ["/path/to/your/project/dist/main.js", "some_argument"]
        }
      }
    }
    

📜 版本管理

此项目使用 标准版本 用于自动化版本管理。跑 bun run release 创建新版本。

提交消息格式

  • feat:新功能(凸起次要版本)
  • fix:Bug修复(凸起补丁版本)
  • BREAKING CHANGE:突破性变化(颠簸主要版本)

📦 发布到npm

  1. 请确保您已登录到npm:
    npm login
    
  2. 构建项目:
    bun run build
    
  3. 发布包:
    npm publish
    

请记住使用以下命令更新版本号 bun run release 在发布新版本之前。

从npm安装(发布后)

添加到您的Claude Desktop配置中:

// You only need the argument if you need to pass arguments to your server
{
  "mcpServers": {
    "your-server-name": {
      "command": "npx",
      "args": ["-y", "your-package-name", "some_argument"]
    }
  }
}