MCP服务器模板

一个使用TypeScript和Node.js构建的Model Context Protocol (MCP)服务器模板,用于与Claude Desktop集成。

  • by Somsubhra-Nandi
  • TypeScript
  • 本地部署
  • 更新于
在 GitHub 查看 Somsubhra-Nandi/hello-world-mcp

使用说明

Hello World MCP服务器

A的最小实现 模型上下文协议(MCP) 使用TypeScript和Node.js的服务器。

该项目可作为构建本地MCP工具的入门模板,这些工具与TypeScript中的Claude Desktop集成。

特性

  • 类型安全: 使用TypeScript和Zod构建,用于强大的模式验证。
  • 标准运输: 用途 StdioServerTransport 实现无缝的本地整合。
  • 简单工具: 包括a say_hello 演示工具定义和执行的工具。

先决条件

快速开始

1.克隆和安装

git clone https://github.com/Somsubhra-Nandi/hello-world-mcp.git
cd hello-world-mcp
npm install

2.建设项目

MCP服务器运行在JavaScript上,所以我们必须先编译TypeScript代码。

npm run build

此命令编译 src/index.ts 进入 dist/index.js.

配置

要将此服务器与Claude Desktop一起使用,请将以下配置添加到您的 claude_desktop_config.json 文件。

文件位置:

  • 窗户: %APPDATA%\Claude\claude_desktop_config.json
  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json

配置:

{
  "mcpServers": {
    "hello-world-mcp": {
      "command": "node",
      "args": [
        "C:\\Users\\YOUR_USERNAME\\path\\to\\hello-world-mcp\\dist\\index.js"
      ]
    }
  }
}

确保更换 YOUR_USERNAME 以及你实际的绝对路径。

用法

  1. 重新启动克劳德桌面。
  2. 寻找🔌 图标以验证连接。
  3. 问克劳德:

“运行say_hello工具进行问候 YOUR_USERNAME."

项目结构

hello-world-mcp/
├── src/
│   └── index.ts       # Source code (TypeScript)
├── dist/              # Compiled code (JavaScript) - Generated by build
├── package.json       # Dependencies and scripts
├── tsconfig.json      # TypeScript configuration
└── README.md          # Project documentation

发展

要修改服务器,请执行以下操作:

  1. 编辑 src/index.ts.
  2. 重建项目:
npm run build
  1. 重新启动Claude Desktop以加载更改。

许可证

麻省理工学院