Back to MCP directory
publicPublicdnsLocal runtime

mcp-starter-template

一个基于TypeScript的MCP服务器生产级启动模板,提供快速开发工具和标准化工作流。

article

README

🚀 MCP 服务器启动模板

这是一个使用 TypeScript 构建的生产就绪 starter 模板,专门用于搭建 Model Context Protocol (MCP) 服务器。它能帮助开发者快速启动 MCP 服务器的开发工作,提供了高效的开发和测试环境,以及良好的项目结构和版本管理方案。

🚀 快速开始

克隆仓库

安装依赖

bun install

✨ 主要特性

  • 借助 Bun 实现快速测试和开发,显著提升开发效率。
  • 利用 Biome 进行代码检查和格式化,保证代码质量。
  • 配合 standard - version 实现版本管理自动化,简化版本发布流程。
  • 提供干净、可维护的项目结构,便于后续开发和扩展。

📦 安装指南

克隆仓库

安装依赖

bun install

📂 项目结构

mcp-starter/
├── src/
│   ├── tools/          # MCP 工具实现
│   ├── utils/          # 共用工具函数
│   ├── main.ts         # 服务器入口点
│   └── types.ts        # 共用类型定义
├── tests/              # 测试文件
├── biome.json          # 代码检查配置
├── tsconfig.json       # TypeScript 配置
└── package.json        # 项目依赖

🔧 配置

创建新工具

该项目包含一个脚本,可帮助创建新的 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
  1. 更新你的 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
  1. 构建项目:
bun run build
  1. 发布包:
npm publish

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

📦 从 npm 安装(在发布后)

将以下内容添加到你的 Claude Desktop 配置中:

// 只有在你需要传递参数给服务器时才需要此参数
{
  "mcpServers": {
    "your-server-name": {
      "command": "npx",
      "args": ["-y", "your-package-name", "some_argument"]
    }
  }
}
help

Runtime guide

cloud

Hosted runtime

Hosted servers run from a provider-managed environment. You usually connect the MCP client to the hosted endpoint or follow the provider's authorization flow, without keeping a local process alive

  1. Open provider connection page
  2. Authorize or copy endpoint
  3. Connect from your MCP client
terminal

Local runtime / other methods

Local servers run on your own machine or infrastructure. You normally copy the server_config into your MCP client, install the required package, and provide env variables from env_schema when needed

  1. Copy server_config
  2. Install required package
  3. Fill env variables and restart client