Token导航 LogoToken导航TokenDH.com
Create MCP Server Pro logo
运维云端stdio官方级别未说明来源级核验

Create MCP Server Pro

MCP Server

create-mcp-server-pro

一个用于快速搭建生产就绪MCP服务器的脚手架工具,包含TypeScript、Vitest测试、GitHub Actions CI等最佳实践。

工具数

0

提示词数

0

GitHub Stars

0

资源数

0
AI工具集成TypeScriptClaudeJavaScriptClaudeCursorWindsurf

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

ofershap

提供方

ofershap

最后核验

2026/5/17 20:22

运行时

Node.js

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

命令预览

npx create-mcp-server-pro my-server

详细介绍

创建MCP服务器Pro——脚手架生产就绪的MCP服务器

](https://www.npmjs.com/package/create-mcp-server-pro) ](https://www.npmjs.com/package/create-mcp-server-pro) ![CI](https://github.com/ofershap/create-mcp-server-pro/actions/workflows/ci.yml) ![TypeScript](https://www.typescriptlang.org/) ![License: MIT](https://opensource.org/licenses/MIT)

用一个命令搭建一个生产就绪的MCP服务器。TypeScript、Vitest测试、GitHub Actions CI、错误处理模式和最佳实践——所有这些都包括在内。

npx create-mcp-server-pro my-server

为什么是这个?

功能官方(存档)FastMCP模板创建mcp服务器专业版
已维护2024年11月存档
官方MCP SDK否(FastMCP)
Vitest测试
GitHub操作CI
错误处理模式
对代理友好的自述文件
验证样板
语义释放
ESLint 9+预处理

快速开始

Demo

交互式

npx create-mcp-server-pro my-server

您将被要求:

  • 服务器名称 --npm包名称(默认为 mcp-server-)
  • 描述 --你的服务器做什么
  • 认证 -是否需要API令牌
  • 作者 --你的名字

非交互式(对代理友好)

npx create-mcp-server-pro my-server \
  --name mcp-server-weather \
  --description "MCP server for weather data" \
  --auth \
  --author "Your Name"

所有标志都是可选的。提供 --name--description 跳过所有提示。

脚手架搭设后

cd my-server
npm install
npm run build
npm test

然后添加您的工具 src/tools.ts 并将其注册到 src/index.ts.

生成什么

my-server/
  src/
    index.ts          # McpServer setup, tool registration, StdioServerTransport
    tools.ts          # Example tools with proper error handling
  tests/
    tools.test.ts     # Vitest tests with fetch mocking
  .github/
    workflows/
      ci.yml          # Node 20 + 22 matrix, lint, typecheck, build, test
      release.yml     # semantic-release on version tags
    FUNDING.yml
  package.json        # bin field, correct deps, scripts, lint-staged
  tsconfig.json       # ES2022, NodeNext, strict mode
  tsup.config.ts      # ESM, node20 target, shebang banner
  vitest.config.ts    # globals, v8 coverage
  eslint.config.js    # flat config, typescript-eslint strict
  .prettierrc.json
  .gitignore
  LICENSE             # MIT
  README.md           # Agent-friendly with Quick Start configs

如何构建MCP服务器

如果你是MCP(模型上下文协议)的新手,以下是你需要知道的。

什么是MCP?

MCP是Anthropic的开放标准,允许AI助手(Claude、Cursor、GitHub Copilot、Windsurf)连接到外部工具和数据。您的MCP服务器暴露 工具 AI代理可以调用。

AI Assistant    MCP Protocol    Your Server    APIs / Data

工具剖析

每个MCP工具都有三个部分:

import { z } from "zod";

server.tool(
  "tool_name", // 1. Name (snake_case)
  "What this tool does — be specific for the AI", // 2. Description
  {
    // 3. Input schema (Zod)
    query: z.string().describe("Search query"),
    limit: z
      .number()
      .int()
      .min(1)
      .max(100)
      .default(10)
      .describe("Max results to return"),
  },
  async ({ query, limit }) => {
    // 4. Handler
    try {
      const results = await searchAPI(query, limit);
      return {
        content: [{ type: "text", text: JSON.stringify(results, null, 2) }],
      };
    } catch (err) {
      const message = err instanceof Error ? err.message : String(err);
      return {
        content: [{ type: "text", text: `Error: ${message}` }],
        isError: true,
      };
    }
  },
);

最佳实践

这些图案来自建筑 4台生产MCP服务器:

命名

  • 使用 snake_case 工具名称(例如。 search_packages, get_user)
  • 避免空格、点或大小写混合——它们会导致LLM中的标记化问题

描述

  • 为人工智能而不是人类写描述
  • 具体来说:“按关键字搜索npm包并返回名称、版本和描述”比“搜索包”更好
  • 每个Zod领域都应该有 .describe() --这就是人工智能知道传递什么的方式

错误处理

  • 用try/catch封装外部调用
  • 返回 { content: [...], isError: true } 用于可恢复的错误
  • 包括可操作的上下文:“未设置API_TOKEN。在MCP客户端环境中设置它。”而不是“Auth failed”

测试

  • 测试工具逻辑与MCP注册分开
  • 模拟 fetch 随着 vi.spyOn(globalThis, "fetch")
  • 测试成功和错误路径

项目结构

  • 保持工具逻辑 src/tools.ts (或 src/tools/ 对于许多工具)
  • 将MCP注册保存在 src/index.ts
  • 这种分离使得工具可以在没有MCP传输的情况下进行测试

连接到AI客户端

构建服务器后(npm run build),连接它:

克劳德桌面版~/Library/Application Support/Claude/claude_desktop_config.json:

{
  "mcpServers": {
    "my-server": {
      "command": "npx",
      "args": ["-y", "my-server"]
    }
  }
}

光标.cursor/mcp.json 在您的项目中:

{
  "mcpServers": {
    "my-server": {
      "command": "npx",
      "args": ["-y", "my-server"]
    }
  }
}

VS代码(GitHub副本).vscode/mcp.json:

{
  "servers": {
    "my-server": {
      "type": "stdio",
      "command": "npx",
      "args": ["-y", "my-server"]
    }
  }
}

真实世界的例子

这些MCP服务器是使用此脚手架生成的相同模式构建的:

服务器工具功能
mcp服务器开发工具17Base64、UUID、哈希、JWT解码、cron、时间戳、JSON、正则表达式
6搜索包、查看详细信息、比较、检查下载
8创建、阅读、更新、列出和搜索GitHub Gists
mcp服务器cloudflare13Workers、KV、R2、DNS和缓存管理

作者

![Made by ofershap](https://gitshow.dev/ofershap)

![LinkedIn](https://linkedin.com/in/ofershap) ](https://github.com/ofershap)

______________________________________________________________________

README构建于 README生成器

许可证

麻省理工学院

目录标签

目录标签

AI工具集成TypeScriptClaudeJavaScriptMCP服务器本地部署脚手架工具

支持客户端

ClaudeCursorWindsurf

接入字段

传输方式(transport,传输协议)

stdio

鉴权方式(authType,认证方式)

none

运行时(runtime,运行环境)

Node.js

来源包(packageName,安装包名)

create-mcp-server-pro

工具数量(toolCount,工具数)

0

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

stdionone部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

来源信息

继续浏览同类 MCP