← Back to Plugins
Tools

X402 Plugin Template

MangroveTechnologies By MangroveTechnologies 👁 41 views ▲ 0 votes

Template for building Claude Code + OpenClaw plugins that consume x402 MCP servers

GitHub

README

# x402 Plugin Template

Template for building Claude Code + OpenClaw plugins that consume x402-enabled MCP servers. The client-side companion to [x402-app-template](https://github.com/MangroveTechnologies/x402-app-template).

## Quick Start

1. Clone this template
2. Run `./init.sh my-plugin-name https://my-server.com/mcp`
3. Replace example skills in `.claude/skills/` with your tool interactions
4. Replace example tools in `openclaw-plugin/` with your MCP tool definitions
5. Update `shared/config.ts` with any custom configuration

## Directory Structure

```
.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 types
```

## x402 Payment Flow

Paid tools use the x402 micropayment protocol:

1. Call the tool without a `payment` parameter
2. Server returns `PAYMENT_REQUIRED` with price and network details
3. Present the cost to the user
4. If confirmed, sign the payment with the user's wallet
5. Call the tool with the `payment` parameter (base64 signature)
6. Server verifies payment, settles on-chain, returns data

## Related

- [x402-app-template](https://github.com/MangroveTechnologies/x402-app-template) -- Server-side template
- [x402 Protocol](https://www.x402.org/) -- Payment protocol specification
tools

Comments

Sign in to leave a comment

Loading comments...