SC

stephencme/create-mcp-ts

开发工具

本页由 AI 翻译,技术细节请以原文为准。 查看原文

21 stars 7 forks 质量 49 趋势 0

用TypeScript创建一个新的MCP服务器,电池也随意。

概览

用TypeScript创建一个新的MCP服务器,电池也随意。 create-mcp-ts 需要——它会自动安装开发、构建和设置 MCP 服务器所需的一切。 create-mcp-ts 可以自动配置你的 MCP 服务器,包括 Cursor、Windsurf 和 Claude Desktop: 该脚本会检查你的服务器是否已经存在于每个客户端的MCP配置文件中。如果没有,它会添加一个指向服务器脚本(dist/index.js)的条目: 关于如何在Cursor、Windsurf和Claude Desktop中设置MCP服务器的更多细节,请参见: - 光标用 MCP 文档 - 风板用 MCP 文档 - Claude Desktop 用 MCP 文档 如果你想使用自定义模板,可以通过将模板的 npm 包名称或文件路径传递到 npx 的 create-mcp-ts 命令中实现: 如果你打算分享你的MCP服务器,可以发布到npm:

概述(AI 翻译)

用TypeScript创建一个新的MCP服务器,电池也随意。

开始

create-mcp-ts 要求零构建配置——它会自动安装你开发、构建和设置MCP服务器所需的一切。

在Cursor、Windsurf和Claude Desktop中设置你的MCP服务器

create-mcp-ts 可以自动在 Cursor、Windsurf 和 Claude Desktop 中配置您的 MCP 服务器:

该脚本检查每个客户端的MCP配置文件中是否已经存在your-server。如果没有,则添加指向服务器脚本(dist/index.js)的条目:

关于如何在Cursor、Windsurf和Claude Desktop中设置MCP服务器的更多细节,请参见:

  • 光标的MCP文档
  • 风帆冲浪的MCP文档
  • Claude Desktop 的 MCP 文档

自定义模板

如果你想使用自定义模板,可以通过将模板的 npm 包名或文件路径传递到 npx create-mcp-ts 命令中实现:

发布你的MCP服务器

如果你打算分享你的MCP服务器,可以发布到npm:

  1. 将"version"设在package.json中,并确保"private"设置为false。
  2. 跑npm install。
  3. 跑npm run build。
  4. 运行npm login(如有需要)。
  5. 跑npm publish。

本页由 AI 翻译,技术细节请以原文为准。

README

以下为原文 README 节选,完整内容请查看原文。

create-mcp-ts

Create a new MCP server in TypeScript, batteries included.

Getting started

npm init mcp-ts your-server
cd your-server
npm run dev

create-mcp-ts requires zero build configuration - it will automatically install everything you need to develop, build, and set up your MCP server.

Set up your MCP server in Cursor, Windsurf, and Claude Desktop

create-mcp-ts can automatically configure your MCP server in Cursor, Windsurf, and Claude Desktop:

npm run setup

This script checks if your-server already exists in each client’s respective MCP configuration file. If not, it adds an entry pointing to the server script (dist/index.js):

{
  "mcpConfig": {
    "your-server": {
      "command": "node",
      "args": ["/path/to/your-server/dist/index.js"]
    }
  }
}

For more details on how to set up MCP servers in Cursor, Windsurf, and Claude Desktop, see:

Custom templates

If you’d like to use a custom template, you can do so by passing the template npm package name or file path to the npx create-mcp-ts command:

npx create-mcp-ts your-server --template=mcp-ts-template-default
npx create-mcp-ts your-server --template=file:/path/to/mcp-ts-template

Publishing your MCP server

If you plan to share your MCP server, you can publish it to npm:

  1. Set "version" in package.json and ensure "private" is set to false.
  2. Run npm install.
  3. Run npm run build.
  4. Run npm login (if needed).
  5. Run npm publish.

Ejecting from mcp-scripts

The mcp-scripts package contains build tools for create-mcp-ts projects - everything you’ll need to develop, build, and set up an MCP server without any additional configuration.

Under the hood mcp-scripts uses tsup and esbuild, lightweight, battle-tested utilities that are well-suited for production-grade TypeScript projects.

If you’d like to eject from mcp-scripts, run the following command:

npm run eject

This will remove the mcp-scripts dependency and replace any related commands from your project’s package.json file.

Troubleshooting your MCP server

Confirm you have Node.js installed

If you experience issues running your MCP server, the first thing to check is that you have Node.js installed globally. You can check this by running:

node --version

If you don’t have Node.js installed, you can install it by following the instructions here.

Usage with Node.js version managers

在 GitHub 查看完整 README

安装

npx create-mcp-ts your-server --template=mcp-ts-template-default
新手?先看 mcpskill.org 教程 →