MCP框架服务器

一个基于mcp-framework构建的模型上下文协议(MCP)服务器,用于开发和集成自定义工具。

  • by cadugrillo
  • TypeScript
  • 本地部署
  • 更新于
在 GitHub 查看 cadugrillo/mcp-framework-101

使用说明

mcp-framework-101(可译为“MCP框架-101”,具体翻译可能根据上下文有所调整)

使用mcp-framework构建的模型上下文协议(MCP)服务器。

快速入门

# Install dependencies
npm install

# Build the project
npm run build

项目结构

mcp-framework-101/
├── src/
│   ├── tools/        # MCP Tools
│   │   └── ExampleTool.ts
│   └── index.ts      # Server entry point
├── package.json
└── tsconfig.json

添加组件

该项目附带了一个示例工具 src/tools/ExampleTool.ts你可以使用命令行界面(CLI)添加更多工具:

# Add a new tool
mcp add tool my-tool

# Example tools you might create:
mcp add tool data-processor
mcp add tool api-client
mcp add tool file-handler

工具开发

示例工具结构:

import { MCPTool } from "mcp-framework";
import { z } from "zod";

interface MyToolInput {
  message: string;
}

class MyTool extends MCPTool<MyToolInput> {
  name = "my_tool";
  description = "Describes what your tool does";

  schema = {
    message: {
      type: z.string(),
      description: "Description of this input parameter",
    },
  };

  async execute(input: MyToolInput) {
    // Your tool logic here
    return `Processed: ${input.message}`;
  }
}

export default MyTool;

发布到 npm

  1. 更新你的 package.json:

    • 确保 name 是独一无二的,并遵循npm的命名规范
    • 设置适当的 version
    • 添加 description, author, license等。
    • 检查 bin 指向正确的入口文件
  2. 本地构建和测试:

    npm run build
    npm link
    mcp-framework-101  # Test your CLI locally
    
  3. 登录到npm(如需请创建账户):

    npm login
    
  4. 发布您的软件包:

    npm publish
    

发布后,用户可以将其添加到他们的Claude桌面客户端(见下文)中,或者使用npx来运行它


## Using with Claude Desktop

### Local Development

Add this configuration to your Claude Desktop config file:

**MacOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
**Windows**: `%APPDATA%/Claude/claude_desktop_config.json`

```json
{
  "mcpServers": {
    "mcp-framework-101": {
      "command": "node",
      "args":["/absolute/path/to/mcp-framework-101/dist/index.js"]
    }
  }
}

发布后

将此配置添加到您的Claude Desktop配置文件中:

MacOS(苹果电脑操作系统): ~/Library/Application Support/Claude/claude_desktop_config.json Windows: %APPDATA%/Claude/claude_desktop_config.json

{
  "mcpServers": {
    "mcp-framework-101": {
      "command": "npx",
      "args": ["mcp-framework-101"]
    }
  }
}

构建与测试

  1. 对你的工具进行更改
  2. 跑 npm run build 编译
  3. 服务器将在启动时自动加载您的工具

了解更多