drain-mcp 0.1.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 +177 -0
- package/dist/config.d.ts +17530 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +74 -0
- package/dist/config.js.map +1 -0
- package/dist/constants.d.ts +174 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +119 -0
- package/dist/constants.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +170 -0
- package/dist/index.js.map +1 -0
- package/dist/services/channel.d.ts +79 -0
- package/dist/services/channel.d.ts.map +1 -0
- package/dist/services/channel.js +190 -0
- package/dist/services/channel.js.map +1 -0
- package/dist/services/inference.d.ts +54 -0
- package/dist/services/inference.d.ts.map +1 -0
- package/dist/services/inference.js +81 -0
- package/dist/services/inference.js.map +1 -0
- package/dist/services/provider.d.ts +70 -0
- package/dist/services/provider.d.ts.map +1 -0
- package/dist/services/provider.js +84 -0
- package/dist/services/provider.js.map +1 -0
- package/dist/services/wallet.d.ts +48 -0
- package/dist/services/wallet.d.ts.map +1 -0
- package/dist/services/wallet.js +102 -0
- package/dist/services/wallet.js.map +1 -0
- package/dist/tools/balance.d.ts +40 -0
- package/dist/tools/balance.d.ts.map +1 -0
- package/dist/tools/balance.js +86 -0
- package/dist/tools/balance.js.map +1 -0
- package/dist/tools/channel.d.ts +67 -0
- package/dist/tools/channel.d.ts.map +1 -0
- package/dist/tools/channel.js +177 -0
- package/dist/tools/channel.js.map +1 -0
- package/dist/tools/chat.d.ts +64 -0
- package/dist/tools/chat.d.ts.map +1 -0
- package/dist/tools/chat.js +118 -0
- package/dist/tools/chat.js.map +1 -0
- package/dist/tools/providers.d.ts +54 -0
- package/dist/tools/providers.d.ts.map +1 -0
- package/dist/tools/providers.js +102 -0
- package/dist/tools/providers.js.map +1 -0
- package/package.json +43 -0
package/README.md
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
# DRAIN MCP Server
|
|
2
|
+
|
|
3
|
+
Model Context Protocol (MCP) server for autonomous AI payments using the DRAIN protocol.
|
|
4
|
+
|
|
5
|
+
Enables AI agents to pay for AI inference without human intervention.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install -g drain-mcp
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Or run directly with npx:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npx drain-mcp
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Configuration
|
|
20
|
+
|
|
21
|
+
Set the following environment variables:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
# REQUIRED: Your agent's wallet private key
|
|
25
|
+
export DRAIN_PRIVATE_KEY="0x..."
|
|
26
|
+
|
|
27
|
+
# OPTIONAL: Network (default: 137 = Polygon Mainnet)
|
|
28
|
+
export DRAIN_CHAIN_ID="137"
|
|
29
|
+
|
|
30
|
+
# OPTIONAL: Custom RPC URL
|
|
31
|
+
export DRAIN_RPC_URL="https://polygon-rpc.com"
|
|
32
|
+
|
|
33
|
+
# OPTIONAL: Provider directory URL
|
|
34
|
+
export DRAIN_DIRECTORY_URL="https://drain-marketplace.railway.app/api/mcp/providers"
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Usage with Cursor
|
|
38
|
+
|
|
39
|
+
Add to your Cursor settings (`~/.cursor/mcp.json`):
|
|
40
|
+
|
|
41
|
+
```json
|
|
42
|
+
{
|
|
43
|
+
"mcpServers": {
|
|
44
|
+
"drain": {
|
|
45
|
+
"command": "npx",
|
|
46
|
+
"args": ["-y", "drain-mcp"],
|
|
47
|
+
"env": {
|
|
48
|
+
"DRAIN_PRIVATE_KEY": "0x..."
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Usage with Claude Desktop
|
|
56
|
+
|
|
57
|
+
Add to your Claude config (`~/Library/Application Support/Claude/claude_desktop_config.json`):
|
|
58
|
+
|
|
59
|
+
```json
|
|
60
|
+
{
|
|
61
|
+
"mcpServers": {
|
|
62
|
+
"drain": {
|
|
63
|
+
"command": "npx",
|
|
64
|
+
"args": ["-y", "drain-mcp"],
|
|
65
|
+
"env": {
|
|
66
|
+
"DRAIN_PRIVATE_KEY": "0x..."
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Available Tools
|
|
74
|
+
|
|
75
|
+
### Discovery
|
|
76
|
+
|
|
77
|
+
| Tool | Description |
|
|
78
|
+
|------|-------------|
|
|
79
|
+
| `drain_providers` | List available AI providers and their models |
|
|
80
|
+
| `drain_provider_info` | Get details about a specific provider |
|
|
81
|
+
|
|
82
|
+
### Wallet
|
|
83
|
+
|
|
84
|
+
| Tool | Description |
|
|
85
|
+
|------|-------------|
|
|
86
|
+
| `drain_balance` | Check USDC balance and wallet status |
|
|
87
|
+
| `drain_approve` | Approve USDC spending for DRAIN contract |
|
|
88
|
+
|
|
89
|
+
### Channels
|
|
90
|
+
|
|
91
|
+
| Tool | Description |
|
|
92
|
+
|------|-------------|
|
|
93
|
+
| `drain_open_channel` | Open a payment channel with a provider |
|
|
94
|
+
| `drain_close_channel` | Close an expired channel and get refund |
|
|
95
|
+
| `drain_channel_status` | Check channel balance and expiry |
|
|
96
|
+
|
|
97
|
+
### Inference
|
|
98
|
+
|
|
99
|
+
| Tool | Description |
|
|
100
|
+
|------|-------------|
|
|
101
|
+
| `drain_chat` | Send chat completion request with automatic payment |
|
|
102
|
+
|
|
103
|
+
## Example Workflow
|
|
104
|
+
|
|
105
|
+
```
|
|
106
|
+
Agent: "I need to use GPT-4 for analysis"
|
|
107
|
+
|
|
108
|
+
1. Check providers:
|
|
109
|
+
→ drain_providers(model: "gpt-4o")
|
|
110
|
+
|
|
111
|
+
2. Check balance:
|
|
112
|
+
→ drain_balance()
|
|
113
|
+
|
|
114
|
+
3. Approve USDC (if needed):
|
|
115
|
+
→ drain_approve()
|
|
116
|
+
|
|
117
|
+
4. Open channel:
|
|
118
|
+
→ drain_open_channel(provider: "drain-official", amount: "5.00", duration: "24h")
|
|
119
|
+
|
|
120
|
+
5. Make requests:
|
|
121
|
+
→ drain_chat(channelId: "0x...", model: "gpt-4o", messages: [...])
|
|
122
|
+
|
|
123
|
+
6. When done (after expiry):
|
|
124
|
+
→ drain_close_channel(channelId: "0x...")
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## Resources
|
|
128
|
+
|
|
129
|
+
The server also exposes MCP resources:
|
|
130
|
+
|
|
131
|
+
| URI | Description |
|
|
132
|
+
|-----|-------------|
|
|
133
|
+
| `drain://wallet` | Current wallet status |
|
|
134
|
+
| `drain://providers` | List of available providers |
|
|
135
|
+
|
|
136
|
+
## Funding Your Agent
|
|
137
|
+
|
|
138
|
+
Before your agent can pay for services, it needs:
|
|
139
|
+
|
|
140
|
+
1. **USDC** - For paying AI providers
|
|
141
|
+
2. **POL** - For gas fees on Polygon
|
|
142
|
+
|
|
143
|
+
Send these tokens to your agent's wallet address (shown when the server starts).
|
|
144
|
+
|
|
145
|
+
### Getting USDC on Polygon
|
|
146
|
+
|
|
147
|
+
- Bridge from Ethereum: [Polygon Bridge](https://wallet.polygon.technology/bridge)
|
|
148
|
+
- Buy directly: Various exchanges support Polygon USDC
|
|
149
|
+
- Testnet: Use Amoy faucet for testing
|
|
150
|
+
|
|
151
|
+
## Security
|
|
152
|
+
|
|
153
|
+
- **Never share your private key**
|
|
154
|
+
- Use a dedicated wallet for your agent
|
|
155
|
+
- Consider using spending limits in production
|
|
156
|
+
- Monitor your agent's spending
|
|
157
|
+
|
|
158
|
+
## Development
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
# Clone the repo
|
|
162
|
+
git clone https://github.com/kimbo128/DRAIN.git
|
|
163
|
+
cd DRAIN/mcp
|
|
164
|
+
|
|
165
|
+
# Install dependencies
|
|
166
|
+
npm install
|
|
167
|
+
|
|
168
|
+
# Build
|
|
169
|
+
npm run build
|
|
170
|
+
|
|
171
|
+
# Run locally
|
|
172
|
+
DRAIN_PRIVATE_KEY="0x..." node dist/index.js
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
## License
|
|
176
|
+
|
|
177
|
+
MIT
|