MCP TypeScript Starter

MCP TypeScript 入门

这是一个使用 TypeScript 创建模型上下文协议 (MCP) 服务器的入门模板。它提供了基本设置和示例工具实现,帮助您开始构建自己的 MCP 服务器。

特征

  • TypeScript 配置
  • 基本 MCP 服务器设置
  • 示例工具实现
  • 类型安全的开发环境

入门

请按照以下步骤创建您自己的 MCP 服务器:

# Create a new directory for your project mkdir <project_name> cd <project_name> # Initialize a new npm project npm init -y # Install dependencies npm install @modelcontextprotocol/sdk zod npm install -D @types/node typescript # Create source directory and main file mkdir src touch src/index.ts

项目结构

. ├── src/ │ └── index.ts # Main server implementation ├── package.json # Project dependencies and scripts └── tsconfig.json # TypeScript configuration

发展

  1. src/index.ts中实现你的工具
  2. 构建项目:
    npm run build

添加新工具

要添加新工具,请使用server.tool()方法。例如:

server.tool( "tool-name", "tool-description", { // Define your tool's parameters using Zod schema param: z.string().describe("parameter description") }, async ({ param }) => { // Implement your tool logic here return { content: [ { type: "text", text: `Tool executed with parameter: ${param}`, }, ], }; }, );

执照

国际学习中心

-
security - not tested
F
license - not found
-
quality - not tested

使用 TypeScript 创建模型上下文协议服务器的入门模板,为开发人员构建自己的 MCP 服务器提供基本设置和示例工具实现。

  1. Features
    1. Getting Started
      1. Project Structure
        1. Development
          1. Adding New Tools
            1. License
              ID: yu8jwbcqyy