drain-mcp 0.2.1 → 0.2.3
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 +382 -262
- package/dist/config.d.ts.map +1 -1
- package/dist/index.js +54 -54
- package/dist/index.js.map +1 -1
- package/dist/tools/balance.d.ts.map +1 -1
- package/dist/tools/balance.js +47 -29
- package/dist/tools/balance.js.map +1 -1
- package/dist/tools/channel.js +79 -79
- package/dist/tools/chat.js +15 -15
- package/dist/tools/providers.js +27 -27
- package/package.json +50 -50
package/README.md
CHANGED
|
@@ -1,262 +1,382 @@
|
|
|
1
|
-
# DRAIN MCP Server
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
-
|
|
9
|
-
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
"model": "gpt-4o",
|
|
89
|
-
"
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
|
242
|
-
|
|
243
|
-
|
|
|
244
|
-
|
|
|
245
|
-
|
|
|
246
|
-
|
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
1
|
+
# DRAIN MCP Server
|
|
2
|
+
|
|
3
|
+
**Payments for AI Agents** — No API keys, no credit cards, no subscriptions.
|
|
4
|
+
|
|
5
|
+
MCP server for the DRAIN payment protocol. Agents discover service providers, open USDC payment channels on Polygon, and call any service — LLM inference, web scraping, image generation, VPN, and more.
|
|
6
|
+
|
|
7
|
+
- **One-time gas cost:** ~$0.02 to open a channel
|
|
8
|
+
- **Per request:** $0.0001–$0.01 depending on service
|
|
9
|
+
- **Setup time:** 30 seconds
|
|
10
|
+
|
|
11
|
+
## When to Use DRAIN
|
|
12
|
+
|
|
13
|
+
Use DRAIN when you need to:
|
|
14
|
+
- Call any service (LLM, scraping, image generation, etc.) without API keys
|
|
15
|
+
- Pay per-request with USDC on Polygon
|
|
16
|
+
- Access multiple service types through one protocol
|
|
17
|
+
|
|
18
|
+
Do NOT use DRAIN when:
|
|
19
|
+
- You already have API keys for the service you need
|
|
20
|
+
- The task doesn't require external services
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## TL;DR - Minimum Viable Workflow
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
1. drain_providers() → Find providers (filter by model or category)
|
|
28
|
+
2. drain_provider_info(id) → Get provider details + usage docs
|
|
29
|
+
3. drain_balance() → Check USDC + POL
|
|
30
|
+
4. drain_approve() → Approve USDC spending (once)
|
|
31
|
+
5. drain_open_channel(...) → Deposit USDC, get channelId
|
|
32
|
+
6. drain_chat(...) → Send requests (repeat as needed)
|
|
33
|
+
7. drain_cooperative_close(...) → Close early, instant refund (when task is done)
|
|
34
|
+
— OR after expiry —
|
|
35
|
+
8. drain_close_channel(...) → Reclaim funds (after expiry)
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## When to Close a Channel
|
|
41
|
+
|
|
42
|
+
- **Done with your task?** → Use `drain_cooperative_close(channelId)`.
|
|
43
|
+
Instant refund of unspent deposit. Always do this when finished.
|
|
44
|
+
|
|
45
|
+
- **Planning more requests soon?** → Keep the channel open.
|
|
46
|
+
No need to close and reopen — saves $0.04 in gas fees.
|
|
47
|
+
|
|
48
|
+
- **Channel expired?** → Use `drain_close_channel(channelId)`.
|
|
49
|
+
Reclaims unspent USDC after the expiry timestamp.
|
|
50
|
+
Funds do NOT return automatically.
|
|
51
|
+
|
|
52
|
+
**Rule of thumb:** Close when the task is done. Keep open while working.
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
## Already Hit a 402?
|
|
57
|
+
|
|
58
|
+
DRAIN providers return `402 Payment Required` with headers when no payment voucher is sent:
|
|
59
|
+
|
|
60
|
+
| Header | Value |
|
|
61
|
+
|---|---|
|
|
62
|
+
| `X-Payment-Protocol` | `drain-v2` |
|
|
63
|
+
| `X-Payment-Provider` | Provider wallet address (open channel to this) |
|
|
64
|
+
| `X-Payment-Contract` | DRAIN contract address |
|
|
65
|
+
| `X-Payment-Chain` | `137` (Polygon Mainnet) |
|
|
66
|
+
| `X-Payment-Signing` | URL for EIP-712 signing parameters |
|
|
67
|
+
| `X-Payment-Docs` | Provider docs endpoint |
|
|
68
|
+
|
|
69
|
+
**Flow:**
|
|
70
|
+
1. Call a provider endpoint (no voucher) → get `402` with headers
|
|
71
|
+
2. Install `drain-mcp` or use the signing API at the `X-Payment-Signing` URL
|
|
72
|
+
3. Open a channel to the `X-Payment-Provider` address
|
|
73
|
+
4. Retry the request with an `X-DRAIN-Voucher` header
|
|
74
|
+
|
|
75
|
+
Everything you need is in the 402 response. No prior registration required.
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
## Tools Reference
|
|
80
|
+
|
|
81
|
+
### Discovery
|
|
82
|
+
|
|
83
|
+
#### drain_providers
|
|
84
|
+
Find service providers. Filter by model name, category, or online status.
|
|
85
|
+
|
|
86
|
+
```json
|
|
87
|
+
{
|
|
88
|
+
"model": "gpt-4o",
|
|
89
|
+
"category": "scraping",
|
|
90
|
+
"onlineOnly": true
|
|
91
|
+
}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Categories: `llm`, `image`, `audio`, `code`, `scraping`, `vpn`, `multi-modal`, `other`
|
|
95
|
+
|
|
96
|
+
#### drain_provider_info
|
|
97
|
+
Get details about a provider including usage instructions (docs). The docs explain how to format requests for that provider.
|
|
98
|
+
|
|
99
|
+
```json
|
|
100
|
+
{ "providerId": "hs58-openai" }
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### Wallet
|
|
104
|
+
|
|
105
|
+
#### drain_balance
|
|
106
|
+
Check wallet USDC balance, POL for gas, and DRAIN contract allowance.
|
|
107
|
+
|
|
108
|
+
#### drain_approve
|
|
109
|
+
Approve USDC spending for the DRAIN contract. Required once before opening channels.
|
|
110
|
+
|
|
111
|
+
```json
|
|
112
|
+
{ "amount": "100" }
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### Channels
|
|
116
|
+
|
|
117
|
+
#### drain_open_channel
|
|
118
|
+
Open a payment channel. Locks USDC for the specified duration.
|
|
119
|
+
|
|
120
|
+
```json
|
|
121
|
+
{
|
|
122
|
+
"provider": "hs58-openai",
|
|
123
|
+
"amount": "5.00",
|
|
124
|
+
"duration": "24h"
|
|
125
|
+
}
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
Returns channelId, expiry time, and provider usage docs.
|
|
129
|
+
|
|
130
|
+
#### drain_channel_status
|
|
131
|
+
Check a channel's deposit, spending, remaining balance, and expiry.
|
|
132
|
+
|
|
133
|
+
#### drain_channels
|
|
134
|
+
List all known channels with status (active/expired/closed). Find expired channels that need closing.
|
|
135
|
+
|
|
136
|
+
### Usage
|
|
137
|
+
|
|
138
|
+
#### drain_chat
|
|
139
|
+
Send a paid request through a channel. Works for ALL provider types:
|
|
140
|
+
|
|
141
|
+
- **LLM providers:** Standard chat messages
|
|
142
|
+
- **Non-LLM providers:** JSON payload in the user message content (check provider docs)
|
|
143
|
+
|
|
144
|
+
```json
|
|
145
|
+
{
|
|
146
|
+
"channelId": "0x...",
|
|
147
|
+
"model": "gpt-4o",
|
|
148
|
+
"messages": [{"role": "user", "content": "Hello"}]
|
|
149
|
+
}
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### Settlement
|
|
153
|
+
|
|
154
|
+
#### drain_cooperative_close
|
|
155
|
+
Close a channel early with provider consent. **Use this when your task is done** — instant refund of unspent deposit. No need to wait for expiry.
|
|
156
|
+
|
|
157
|
+
```json
|
|
158
|
+
{ "channelId": "0x..." }
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
#### drain_close_channel
|
|
162
|
+
Close an expired channel and reclaim unspent USDC. Use when the channel has passed its expiry timestamp.
|
|
163
|
+
|
|
164
|
+
```json
|
|
165
|
+
{ "channelId": "0x..." }
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
---
|
|
169
|
+
|
|
170
|
+
## Economics Example
|
|
171
|
+
|
|
172
|
+
Opening a GPT-4o channel:
|
|
173
|
+
|
|
174
|
+
```
|
|
175
|
+
Gas to open channel: $0.02 (one-time)
|
|
176
|
+
Deposit: $0.50 (refundable remainder)
|
|
177
|
+
Per request: ~$0.001755
|
|
178
|
+
Requests possible: ~285
|
|
179
|
+
|
|
180
|
+
Cost for 10 requests: $0.02 gas + $0.01755 usage = $0.04
|
|
181
|
+
Refund after close: $0.50 - $0.01755 = $0.48
|
|
182
|
+
Gas to close: $0.02
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
- Protocol fee: 2% on provider claims (on-chain)
|
|
186
|
+
- Session fee: none
|
|
187
|
+
- Live pricing: `GET https://handshake58.com/api/mcp/providers`
|
|
188
|
+
|
|
189
|
+
---
|
|
190
|
+
|
|
191
|
+
## Provider Categories
|
|
192
|
+
|
|
193
|
+
Providers are not limited to LLM chat. Each provider has a `category` field and a docs endpoint explaining how to format requests.
|
|
194
|
+
|
|
195
|
+
| Category | Description | Message Format |
|
|
196
|
+
|----------|-------------|----------------|
|
|
197
|
+
| llm | Language models (GPT-4o, Claude, Grok, Gemini) | Standard chat messages |
|
|
198
|
+
| image | Image generation | JSON in user content (see docs) |
|
|
199
|
+
| audio | Audio/TTS/STT | JSON in user content (see docs) |
|
|
200
|
+
| code | Code generation | Standard chat or JSON (see docs) |
|
|
201
|
+
| scraping | Web scraping, data extraction | JSON in user content (see docs) |
|
|
202
|
+
| vpn | VPN services | JSON in user content (see docs) |
|
|
203
|
+
| multi-modal | Multi-modal models | Standard chat messages |
|
|
204
|
+
| other | Everything else | Always check docs |
|
|
205
|
+
|
|
206
|
+
**Rule: For any category other than `llm`, call `drain_provider_info` first to read the docs.**
|
|
207
|
+
|
|
208
|
+
---
|
|
209
|
+
|
|
210
|
+
## Decision Trees
|
|
211
|
+
|
|
212
|
+
### Starting a Session
|
|
213
|
+
|
|
214
|
+
```
|
|
215
|
+
Do I have an active channel?
|
|
216
|
+
├── YES → Use drain_chat() with existing channelId
|
|
217
|
+
└── NO →
|
|
218
|
+
├── drain_balance() → Do I have USDC?
|
|
219
|
+
│ ├── NO → Cannot proceed. Need USDC on Polygon.
|
|
220
|
+
│ └── YES →
|
|
221
|
+
│ ├── drain_providers() → Find provider
|
|
222
|
+
│ │ ├── NO providers → Cannot proceed.
|
|
223
|
+
│ │ └── Found provider →
|
|
224
|
+
│ │ ├── drain_approve() → First time only
|
|
225
|
+
│ │ └── drain_open_channel() → Get channelId
|
|
226
|
+
│ │ └── drain_chat() → Send requests
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
### Ending a Session
|
|
230
|
+
|
|
231
|
+
```
|
|
232
|
+
Am I done with this task?
|
|
233
|
+
├── YES → drain_cooperative_close(channelId) → Instant refund
|
|
234
|
+
└── NO →
|
|
235
|
+
├── More requests soon? → Keep channel open
|
|
236
|
+
└── Channel expired? → drain_close_channel(channelId) → Reclaim funds
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
### Choosing Amount and Duration
|
|
240
|
+
|
|
241
|
+
| Use Case | Amount | Duration |
|
|
242
|
+
|----------|--------|----------|
|
|
243
|
+
| Quick test / single query | $0.50 - $1 | 1h |
|
|
244
|
+
| Short task (few queries) | $2 - $5 | 4h |
|
|
245
|
+
| Extended session | $5 - $20 | 24h |
|
|
246
|
+
| Long-running agent | $20 - $100 | 7d |
|
|
247
|
+
|
|
248
|
+
### Handling Errors
|
|
249
|
+
|
|
250
|
+
```
|
|
251
|
+
"Insufficient balance"
|
|
252
|
+
→ Need more USDC. Check drain_balance().
|
|
253
|
+
|
|
254
|
+
"Insufficient allowance"
|
|
255
|
+
→ Run drain_approve().
|
|
256
|
+
|
|
257
|
+
"Channel not found"
|
|
258
|
+
→ channelId is wrong or channel was closed. Open new channel.
|
|
259
|
+
|
|
260
|
+
"Channel expired"
|
|
261
|
+
→ For drain_chat: Open a new channel.
|
|
262
|
+
→ For drain_close_channel: Expected. Proceed with close.
|
|
263
|
+
|
|
264
|
+
"Insufficient channel balance"
|
|
265
|
+
→ Channel deposit used up. Open new channel with more funds.
|
|
266
|
+
|
|
267
|
+
"Provider offline"
|
|
268
|
+
→ Use drain_providers() to find alternative provider.
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
---
|
|
272
|
+
|
|
273
|
+
## Setup
|
|
274
|
+
|
|
275
|
+
### 1. Install
|
|
276
|
+
|
|
277
|
+
```bash
|
|
278
|
+
npm install -g drain-mcp
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
### 2. Create a Wallet (locally)
|
|
282
|
+
|
|
283
|
+
Generate a key on your own machine — nothing is sent over the network:
|
|
284
|
+
|
|
285
|
+
```bash
|
|
286
|
+
node -e "const w=require('ethers').Wallet.createRandom();console.log('Address:', w.address, '\nKey:', w.privateKey)"
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
### 3. Fund the Wallet
|
|
290
|
+
|
|
291
|
+
Send **$1–5 USDC** on **Polygon Mainnet** to your wallet address.
|
|
292
|
+
Use a dedicated low-value wallet — never your main wallet.
|
|
293
|
+
|
|
294
|
+
**No POL needed** — if your wallet holds $5+ USDC, free gas is provided:
|
|
295
|
+
|
|
296
|
+
```bash
|
|
297
|
+
curl -X POST https://handshake58.com/api/gas-station \
|
|
298
|
+
-H "Content-Type: application/json" \
|
|
299
|
+
-d '{"address": "0x_your_wallet_address"}'
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
Returns 0.1 POL (~10K transactions). Sends only your public address.
|
|
303
|
+
|
|
304
|
+
### 4. Configure MCP Client
|
|
305
|
+
|
|
306
|
+
```json
|
|
307
|
+
{
|
|
308
|
+
"mcpServers": {
|
|
309
|
+
"drain": {
|
|
310
|
+
"command": "drain-mcp",
|
|
311
|
+
"env": { "DRAIN_PRIVATE_KEY": "0x..." }
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
### Environment Variables
|
|
318
|
+
|
|
319
|
+
| Variable | Required | Default |
|
|
320
|
+
|----------|----------|---------|
|
|
321
|
+
| `DRAIN_PRIVATE_KEY` | Yes | — |
|
|
322
|
+
| `DRAIN_CHAIN_ID` | No | 137 (Polygon) |
|
|
323
|
+
| `DRAIN_RPC_URL` | No | Public RPC |
|
|
324
|
+
|
|
325
|
+
---
|
|
326
|
+
|
|
327
|
+
## Security & Privacy
|
|
328
|
+
|
|
329
|
+
### Key Handling
|
|
330
|
+
`DRAIN_PRIVATE_KEY` is loaded into memory by the local MCP process. It is used for:
|
|
331
|
+
1. EIP-712 voucher signing (off-chain, no network call)
|
|
332
|
+
2. On-chain transaction signing (signed locally, only the signature is broadcast)
|
|
333
|
+
|
|
334
|
+
The key is never transmitted to any server. Providers verify signatures against on-chain state.
|
|
335
|
+
|
|
336
|
+
### Spending Limits
|
|
337
|
+
Exposure is capped by the smart contract:
|
|
338
|
+
- Maximum spend = channel deposit (you choose the amount)
|
|
339
|
+
- Channel has a fixed duration (you choose)
|
|
340
|
+
- After expiry, unspent funds are reclaimable via `drain_close_channel`
|
|
341
|
+
- No recurring charges, no stored payment methods
|
|
342
|
+
|
|
343
|
+
### What Leaves Your Machine
|
|
344
|
+
- Public API queries to handshake58.com (provider list, config, channel status)
|
|
345
|
+
- Request messages to providers (sent to the provider's apiUrl, NOT to Handshake58)
|
|
346
|
+
- Signed payment vouchers (contain a cryptographic signature, not the key)
|
|
347
|
+
- Signed on-chain transactions (broadcast to Polygon RPC)
|
|
348
|
+
|
|
349
|
+
### What Stays Local
|
|
350
|
+
- Private key (never transmitted)
|
|
351
|
+
- All cryptographic operations (signing happens in-process)
|
|
352
|
+
|
|
353
|
+
### External Endpoints
|
|
354
|
+
|
|
355
|
+
Every network request the MCP server makes:
|
|
356
|
+
|
|
357
|
+
| Endpoint | Method | Data Sent | Key Transmitted? |
|
|
358
|
+
|---|---|---|---|
|
|
359
|
+
| handshake58.com/api/mcp/providers | GET | Nothing (public catalog) | No |
|
|
360
|
+
| handshake58.com/api/directory/config | GET | Nothing (reads fee wallet) | No |
|
|
361
|
+
| handshake58.com/api/channels/status | GET | channelId (public on-chain data) | No |
|
|
362
|
+
| handshake58.com/api/gas-station | POST | Wallet address | No |
|
|
363
|
+
| Provider apiUrl /v1/docs | GET | Nothing (fetches usage docs) | No |
|
|
364
|
+
| Provider apiUrl /v1/chat/completions | POST | Request messages + signed voucher | No |
|
|
365
|
+
| Provider apiUrl /v1/close-channel | POST | channelId + close signature | No |
|
|
366
|
+
| Polygon RPC (on-chain tx) | POST | Signed transactions | No |
|
|
367
|
+
|
|
368
|
+
### Safeguards
|
|
369
|
+
- Use a **dedicated wallet** with $1–5 USDC. Never reuse your main wallet.
|
|
370
|
+
- Always generate keys **locally**. The key stays on your machine.
|
|
371
|
+
- **Open source**: [github.com/kimbo128/DRAIN](https://github.com/kimbo128/DRAIN) (MIT licensed)
|
|
372
|
+
- Open channels with small deposits. Close promptly when done.
|
|
373
|
+
|
|
374
|
+
---
|
|
375
|
+
|
|
376
|
+
## Links
|
|
377
|
+
|
|
378
|
+
- NPM: https://www.npmjs.com/package/drain-mcp
|
|
379
|
+
- GitHub: https://github.com/kimbo128/DRAIN
|
|
380
|
+
- Marketplace: https://handshake58.com
|
|
381
|
+
- Provider Directory: https://handshake58.com/directory
|
|
382
|
+
- Contract: `0x0C2B3aA1e80629D572b1f200e6DF3586B3946A8A` (Polygon Mainnet)
|