QuantGeekDev
MCP 服务配置
复制以下 JSON 到 OPClaw 或其他 MCP 客户端的配置文件中即可使用
{
"mcpServers": {
"filesystem": {
"args": [
"filesystem"
],
"command": "npx"
}
}
}
服务介绍
文件系统
使用 mcp-framework 构建的 Model Context Protocol (MCP) 服务器。
快速开始
bash
安装依赖
npm install
构建项目
npm run build
项目结构
filesystem/
├── src/
│ ├── tools/ # MCP 工具
│ │ └── ExampleTool.ts
│ └── index.ts # 服务器入口点
├── package.json
└── tsconfig.json
添加组件
该项目在 src/tools/ExampleTool.ts 中包含一个示例工具。您可以使用 CLI 添加更多工具:
bash
添加新工具
mcp add tool my-tool
您可能创建的示例工具:
mcp add tool data-processor
mcp add tool api-client
mcp add tool file-handler
工具开发
示例工具结构:
typescript
import { MCPTool } from "mcp-framework";
import { z } from "zod";
interface MyToolInput {
message: string;
}
class MyTool extends MCPTool {
name = "my_tool";
description = "描述您的工具的功能";
schema = {
message: {
type: z.string(),
description: "此输入参数的描述",
},
};
async execute(input: MyToolInput) {
// 在这里编写您的工具逻辑
return Processed: ${input.message};
}
}
export default MyTool;
发布到 npm
-
更新您的
package.json:- 确保
name是唯一的,并遵循 npm 命名规范 - 设置适当的
version - 添加
description,author,license等信息 - 检查
bin是否指向正确的入口文件
- 确保
-
本地构建和测试:
bash
npm run build
npm link
filesystem # 本地测试您的 CLI -
登录 npm(如果需要,请先创建账号):
bash
npm login -
发布您的包:
bash
npm publish
发布后,用户可以将其添加到他们的 Claude 桌面客户端(请阅读以下内容),或者使用 npx 运行它。
与 Claude 桌面客户端一起使用
本地开发
将此配置添加到您的 Claude 桌面客户端配置文件中:
MacOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%/Claude/claude_desktop_config.json
json
{
"mcpServers": {
"filesystem": {
"command": "node",
"args":["/absolute/path/to/filesystem/dist/index.js"]
}
}
}
发布后
将此配置添加到您的 Claude 桌面客户端配置文件中:
MacOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%/Claude/claude_desktop_config.json
json
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": ["filesystem"]
}
}
}
构建和测试
- 对您的工具进行修改
- 运行
npm run build编译 - 服务器将在启动时自动加载您的工具