@x402-api/mcp-server 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +242 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +377 -0
- package/dist/index.js.map +1 -0
- package/package.json +66 -0
package/README.md
ADDED
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
# @x402-api/mcp-server
|
|
2
|
+
|
|
3
|
+
> MCP server that gives Claude, ChatGPT, and any MCP-compatible AI agent access to pay-per-call crypto/DeFi data via the [x402 protocol](https://github.com/coinbase/x402).
|
|
4
|
+
|
|
5
|
+
**8 tools. No API keys. AI agents pay USDC micropayments on Base, per request.**
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
██╗ ██╗██╗ ██╗ ██████╗ ██████╗
|
|
9
|
+
╚██╗██╔╝██║ ██║██╔═══██╗╚════██╗
|
|
10
|
+
╚███╔╝ ███████║██║ ██║ █████╔╝
|
|
11
|
+
██╔██╗ ╚════██║██║ ██║██╔═══╝
|
|
12
|
+
██╔╝ ██╗ ██║╚██████╔╝███████╗
|
|
13
|
+
╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚══════╝
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Tools
|
|
17
|
+
|
|
18
|
+
| Tool | API Endpoint | Cost | Description |
|
|
19
|
+
|------|-------------|------|-------------|
|
|
20
|
+
| `get_crypto_prices` | `GET /api/price-feed` | 0.001 USDC | BTC/ETH/SOL + top 24h movers |
|
|
21
|
+
| `get_gas_prices` | `GET /api/gas-tracker` | 0.001 USDC | Multi-chain gas (ETH, Base, Polygon, Arbitrum) |
|
|
22
|
+
| `get_dex_quotes` | `GET /api/dex-quotes` | 0.002 USDC | Swap quotes: Uniswap, SushiSwap, 1inch |
|
|
23
|
+
| `scan_token` | `GET /api/token-scanner` | 0.003 USDC | Token security scan + rug-pull detection |
|
|
24
|
+
| `track_whales` | `GET /api/whale-tracker` | 0.005 USDC | Holder concentration + whale alerts |
|
|
25
|
+
| `scan_yields` | `GET /api/yield-scanner` | 0.005 USDC | DeFi yields: Aave, Compound, Morpho, Lido, Pendle |
|
|
26
|
+
| `get_funding_rates` | `GET /api/funding-rates` | 0.008 USDC | Perp funding rates across 6 venues |
|
|
27
|
+
| `profile_wallet` | `GET /api/wallet-profiler` | 0.008 USDC | Full wallet portfolio + risk profile |
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## Quick Start
|
|
32
|
+
|
|
33
|
+
### Option A: Inspect mode (no payment needed)
|
|
34
|
+
|
|
35
|
+
Just run it — any 402 responses will return human-readable payment instructions:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
npx @x402-api/mcp-server
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Claude will tell you what's needed when a tool requires payment.
|
|
42
|
+
|
|
43
|
+
### Option B: Auto-pay mode (fully autonomous)
|
|
44
|
+
|
|
45
|
+
Install optional payment deps and set your wallet key:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
npm install -g @x402-api/mcp-server
|
|
49
|
+
npm install -g x402-fetch viem
|
|
50
|
+
export X402_WALLET_PRIVATE_KEY=0x<your_private_key>
|
|
51
|
+
x402-api-mcp
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
The server will auto-pay 402 responses using USDC on Base. **Make sure your wallet has USDC on Base mainnet.**
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## Claude Desktop Integration
|
|
59
|
+
|
|
60
|
+
Add to your `claude_desktop_config.json`:
|
|
61
|
+
|
|
62
|
+
### Without auto-pay (inspect mode)
|
|
63
|
+
|
|
64
|
+
```json
|
|
65
|
+
{
|
|
66
|
+
"mcpServers": {
|
|
67
|
+
"x402-api": {
|
|
68
|
+
"command": "npx",
|
|
69
|
+
"args": ["@x402-api/mcp-server"]
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### With auto-pay
|
|
76
|
+
|
|
77
|
+
```json
|
|
78
|
+
{
|
|
79
|
+
"mcpServers": {
|
|
80
|
+
"x402-api": {
|
|
81
|
+
"command": "npx",
|
|
82
|
+
"args": ["@x402-api/mcp-server"],
|
|
83
|
+
"env": {
|
|
84
|
+
"X402_WALLET_PRIVATE_KEY": "0x<your_private_key>"
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
**Config file location:**
|
|
92
|
+
- macOS: `~/Library/Application Support/Claude/claude_desktop_config.json`
|
|
93
|
+
- Windows: `%APPDATA%\Claude\claude_desktop_config.json`
|
|
94
|
+
- Linux: `~/.config/Claude/claude_desktop_config.json`
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
## Environment Variables
|
|
99
|
+
|
|
100
|
+
| Variable | Required | Description |
|
|
101
|
+
|----------|----------|-------------|
|
|
102
|
+
| `X402_WALLET_PRIVATE_KEY` | Optional | Private key for auto-pay (e.g. `0x...`). If set, x402-fetch handles payments automatically. |
|
|
103
|
+
| `X402_API_BASE_URL` | Optional | Override API URL (default: `https://x402-api.fly.dev`) |
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
## How x402 Payments Work
|
|
108
|
+
|
|
109
|
+
This API uses the [x402 protocol](https://github.com/coinbase/x402) — HTTP 402 Payment Required:
|
|
110
|
+
|
|
111
|
+
1. **Agent calls tool** → MCP server makes API request
|
|
112
|
+
2. **Server returns 402** with payment details (amount, USDC address, Base network)
|
|
113
|
+
3. **Auto-pay mode:** x402-fetch signs and submits payment, retries request automatically
|
|
114
|
+
4. **Manual mode:** MCP returns 402 details so user/agent can arrange payment
|
|
115
|
+
|
|
116
|
+
**Payment details:**
|
|
117
|
+
- Token: USDC on Base mainnet
|
|
118
|
+
- Address: `0x60264c480b67adb557efEd22Cf0e7ceA792DefB7`
|
|
119
|
+
- Chain: Base (chain ID 8453)
|
|
120
|
+
- Amount: 0.001–0.008 USDC per call (< 1 cent USD)
|
|
121
|
+
|
|
122
|
+
---
|
|
123
|
+
|
|
124
|
+
## Tool Reference
|
|
125
|
+
|
|
126
|
+
### `get_crypto_prices`
|
|
127
|
+
No parameters. Returns current prices for BTC, ETH, SOL + top 24h movers.
|
|
128
|
+
|
|
129
|
+
```
|
|
130
|
+
Cost: 0.001 USDC
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### `get_gas_prices`
|
|
134
|
+
No parameters. Returns gas prices for Ethereum, Base, Polygon, Arbitrum — slow/standard/fast tiers.
|
|
135
|
+
|
|
136
|
+
```
|
|
137
|
+
Cost: 0.001 USDC
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### `get_dex_quotes`
|
|
141
|
+
Compare swap quotes across DEXes.
|
|
142
|
+
|
|
143
|
+
| Parameter | Type | Required | Description |
|
|
144
|
+
|-----------|------|----------|-------------|
|
|
145
|
+
| `from` | string | ✅ | Input token (e.g. `"ETH"`, `"0x..."`) |
|
|
146
|
+
| `to` | string | ✅ | Output token (e.g. `"USDC"`) |
|
|
147
|
+
| `amount` | string | ✅ | Amount to swap (e.g. `"1.5"`) |
|
|
148
|
+
|
|
149
|
+
```
|
|
150
|
+
Cost: 0.002 USDC
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### `scan_token`
|
|
154
|
+
Token security scan — detects rug-pull flags, honeypot patterns, mint authority, etc.
|
|
155
|
+
|
|
156
|
+
| Parameter | Type | Required | Description |
|
|
157
|
+
|-----------|------|----------|-------------|
|
|
158
|
+
| `token` | string | ✅ | Contract address or symbol (e.g. `"PEPE"`) |
|
|
159
|
+
|
|
160
|
+
```
|
|
161
|
+
Cost: 0.003 USDC
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### `track_whales`
|
|
165
|
+
Whale tracking — holder concentration, Gini coefficient, recent large moves.
|
|
166
|
+
|
|
167
|
+
| Parameter | Type | Required | Description |
|
|
168
|
+
|-----------|------|----------|-------------|
|
|
169
|
+
| `token` | string | ✅ | Contract address or symbol |
|
|
170
|
+
|
|
171
|
+
```
|
|
172
|
+
Cost: 0.005 USDC
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### `scan_yields`
|
|
176
|
+
Top DeFi yield opportunities across Aave, Compound, Morpho, Lido, Pendle, etc.
|
|
177
|
+
|
|
178
|
+
| Parameter | Type | Required | Description |
|
|
179
|
+
|-----------|------|----------|-------------|
|
|
180
|
+
| `chain` | string | ❌ | Filter by chain: `"ethereum"`, `"base"`, `"arbitrum"`, `"polygon"` |
|
|
181
|
+
| `min_tvl` | number | ❌ | Minimum TVL in USD (e.g. `1000000`) |
|
|
182
|
+
|
|
183
|
+
```
|
|
184
|
+
Cost: 0.005 USDC
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
### `get_funding_rates`
|
|
188
|
+
Perpetual funding rates across Binance, OKX, Bybit, dYdX, GMX, Hyperliquid.
|
|
189
|
+
|
|
190
|
+
| Parameter | Type | Required | Description |
|
|
191
|
+
|-----------|------|----------|-------------|
|
|
192
|
+
| `asset` | string | ❌ | Asset symbol (e.g. `"BTC"`, `"ETH"`). All assets if omitted. |
|
|
193
|
+
|
|
194
|
+
```
|
|
195
|
+
Cost: 0.008 USDC
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### `profile_wallet`
|
|
199
|
+
Full wallet portfolio analysis — holdings, DeFi positions, activity, PnL, risk score.
|
|
200
|
+
|
|
201
|
+
| Parameter | Type | Required | Description |
|
|
202
|
+
|-----------|------|----------|-------------|
|
|
203
|
+
| `address` | string | ✅ | Ethereum/Base wallet address (`0x...`) |
|
|
204
|
+
|
|
205
|
+
```
|
|
206
|
+
Cost: 0.008 USDC
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
---
|
|
210
|
+
|
|
211
|
+
## Development
|
|
212
|
+
|
|
213
|
+
```bash
|
|
214
|
+
git clone https://github.com/sugi/x402-api-server
|
|
215
|
+
cd x402-api-server/mcp-server
|
|
216
|
+
|
|
217
|
+
npm install
|
|
218
|
+
npm run build
|
|
219
|
+
npm start
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
To test without a payment wallet, simply run and see the 402 responses:
|
|
223
|
+
|
|
224
|
+
```bash
|
|
225
|
+
node dist/index.js
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
---
|
|
229
|
+
|
|
230
|
+
## Links
|
|
231
|
+
|
|
232
|
+
- [x402 API Landing Page](https://x402-api.fly.dev)
|
|
233
|
+
- [x402 Protocol](https://github.com/coinbase/x402)
|
|
234
|
+
- [Base Chain](https://base.org)
|
|
235
|
+
- [ERC-8004 Agent Identity](https://eips.ethereum.org/EIPS/eip-8004)
|
|
236
|
+
- [Agent #18763 on BaseScan](https://basescan.org/address/0x8004A169FB4a3325136EB29fA0ceB6D2e539a432)
|
|
237
|
+
|
|
238
|
+
---
|
|
239
|
+
|
|
240
|
+
## License
|
|
241
|
+
|
|
242
|
+
MIT
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* @x402-api/mcp-server
|
|
4
|
+
*
|
|
5
|
+
* MCP (Model Context Protocol) server that wraps Sugi's x402 DeFi API.
|
|
6
|
+
* Gives Claude, ChatGPT, and any MCP-compatible AI agent access to
|
|
7
|
+
* pay-per-call crypto/DeFi data endpoints.
|
|
8
|
+
*
|
|
9
|
+
* ## x402 Payment Protocol
|
|
10
|
+
*
|
|
11
|
+
* Every endpoint costs a small USDC micropayment (0.001–0.008 USDC).
|
|
12
|
+
* Two modes:
|
|
13
|
+
*
|
|
14
|
+
* 1. **Auto-pay mode** — Set X402_WALLET_PRIVATE_KEY env var.
|
|
15
|
+
* x402-fetch handles the payment automatically. The agent just calls
|
|
16
|
+
* the tool and gets data.
|
|
17
|
+
*
|
|
18
|
+
* 2. **Manual mode** — No private key set. The tool returns 402 payment
|
|
19
|
+
* instructions so you (or the agent) can see what's needed.
|
|
20
|
+
*
|
|
21
|
+
* ## Setup
|
|
22
|
+
*
|
|
23
|
+
* export X402_WALLET_PRIVATE_KEY=0x...your_private_key...
|
|
24
|
+
* npx @x402-api/mcp-server
|
|
25
|
+
*
|
|
26
|
+
* Or in your Claude Desktop config:
|
|
27
|
+
* { "command": "npx", "args": ["@x402-api/mcp-server"] }
|
|
28
|
+
*/
|
|
29
|
+
export {};
|
|
30
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,377 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* @x402-api/mcp-server
|
|
4
|
+
*
|
|
5
|
+
* MCP (Model Context Protocol) server that wraps Sugi's x402 DeFi API.
|
|
6
|
+
* Gives Claude, ChatGPT, and any MCP-compatible AI agent access to
|
|
7
|
+
* pay-per-call crypto/DeFi data endpoints.
|
|
8
|
+
*
|
|
9
|
+
* ## x402 Payment Protocol
|
|
10
|
+
*
|
|
11
|
+
* Every endpoint costs a small USDC micropayment (0.001–0.008 USDC).
|
|
12
|
+
* Two modes:
|
|
13
|
+
*
|
|
14
|
+
* 1. **Auto-pay mode** — Set X402_WALLET_PRIVATE_KEY env var.
|
|
15
|
+
* x402-fetch handles the payment automatically. The agent just calls
|
|
16
|
+
* the tool and gets data.
|
|
17
|
+
*
|
|
18
|
+
* 2. **Manual mode** — No private key set. The tool returns 402 payment
|
|
19
|
+
* instructions so you (or the agent) can see what's needed.
|
|
20
|
+
*
|
|
21
|
+
* ## Setup
|
|
22
|
+
*
|
|
23
|
+
* export X402_WALLET_PRIVATE_KEY=0x...your_private_key...
|
|
24
|
+
* npx @x402-api/mcp-server
|
|
25
|
+
*
|
|
26
|
+
* Or in your Claude Desktop config:
|
|
27
|
+
* { "command": "npx", "args": ["@x402-api/mcp-server"] }
|
|
28
|
+
*/
|
|
29
|
+
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
30
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
31
|
+
import { CallToolRequestSchema, ListToolsRequestSchema, ErrorCode, McpError, } from '@modelcontextprotocol/sdk/types.js';
|
|
32
|
+
// ─── Configuration ────────────────────────────────────────────────────────────
|
|
33
|
+
const API_BASE_URL = process.env.X402_API_BASE_URL || 'https://x402-api.fly.dev';
|
|
34
|
+
const WALLET_PRIVATE_KEY = process.env.X402_WALLET_PRIVATE_KEY;
|
|
35
|
+
const SERVER_VERSION = '1.0.0';
|
|
36
|
+
let _fetchFn = null;
|
|
37
|
+
/**
|
|
38
|
+
* Returns a fetch function that auto-handles x402 payments if a wallet
|
|
39
|
+
* private key is configured. Falls back to standard fetch otherwise.
|
|
40
|
+
*/
|
|
41
|
+
async function getX402Fetch() {
|
|
42
|
+
if (_fetchFn)
|
|
43
|
+
return _fetchFn;
|
|
44
|
+
if (WALLET_PRIVATE_KEY) {
|
|
45
|
+
try {
|
|
46
|
+
// Dynamic imports for optional dependencies (x402-fetch, viem)
|
|
47
|
+
const dynImport = new Function('m', 'return import(m)');
|
|
48
|
+
const x402Module = await dynImport('x402-fetch').catch(() => null);
|
|
49
|
+
if (x402Module?.wrapFetchWithPayment) {
|
|
50
|
+
const viemModule = await dynImport('viem');
|
|
51
|
+
const viemAccounts = await dynImport('viem/accounts');
|
|
52
|
+
const viemChains = await dynImport('viem/chains');
|
|
53
|
+
const privateKeyToAccount = viemAccounts['privateKeyToAccount'];
|
|
54
|
+
const createWalletClient = viemModule['createWalletClient'];
|
|
55
|
+
const http = viemModule['http'];
|
|
56
|
+
const base = viemChains['base'];
|
|
57
|
+
const account = privateKeyToAccount(WALLET_PRIVATE_KEY);
|
|
58
|
+
const walletClient = createWalletClient({
|
|
59
|
+
account,
|
|
60
|
+
chain: base,
|
|
61
|
+
transport: http(),
|
|
62
|
+
});
|
|
63
|
+
const wrapFetch = x402Module['wrapFetchWithPayment'];
|
|
64
|
+
_fetchFn = wrapFetch(fetch, walletClient);
|
|
65
|
+
process.stderr.write(`[x402-mcp] Auto-pay enabled. Wallet: ${account.address}\n`);
|
|
66
|
+
return _fetchFn;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
catch (err) {
|
|
70
|
+
process.stderr.write(`[x402-mcp] Warning: X402_WALLET_PRIVATE_KEY is set but x402-fetch/viem ` +
|
|
71
|
+
`are not installed. Falling back to manual mode.\n` +
|
|
72
|
+
` Run: npm install x402-fetch viem\n`);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
// Standard fetch — 402s will surface as payment instruction responses
|
|
76
|
+
_fetchFn = fetch;
|
|
77
|
+
return _fetchFn;
|
|
78
|
+
}
|
|
79
|
+
async function callApi(endpoint, params = {}) {
|
|
80
|
+
const url = new URL(`${API_BASE_URL}${endpoint}`);
|
|
81
|
+
for (const [key, value] of Object.entries(params)) {
|
|
82
|
+
if (value !== undefined && value !== '') {
|
|
83
|
+
url.searchParams.set(key, String(value));
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
const fetchFn = await getX402Fetch();
|
|
87
|
+
let response;
|
|
88
|
+
try {
|
|
89
|
+
response = await fetchFn(url.toString(), {
|
|
90
|
+
headers: {
|
|
91
|
+
'Accept': 'application/json',
|
|
92
|
+
'User-Agent': `x402-api-mcp/${SERVER_VERSION}`,
|
|
93
|
+
},
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
catch (err) {
|
|
97
|
+
throw new McpError(ErrorCode.InternalError, `Network error calling ${endpoint}: ${err instanceof Error ? err.message : String(err)}`);
|
|
98
|
+
}
|
|
99
|
+
if (response.status === 402) {
|
|
100
|
+
let paymentDetails;
|
|
101
|
+
try {
|
|
102
|
+
paymentDetails = await response.json();
|
|
103
|
+
}
|
|
104
|
+
catch {
|
|
105
|
+
paymentDetails = await response.text();
|
|
106
|
+
}
|
|
107
|
+
return { status: 402, data: null, paymentRequired: true, paymentDetails };
|
|
108
|
+
}
|
|
109
|
+
if (!response.ok) {
|
|
110
|
+
const errorText = await response.text();
|
|
111
|
+
throw new McpError(ErrorCode.InternalError, `API error ${response.status} from ${endpoint}: ${errorText}`);
|
|
112
|
+
}
|
|
113
|
+
const data = await response.json();
|
|
114
|
+
return { status: response.status, data };
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Format a successful API response or payment instructions.
|
|
118
|
+
*/
|
|
119
|
+
function formatResult(result, toolName) {
|
|
120
|
+
if (result.paymentRequired) {
|
|
121
|
+
const details = result.paymentDetails;
|
|
122
|
+
const accepts = details?.accepts;
|
|
123
|
+
const first = accepts?.[0];
|
|
124
|
+
let message = `## Payment Required — ${toolName}\n\n`;
|
|
125
|
+
message += `This endpoint requires a USDC micropayment on Base network.\n\n`;
|
|
126
|
+
if (first) {
|
|
127
|
+
const amountRaw = Number(first.maxAmountRequired ?? 0);
|
|
128
|
+
const amountUsdc = (amountRaw / 1_000_000).toFixed(6);
|
|
129
|
+
message += `**Cost:** ${amountUsdc} USDC\n`;
|
|
130
|
+
message += `**Pay to:** \`${first.payTo}\`\n`;
|
|
131
|
+
message += `**Network:** Base mainnet (chain ID 8453)\n`;
|
|
132
|
+
message += `**Asset:** USDC (\`0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913\`)\n\n`;
|
|
133
|
+
}
|
|
134
|
+
message += `### To enable automatic payments:\n\n`;
|
|
135
|
+
message += `1. Install dependencies:\n`;
|
|
136
|
+
message += ` \`\`\`bash\n npm install x402-fetch viem\n \`\`\`\n\n`;
|
|
137
|
+
message += `2. Set your wallet private key:\n`;
|
|
138
|
+
message += ` \`\`\`bash\n export X402_WALLET_PRIVATE_KEY=0x...\n \`\`\`\n\n`;
|
|
139
|
+
message += `3. Restart the MCP server.\n\n`;
|
|
140
|
+
message += `### To pay manually:\n\n`;
|
|
141
|
+
message += `Send a USDC transfer to the address above on Base, then include `;
|
|
142
|
+
message += `the transaction hash as \`X-Payment\` header on your request.\n\n`;
|
|
143
|
+
message += `---\n**Raw 402 response:**\n\`\`\`json\n`;
|
|
144
|
+
message += JSON.stringify(result.paymentDetails, null, 2);
|
|
145
|
+
message += `\n\`\`\``;
|
|
146
|
+
return message;
|
|
147
|
+
}
|
|
148
|
+
return JSON.stringify(result.data, null, 2);
|
|
149
|
+
}
|
|
150
|
+
// ─── Tool Definitions ─────────────────────────────────────────────────────────
|
|
151
|
+
const TOOLS = [
|
|
152
|
+
{
|
|
153
|
+
name: 'get_crypto_prices',
|
|
154
|
+
description: 'Get live cryptocurrency prices and top 24h movers. Returns BTC, ETH, SOL prices plus top gainers/losers. ' +
|
|
155
|
+
'Costs 0.001 USDC per call (x402 micropayment on Base). ' +
|
|
156
|
+
'Data sourced live from CoinGecko.',
|
|
157
|
+
inputSchema: {
|
|
158
|
+
type: 'object',
|
|
159
|
+
properties: {},
|
|
160
|
+
required: [],
|
|
161
|
+
},
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
name: 'get_gas_prices',
|
|
165
|
+
description: 'Get current gas prices across multiple chains: Ethereum, Base, Polygon, and Arbitrum. ' +
|
|
166
|
+
'Returns slow/standard/fast tiers in gwei and estimated USD cost. ' +
|
|
167
|
+
'Costs 0.001 USDC per call (x402 micropayment on Base).',
|
|
168
|
+
inputSchema: {
|
|
169
|
+
type: 'object',
|
|
170
|
+
properties: {},
|
|
171
|
+
required: [],
|
|
172
|
+
},
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
name: 'get_dex_quotes',
|
|
176
|
+
description: 'Compare swap quotes across DEXes: Uniswap, SushiSwap, and 1inch. ' +
|
|
177
|
+
'Returns best price, price impact, liquidity, and estimated fees for each venue. ' +
|
|
178
|
+
'Costs 0.002 USDC per call (x402 micropayment on Base).',
|
|
179
|
+
inputSchema: {
|
|
180
|
+
type: 'object',
|
|
181
|
+
properties: {
|
|
182
|
+
from: {
|
|
183
|
+
type: 'string',
|
|
184
|
+
description: 'Input token symbol or address (e.g. "ETH", "USDC", "0x...")',
|
|
185
|
+
},
|
|
186
|
+
to: {
|
|
187
|
+
type: 'string',
|
|
188
|
+
description: 'Output token symbol or address (e.g. "USDC", "DAI", "0x...")',
|
|
189
|
+
},
|
|
190
|
+
amount: {
|
|
191
|
+
type: 'string',
|
|
192
|
+
description: 'Amount to swap (e.g. "1.5" for 1.5 ETH)',
|
|
193
|
+
},
|
|
194
|
+
},
|
|
195
|
+
required: ['from', 'to', 'amount'],
|
|
196
|
+
},
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
name: 'scan_token',
|
|
200
|
+
description: 'Perform a security scan on a token contract. Detects rug-pull risks, honeypot patterns, ' +
|
|
201
|
+
'ownership concentration, mint authority, and other red flags. ' +
|
|
202
|
+
'Costs 0.003 USDC per call (x402 micropayment on Base).',
|
|
203
|
+
inputSchema: {
|
|
204
|
+
type: 'object',
|
|
205
|
+
properties: {
|
|
206
|
+
token: {
|
|
207
|
+
type: 'string',
|
|
208
|
+
description: 'Token contract address (0x...) or symbol (e.g. "PEPE", "UNI")',
|
|
209
|
+
},
|
|
210
|
+
},
|
|
211
|
+
required: ['token'],
|
|
212
|
+
},
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
name: 'track_whales',
|
|
216
|
+
description: 'Analyze whale activity and holder concentration for a token. Returns top holders, ' +
|
|
217
|
+
'Gini coefficient, whale alerts (large recent buys/sells), and distribution breakdown. ' +
|
|
218
|
+
'Costs 0.005 USDC per call (x402 micropayment on Base).',
|
|
219
|
+
inputSchema: {
|
|
220
|
+
type: 'object',
|
|
221
|
+
properties: {
|
|
222
|
+
token: {
|
|
223
|
+
type: 'string',
|
|
224
|
+
description: 'Token contract address (0x...) or symbol (e.g. "ETH", "PEPE")',
|
|
225
|
+
},
|
|
226
|
+
},
|
|
227
|
+
required: ['token'],
|
|
228
|
+
},
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
name: 'scan_yields',
|
|
232
|
+
description: 'Scan top DeFi yield opportunities across protocols: Aave, Compound, Morpho, Lido, Pendle, and more. ' +
|
|
233
|
+
'Filter by chain and minimum TVL. Returns APY, TVL, risk score, and protocol details. ' +
|
|
234
|
+
'Costs 0.005 USDC per call (x402 micropayment on Base).',
|
|
235
|
+
inputSchema: {
|
|
236
|
+
type: 'object',
|
|
237
|
+
properties: {
|
|
238
|
+
chain: {
|
|
239
|
+
type: 'string',
|
|
240
|
+
description: 'Blockchain to filter by (e.g. "ethereum", "base", "arbitrum", "polygon"). ' +
|
|
241
|
+
'Omit for all chains.',
|
|
242
|
+
},
|
|
243
|
+
min_tvl: {
|
|
244
|
+
type: 'number',
|
|
245
|
+
description: 'Minimum TVL in USD (e.g. 1000000 for $1M). Omit for no minimum.',
|
|
246
|
+
},
|
|
247
|
+
},
|
|
248
|
+
required: [],
|
|
249
|
+
},
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
name: 'get_funding_rates',
|
|
253
|
+
description: 'Get perpetual futures funding rates across 6 venues (Binance, OKX, Bybit, dYdX, GMX, Hyperliquid). ' +
|
|
254
|
+
'Returns current rates, 7d average, annualized rate, and arbitrage opportunity ranking. ' +
|
|
255
|
+
'Costs 0.008 USDC per call (x402 micropayment on Base).',
|
|
256
|
+
inputSchema: {
|
|
257
|
+
type: 'object',
|
|
258
|
+
properties: {
|
|
259
|
+
asset: {
|
|
260
|
+
type: 'string',
|
|
261
|
+
description: 'Asset symbol (e.g. "BTC", "ETH", "SOL"). Returns all assets if omitted.',
|
|
262
|
+
},
|
|
263
|
+
},
|
|
264
|
+
required: [],
|
|
265
|
+
},
|
|
266
|
+
},
|
|
267
|
+
{
|
|
268
|
+
name: 'profile_wallet',
|
|
269
|
+
description: 'Generate a full portfolio profile for an Ethereum/Base wallet address. ' +
|
|
270
|
+
'Returns token holdings, NFTs, DeFi positions, transaction history summary, ' +
|
|
271
|
+
'PnL estimate, and risk profile score. ' +
|
|
272
|
+
'Costs 0.008 USDC per call (x402 micropayment on Base).',
|
|
273
|
+
inputSchema: {
|
|
274
|
+
type: 'object',
|
|
275
|
+
properties: {
|
|
276
|
+
address: {
|
|
277
|
+
type: 'string',
|
|
278
|
+
description: 'Ethereum or Base wallet address (0x...)',
|
|
279
|
+
},
|
|
280
|
+
},
|
|
281
|
+
required: ['address'],
|
|
282
|
+
},
|
|
283
|
+
},
|
|
284
|
+
];
|
|
285
|
+
// ─── MCP Server ───────────────────────────────────────────────────────────────
|
|
286
|
+
const server = new Server({
|
|
287
|
+
name: 'x402-api-mcp',
|
|
288
|
+
version: SERVER_VERSION,
|
|
289
|
+
}, {
|
|
290
|
+
capabilities: {
|
|
291
|
+
tools: {},
|
|
292
|
+
},
|
|
293
|
+
});
|
|
294
|
+
// List tools handler
|
|
295
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => ({
|
|
296
|
+
tools: TOOLS,
|
|
297
|
+
}));
|
|
298
|
+
// Call tool handler
|
|
299
|
+
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
300
|
+
const { name, arguments: args } = request.params;
|
|
301
|
+
const params = (args ?? {});
|
|
302
|
+
let result;
|
|
303
|
+
switch (name) {
|
|
304
|
+
case 'get_crypto_prices':
|
|
305
|
+
result = await callApi('/api/price-feed');
|
|
306
|
+
break;
|
|
307
|
+
case 'get_gas_prices':
|
|
308
|
+
result = await callApi('/api/gas-tracker');
|
|
309
|
+
break;
|
|
310
|
+
case 'get_dex_quotes':
|
|
311
|
+
if (!params.from || !params.to || !params.amount) {
|
|
312
|
+
throw new McpError(ErrorCode.InvalidParams, 'get_dex_quotes requires: from, to, amount');
|
|
313
|
+
}
|
|
314
|
+
result = await callApi('/api/dex-quotes', {
|
|
315
|
+
from: params.from,
|
|
316
|
+
to: params.to,
|
|
317
|
+
amount: params.amount,
|
|
318
|
+
});
|
|
319
|
+
break;
|
|
320
|
+
case 'scan_token':
|
|
321
|
+
if (!params.token) {
|
|
322
|
+
throw new McpError(ErrorCode.InvalidParams, 'scan_token requires: token');
|
|
323
|
+
}
|
|
324
|
+
result = await callApi('/api/token-scanner', { token: params.token });
|
|
325
|
+
break;
|
|
326
|
+
case 'track_whales':
|
|
327
|
+
if (!params.token) {
|
|
328
|
+
throw new McpError(ErrorCode.InvalidParams, 'track_whales requires: token');
|
|
329
|
+
}
|
|
330
|
+
result = await callApi('/api/whale-tracker', { token: params.token });
|
|
331
|
+
break;
|
|
332
|
+
case 'scan_yields':
|
|
333
|
+
result = await callApi('/api/yield-scanner', {
|
|
334
|
+
chain: params.chain,
|
|
335
|
+
min_tvl: params.min_tvl,
|
|
336
|
+
});
|
|
337
|
+
break;
|
|
338
|
+
case 'get_funding_rates':
|
|
339
|
+
result = await callApi('/api/funding-rates', { asset: params.asset });
|
|
340
|
+
break;
|
|
341
|
+
case 'profile_wallet':
|
|
342
|
+
if (!params.address) {
|
|
343
|
+
throw new McpError(ErrorCode.InvalidParams, 'profile_wallet requires: address');
|
|
344
|
+
}
|
|
345
|
+
result = await callApi('/api/wallet-profiler', { address: params.address });
|
|
346
|
+
break;
|
|
347
|
+
default:
|
|
348
|
+
throw new McpError(ErrorCode.MethodNotFound, `Unknown tool: ${name}`);
|
|
349
|
+
}
|
|
350
|
+
const text = formatResult(result, name);
|
|
351
|
+
return {
|
|
352
|
+
content: [
|
|
353
|
+
{
|
|
354
|
+
type: 'text',
|
|
355
|
+
text,
|
|
356
|
+
},
|
|
357
|
+
],
|
|
358
|
+
isError: false,
|
|
359
|
+
};
|
|
360
|
+
});
|
|
361
|
+
// ─── Start ────────────────────────────────────────────────────────────────────
|
|
362
|
+
async function main() {
|
|
363
|
+
const transport = new StdioServerTransport();
|
|
364
|
+
await server.connect(transport);
|
|
365
|
+
const payMode = WALLET_PRIVATE_KEY
|
|
366
|
+
? 'AUTO-PAY (x402-fetch)'
|
|
367
|
+
: 'MANUAL (returns 402 payment instructions)';
|
|
368
|
+
process.stderr.write(`[x402-mcp] Server started\n` +
|
|
369
|
+
`[x402-mcp] API: ${API_BASE_URL}\n` +
|
|
370
|
+
`[x402-mcp] Payment mode: ${payMode}\n` +
|
|
371
|
+
`[x402-mcp] Tools: ${TOOLS.map((t) => t.name).join(', ')}\n`);
|
|
372
|
+
}
|
|
373
|
+
main().catch((err) => {
|
|
374
|
+
process.stderr.write(`[x402-mcp] Fatal error: ${err}\n`);
|
|
375
|
+
process.exit(1);
|
|
376
|
+
});
|
|
377
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACtB,SAAS,EACT,QAAQ,GACT,MAAM,oCAAoC,CAAC;AAE5C,iFAAiF;AAEjF,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC,iBAAiB,IAAI,0BAA0B,CAAC;AACjF,MAAM,kBAAkB,GAAG,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC;AAC/D,MAAM,cAAc,GAAG,OAAO,CAAC;AAM/B,IAAI,QAAQ,GAAmB,IAAI,CAAC;AAEpC;;;GAGG;AACH,KAAK,UAAU,YAAY;IACzB,IAAI,QAAQ;QAAE,OAAO,QAAQ,CAAC;IAE9B,IAAI,kBAAkB,EAAE,CAAC;QACvB,IAAI,CAAC;YACH,+DAA+D;YAC/D,MAAM,SAAS,GAAG,IAAI,QAAQ,CAAC,GAAG,EAAE,kBAAkB,CACL,CAAC;YAElD,MAAM,UAAU,GAAG,MAAM,SAAS,CAAC,YAAY,CAAC,CAAC,KAAK,CAAC,G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ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@x402-api/mcp-server",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "MCP server for Sugi's x402 DeFi API — gives Claude, ChatGPT, and MCP-compatible agents access to pay-per-call crypto/DeFi data",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"x402-api-mcp": "./dist/index.js"
|
|
8
|
+
},
|
|
9
|
+
"main": "dist/index.js",
|
|
10
|
+
"types": "dist/index.d.ts",
|
|
11
|
+
"files": [
|
|
12
|
+
"dist",
|
|
13
|
+
"package.json",
|
|
14
|
+
"README.md",
|
|
15
|
+
"LICENSE"
|
|
16
|
+
],
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "tsc",
|
|
19
|
+
"dev": "tsc --watch",
|
|
20
|
+
"start": "node dist/index.js",
|
|
21
|
+
"clean": "rm -rf dist",
|
|
22
|
+
"prepublishOnly": "npm run build"
|
|
23
|
+
},
|
|
24
|
+
"keywords": [
|
|
25
|
+
"mcp",
|
|
26
|
+
"model-context-protocol",
|
|
27
|
+
"x402",
|
|
28
|
+
"defi",
|
|
29
|
+
"crypto",
|
|
30
|
+
"ai-agent",
|
|
31
|
+
"claude",
|
|
32
|
+
"usdc",
|
|
33
|
+
"base",
|
|
34
|
+
"price-feed",
|
|
35
|
+
"gas-tracker",
|
|
36
|
+
"dex",
|
|
37
|
+
"yield",
|
|
38
|
+
"whale-tracker",
|
|
39
|
+
"funding-rates",
|
|
40
|
+
"wallet-profiler"
|
|
41
|
+
],
|
|
42
|
+
"author": "Sugi",
|
|
43
|
+
"license": "MIT",
|
|
44
|
+
"repository": {
|
|
45
|
+
"type": "git",
|
|
46
|
+
"url": "https://github.com/fernsugi/x402-api-server",
|
|
47
|
+
"directory": "mcp-server"
|
|
48
|
+
},
|
|
49
|
+
"dependencies": {
|
|
50
|
+
"@modelcontextprotocol/sdk": "^1.26.0"
|
|
51
|
+
},
|
|
52
|
+
"optionalDependencies": {
|
|
53
|
+
"viem": "^2.0.0",
|
|
54
|
+
"x402-fetch": "^1.0.0"
|
|
55
|
+
},
|
|
56
|
+
"devDependencies": {
|
|
57
|
+
"@types/node": "^22.19.11",
|
|
58
|
+
"typescript": "^5.9.3"
|
|
59
|
+
},
|
|
60
|
+
"engines": {
|
|
61
|
+
"node": ">=18.0.0"
|
|
62
|
+
},
|
|
63
|
+
"publishConfig": {
|
|
64
|
+
"access": "public"
|
|
65
|
+
}
|
|
66
|
+
}
|