M

MCP 服务器构建模板

@GreatAuk/mcp-weather
0 Stars 49 次浏览 GreatAuk 更新于 2026-08-23

一个基于 TypeScript 的模板,用于构建 Model Context Protocol 服务器,具有快速测试、自动版本管理和为 MCP 工具实现提供的清晰结构。

该服务暂未提供标准配置,请参考 README 手动接入

可用工具 (1 个)

该服务在 MCP 协议中暴露的工具,AI 可按需调用

hello_tool 1 个参数 需填 1 项

Hello tool

必填参数:name

服务介绍

MCP 服务器启动器

smithery 徽章

这是一个用于使用 TypeScript 构建 Model Context Protocol (MCP) 服务器的生产就绪启动模板。

🚀 快速开始

  1. 克隆仓库
  2. 安装依赖:
    bun install
    

✨ 主要特性

  • 使用 Bun 进行快速测试和开发
  • 使用 Biome 进行代码检查和格式化
  • 使用 standard-version 自动管理版本
  • 清晰、可维护的项目结构

📂 项目结构

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
  • 代码检查bun run lint
  • 构建项目bun run build

要将您的开发 MCP 服务器添加到 Claude Desktop:

  1. 构建项目:
    bun run build
    
  2. 添加到您的 Claude Desktop 配置中:
    // 仅在需要向服务器传递参数时才需要此参数
    {
      "mcpServers": {
        "your-server-name": {
          "command": "node",
          "args": ["/path/to/your/project/dist/main.js", "some_argument"]
        }
      }
    }
    

📜 版本管理

该项目使用 standard-version 进行自动版本管理。运行 bun run release 来创建新版本。

提交信息格式

  • feat:新功能(提升次要版本号)
  • fix:错误修复(提升补丁版本号)
  • BREAKING CHANGE:破坏性变更(提升主要版本号)

📦 发布到 npm

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

记得在发布新版本之前使用 bun run release 更新版本号。

通过 Smithery 安装

要通过 Smithery 自动为 Claude Desktop 安装 Weather MCP Server 启动器:

npx -y @smithery/cli install @GreatAuk/mcp-weather --client claude

从 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"]
    }
  }
}

相关 MCP 服务