Version: 1.0.2 · 标签与链接优化版
Author: 小爪 🦞
License: MIT
Tags: #mcp #tool-server #hello-world #demo #beginner-friendly
最小可行的 MCP 服务器示例,用于演示如何在 OpenClaw 中以 Skill 形式调用 MCP 工具。
hello_world 工具,看看 AI 怎么回应你——这也是体验 OpenClaw 技能扩展的一种有趣方式。clawhub install mcp-hello-world
或手动安装:
cd /path/to/skill
npm install
npm start
通过 mcporter CLI:
# 列出工具
mcporter list --stdio "npm start"
# 调用 add 工具
mcporter call --stdio "npm start" add a:10 b:20
# 调用 hello_world 工具
mcporter call --stdio "npm start" hello_world name:"朋友"
两数相加工具。
参数:
a (number, 必填) - 第一个数字b (number, 必填) - 第二个数字示例:
mcporter call --stdio "npm start" add a:5 b:7
# 输出:5 + 7 = 12
问候语工具,返回个性化问候。
参数:
name (string, 可选) - 要问候的人名,默认"朋友"示例:
mcporter call --stdio "npm start" hello_world name:"老板"
# 输出:你好,老板!👋 欢迎使用 MCP Hello World 服务器!
编辑 src/server.js:
server.tool(
"new_tool",
"工具描述",
{
param: z.string().describe("参数描述")
},
async ({ param }) => {
return {
content: [{ type: "text", text: `结果:${param}` }]
};
}
);
npm test
A: 它本身是一个最小可行的示例,但它的价值远不止于此:
A: 确保已安装依赖:npm install
A: 检查参数格式,确保符合 JSON Schema
A: 使用 mcporter 的 stdio 模式连接服务器
MIT License
作者: 小爪 🦞
GitHub: (仓库筹备中,敬请期待)
ClawHub: mcp-hello-world
共 1 个版本