# x402 MCP server

> Enables AI agents to access hundreds of paid APIs via automatic USDC micropayments on Base and Solana.

- Repository: https://github.com/x402node/x402-mcp
- Page: https://hostedmcp.org/servers/x402node/x402-mcp
- Transport: stdio
- Stars: 1
- License: MIT
- Latest version: 1.0.4

## Install

### Claude Code

```sh
claude mcp add --env 'X402_PRIVATE_KEY=<YOUR_X402_PRIVATE_KEY>' x402-mcp -- npx -y x402node-mcp
```

### Cursor (`~/.cursor/mcp.json`)

```json
{
  "mcpServers": {
    "x402-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "x402node-mcp"
      ],
      "env": {
        "X402_PRIVATE_KEY": "<YOUR_X402_PRIVATE_KEY>"
      }
    }
  }
}
```

### VS Code (`.vscode/mcp.json`)

```json
{
  "servers": {
    "x402-mcp": {
      "type": "stdio",
      "command": "npx",
      "args": [
        "-y",
        "x402node-mcp"
      ],
      "env": {
        "X402_PRIVATE_KEY": "<YOUR_X402_PRIVATE_KEY>"
      }
    }
  }
}
```

### VS Code CLI

```sh
code --add-mcp '{"name":"x402-mcp","type":"stdio","command":"npx","args":["-y","x402node-mcp"],"env":{"X402_PRIVATE_KEY":"<YOUR_X402_PRIVATE_KEY>"}}'
```

### Claude Desktop (`claude_desktop_config.json`)

```json
{
  "mcpServers": {
    "x402-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "x402node-mcp"
      ],
      "env": {
        "X402_PRIVATE_KEY": "<YOUR_X402_PRIVATE_KEY>"
      }
    }
  }
}
```

### Codex

```sh
codex mcp add x402-mcp --env 'X402_PRIVATE_KEY=<YOUR_X402_PRIVATE_KEY>' -- npx -y x402node-mcp
```

### Codex config.toml (`~/.codex/config.toml`)

```toml
[mcp_servers.x402-mcp]
command = "npx"
args = ["-y", "x402node-mcp"]

[mcp_servers.x402-mcp.env]
X402_PRIVATE_KEY = "<YOUR_X402_PRIVATE_KEY>"
```

### Gemini CLI

```sh
gemini mcp add -s user -e 'X402_PRIVATE_KEY=<YOUR_X402_PRIVATE_KEY>' x402-mcp npx -- -y x402node-mcp
```

### Gemini settings.json (`~/.gemini/settings.json`)

```json
{
  "mcpServers": {
    "x402-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "x402node-mcp"
      ],
      "env": {
        "X402_PRIVATE_KEY": "<YOUR_X402_PRIVATE_KEY>"
      }
    }
  }
}
```

## Environment variables

| Name | Required | Secret | Description |
|---|---|---|---|
| `X402_PRIVATE_KEY` | yes | yes | Base EOA private key (hex, 0x-prefixed) with USDC for signing x402 payments |

## FAQ

### How much does each tool call cost?

Tool calls typically cost between $0.0001 and $0.10 USDC, depending on the specific endpoint.

### Can I set a limit on how much is spent per call?

Yes, you can use the MAX_PRICE_USD environment variable to set a hard cap on tool call costs.

### Which blockchains are supported?

Base and Solana mainnets are currently live with USDC support.
