x402插件模板
用于构建使用x402启用的MCP服务器的Claude Code+OpenClaw插件的模板。客户端伴侣 x402应用模板.
快速开始
- 克隆此模板
- 跑
./init.sh my-plugin-name https://my-server.com/mcp - 替换示例技能
.claude/skills/与工具交互 - 更换中的示例工具
openclaw-plugin/使用您的MCP工具定义 - 更新
shared/config.ts具有任何自定义配置
目录结构
.claude/ Claude Code plugin
settings.json MCP server connection
skills/ One markdown file per tool interaction
commands/ Slash commands
hooks/ Lifecycle hooks (session start, etc.)
openclaw-plugin/ OpenClaw plugin
src/index.ts register() with hooks and tool proxies
openclaw.plugin.json Tool definitions
shared/ Shared between both platforms
config.ts Server URL and auth config
types.ts Common TypeScript typesx402付款流程
付费工具使用x402微支付协议:
- 调用工具而不使用
payment参数 - 服务器返回
PAYMENT_REQUIRED包含价格和网络详细信息 - 向用户展示成本
- 如果确认,用用户的钱包签署付款
- 使用调用工具
payment参数(base64签名) - 服务器验证付款,在链上结算,返回数据
