M

MCP框架启动器

@QuantGeekDev/mcp-framework-starter
0 Stars 18 次浏览 QuantGeekDev 更新于 2026-08-23

一个用于构建模型上下文协议(MCP)服务器的启动模板,使开发人员能够创建和添加可与克劳德桌面集成的自定义工具。

MCP 服务配置

复制以下 JSON 到 OPClaw 或其他 MCP 客户端的配置文件中即可使用

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

服务介绍

mcp-framework-starter

使用 mcp-framework 构建的 Model Context Protocol (MCP) 服务器。

快速开始

# Install dependencies
npm install

# Build the project
npm run build

项目结构

mcp-framework-starter/
├── 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-starter  # 本地测试你的 CLI
    
  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-starter": {
      "command": "node",
      "args":["/absolute/path/to/mcp-framework-starter/dist/index.js"]
    }
  }
}

发布之后

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

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

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

构建和测试

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

了解更多