@newblock/iautopay-mcp 0.0.1 → 0.0.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.
@@ -0,0 +1,138 @@
1
+ # Claude CLI MCP Configuration
2
+
3
+ This project supports both OpenCode and Claude CLI MCP servers.
4
+
5
+ ## OpenCode
6
+
7
+ Configuration is automatically generated at installation via `opencode.json`.
8
+
9
+ Available commands:
10
+ - `/autopay_toA` - Quick payment of 0.01 USDC
11
+ - `/autopay_toB` - Quick payment of 0.05 USDC (with confirmation)
12
+ - `/autopay_buy_glm_nvidia_apikey` - Purchase GLM NVIDIA API Key
13
+ - `/autopay_custom` - Custom payment
14
+ - `/autopay_getInfo` - Get service information
15
+
16
+ ## Claude CLI
17
+
18
+ ### Option 1: Use Pre-generated Config File (Recommended)
19
+
20
+ ```bash
21
+ # Use the auto-generated mcp-config.json
22
+ claude --mcp-config mcp-config.json
23
+ ```
24
+
25
+ This method uses the configuration file generated at `mcp-config.json` during installation.
26
+
27
+ ### Option 2: Add to Local Config
28
+
29
+ ```bash
30
+ # Add MCP server to Claude CLI
31
+ BUYER_PRIVATE_KEY="your_private_key" claude mcp add iauto-pay \
32
+ -e BUYER_PRIVATE_KEY="your_private_key" \
33
+ -- npx -y @newblock/iautopay-mcp
34
+
35
+ # Verify connection:
36
+ claude mcp list
37
+
38
+ # Should show:
39
+ # iauto-pay: npx -y @newblock/iautopay-mcp - ✓ Connected
40
+ ```
41
+
42
+ After adding, you can simply run `claude` without any additional flags.
43
+
44
+ ### Option 3: Manual Setup
45
+
46
+ ```bash
47
+ # Create mcp-config.json manually:
48
+ {
49
+ "mcpServers": {
50
+ "iauto-pay": {
51
+ "command": "npx",
52
+ "args": ["-y", "@newblock/iautopay-mcp"],
53
+ "env": {
54
+ "BUYER_PRIVATE_KEY": "your_private_key_here"
55
+ }
56
+ }
57
+ }
58
+ }
59
+
60
+ # Then use it:
61
+ claude --mcp-config mcp-config.json
62
+ ```
63
+
64
+ ## Available Tools
65
+
66
+ When using Claude CLI with MCP enabled, the following tools are available:
67
+
68
+ - `pay_stablecoin` - Pay USDC to any address (auto-detects mainnet/testnet based on CUR_ENV)
69
+ - `buy_glm_nvidia_apikey` - Purchase GLM NVIDIA API Key
70
+ - `get_info` - Get server information (stock, price, network config)
71
+ - `pay_preset` - Quick preset payments (toA: 0.01 USDC, toB: 0.05 USDC)
72
+
73
+ ## Usage Examples
74
+
75
+ ### Using Config File
76
+ ```bash
77
+ # Start Claude CLI with MCP support
78
+ claude --mcp-config mcp-config.json
79
+ ```
80
+
81
+ ### Using Local Config
82
+ ```bash
83
+ # Start Claude CLI (MCP servers from local config are auto-loaded)
84
+ claude
85
+ ```
86
+
87
+ ## Verification
88
+
89
+ ```bash
90
+ # List configured MCP servers
91
+ claude mcp list
92
+
93
+ # Get details of specific server
94
+ claude mcp get iauto-pay
95
+ ```
96
+
97
+ ## Removing MCP Server
98
+
99
+ If you added to local config:
100
+ ```bash
101
+ claude mcp remove iauto-pay -s local
102
+ ```
103
+
104
+ If using config file, simply remove the `--mcp-config mcp-config.json` flag when running `claude`.
105
+
106
+ ## Troubleshooting
107
+
108
+ **MCP server not connecting:**
109
+ 1. Ensure dependencies are installed: `npm install -g @newblock/iautopay-mcp`
110
+ 2. Verify npx can run the package: `npx @newblock/iautopay-mcp`
111
+ 3. Check environment variable is set correctly in `mcp-config.json` or local config
112
+
113
+ **Tools not showing up:**
114
+ 1. Verify MCP connection: `claude mcp list`
115
+ 2. Check server health: `claude mcp get iauto-pay`
116
+ 3. Restart Claude CLI
117
+
118
+ **Wrong environment (dev vs prod):**
119
+ - The published npm package uses dev environment by default
120
+ - For production environment, you may need to build from source or request a prod release
121
+
122
+ ## Configuration Files
123
+
124
+ - `opencode.json` - OpenCode configuration (auto-generated)
125
+ - `mcp-config.json` - Claude CLI MCP configuration (auto-generated)
126
+ - `mcp-config.json.example` - Example MCP config template
127
+ - `scripts/generate-opencode-config.js` - Configuration generation script
128
+ - `~/.claude.json` (project-scoped) or `~/.claude/mcp.json` (global) - Claude CLI local config
129
+
130
+ ## Environment Variables
131
+
132
+ Set `BUYER_PRIVATE_KEY` when running the configuration script:
133
+
134
+ ```bash
135
+ BUYER_PRIVATE_KEY="your_private_key" npm run install:opencode-config
136
+ ```
137
+
138
+ This ensures both OpenCode and Claude CLI configurations have the correct key.
package/LICENSE CHANGED
@@ -1,21 +1,19 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 NewBlock
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ Creative Commons Attribution-NonCommercial 4.0 International License (CC BY-NC 4.0)
2
+
3
+ Copyright (c) 2026 Michael
4
+
5
+ You are free to:
6
+
7
+ Share copy and redistribute the material in any medium or format
8
+ Adapt remix, transform, and build upon the material
9
+
10
+ Under the following terms:
11
+
12
+ Attribution You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
13
+
14
+ NonCommercial — You may not use the material for commercial purposes.
15
+
16
+ No additional restrictions You may not apply legal terms or technological measures that legally restrict others from doing anything the license permits.
17
+
18
+ To view a copy of this license, visit:
19
+ https://creativecommons.org/licenses/by-nc/4.0/
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
- # iautopay-mcp
1
+ # iAutoPay MCP Service
2
2
 
3
- iAutoPay is an MCP service that enables AI agents to automatically pay for purchases. It currently runs on the Base chain (operated by Coinbase) and supports USDC payments. It can be used by intelligent agents to automatically purchase paid AI-related services and data.
3
+ An MCP (Model Context Protocol) service that enables AI agents to automatically pay for purchases. It currently runs on Base chain (operated by Coinbase) and supports USDC payments. It can be used by intelligent agents to automatically purchase paid AI-related services and data.
4
4
 
5
5
  ## Features
6
6
 
@@ -9,26 +9,27 @@ iAutoPay is an MCP service that enables AI agents to automatically pay for purch
9
9
  - 🔐 **Secure**: Environment variable based configuration for private keys
10
10
  - 🤖 **AI-Native**: Full MCP integration designed for AI agents
11
11
  - 💸 **Fixed Transfer**: Preset fixed transfer account command, direct transfer by command
12
- - 🔑 **API Key Purchase**: Support GLM4.7 LLM APIKEY purchase service
12
+ - 🔑 **API Key Purchase**: Support GLM4.7 LLM API Key purchase service with dynamic pricing
13
13
 
14
- ## Quick Start with npx (Recommended)
14
+ ## Supported Models
15
15
 
16
- No installation required! Just run:
17
-
18
- ```bash
19
- npx @newblock/iautopay-mcp
20
- ```
21
-
22
- This will automatically download and cache the package.
16
+ API keys purchased through this service provide access to:
17
+ - `z-ai/glm4.7` (GLM4.7 with thinking chain support)
18
+ - `minimaxai/minimax-m2.1` (MiniMax general LLM)
19
+ - `deepseek-ai/deepseek-v3.2` (DeepSeek with thinking chain)
23
20
 
24
21
  ## Installation
25
22
 
26
23
  ### Option 1: npx (Recommended)
27
24
 
25
+ No installation required! Just run:
26
+
28
27
  ```bash
29
28
  npx @newblock/iautopay-mcp
30
29
  ```
31
30
 
31
+ This will automatically download and cache the package.
32
+
32
33
  ### Option 2: Global Install
33
34
 
34
35
  ```bash
@@ -74,6 +75,22 @@ Add to your `opencode.json`:
74
75
  }
75
76
  ```
76
77
 
78
+ ### Claude CLI Configuration
79
+
80
+ For detailed instructions on using Claude CLI with MCP, see [CLAUDE_CLI_MCP_SETUP.md](CLAUDE_CLI_MCP_SETUP.md).
81
+
82
+ #### Quick Setup
83
+
84
+ ```bash
85
+ # Install and add to Claude CLI
86
+ BUYER_PRIVATE_KEY="your_private_key" claude mcp add iauto-pay \
87
+ -e BUYER_PRIVATE_KEY="your_private_key" \
88
+ -- npx -y @newblock/iautopay-mcp
89
+
90
+ # Use with MCP config
91
+ claude --mcp-config mcp-config.json
92
+ ```
93
+
77
94
  ### Claude Code Configuration
78
95
 
79
96
  Add to your `~/.claude/claude_desktop_config.json`:
@@ -94,32 +111,102 @@ Add to your `~/.claude/claude_desktop_config.json`:
94
111
 
95
112
  ## MCP Tools
96
113
 
97
- ### pay_stablecoin
114
+ ### guide
115
+
116
+ ⭐ **FIRST TIME?** Run this guide to learn how to use iAutoPay tools and commands.
117
+
118
+ **Parameters:**
119
+ ```json
120
+ {}
121
+ ```
122
+
123
+ **Returns:**
124
+ - Complete guide with all tools and commands
125
+ - Pricing information
126
+ - Network configuration
98
127
 
99
- Direct stablecoin payment using EIP-3009 transferWithAuthorization.
128
+ ### info
129
+
130
+ Get iAutoPay server information (API key stock, price, network config).
100
131
 
101
132
  **Parameters:**
102
133
  ```json
134
+ {}
135
+ ```
136
+
137
+ **Returns:**
138
+ ```json
103
139
  {
104
- "to": "0x1234567890123456789012345678901234567890",
105
- "amount": "1000000"
140
+ "stock": 100,
141
+ "prices": {
142
+ "1day": "0.09 USDC",
143
+ "7days": "0.49 USDC",
144
+ "30days": "0.99 USDC"
145
+ },
146
+ "network": {
147
+ "chainId": 84532,
148
+ "rpcUrl": "https://sepolia.base.org"
149
+ }
106
150
  }
107
151
  ```
108
152
 
109
- **Usage example:**
153
+ ### buy_apikey
154
+
155
+ Purchase an API key with optional duration (1/7/30 days).
156
+
157
+ **Parameters:**
158
+ ```json
159
+ {
160
+ "duration": 1
161
+ }
110
162
  ```
111
- Use iauto-pay_pay_stablecoin tool to send 1 USDC to 0x123...
163
+
164
+ **Duration Options:**
165
+ - `1`: 1 day validity
166
+ - `7`: 7 days validity
167
+ - `30`: 30 days validity
168
+
169
+ **Returns:**
170
+ ```json
171
+ {
172
+ "apiKey": "sk-ABCD12345678901234567890",
173
+ "txHash": "0x4d757c7e121ad31607ee1e9c5af65bfe13b82c112fcf077638814c031ecc3a6b",
174
+ "payState": "paid",
175
+ "price": "0.09 USDC",
176
+ "deductedAmount": "0.09 USDC",
177
+ "currentBalance": "9.91 USDC"
178
+ }
112
179
  ```
113
180
 
114
- **Tip**: You can preset frequently used transfer addresses and amounts to avoid manual input each time, improving convenience.
181
+ ### pay_stablecoin
182
+
183
+ Pay stablecoin to any address using EIP-3009.
184
+
185
+ **Parameters:**
186
+ ```json
187
+ {
188
+ "to": "0x1234567890123456789012345678901234567890",
189
+ "amount": "100000"
190
+ }
191
+ ```
115
192
 
116
- ### buy_glm_apikey
193
+ **Amount is in smallest units** (e.g., 100000 = 0.1 USDC, 1000000 = 1 USDC)
117
194
 
118
- **Tip**: You can preset frequently used transfer addresses and amounts to avoid manual input each time, improving convenience.
195
+ **Returns:**
196
+ ```json
197
+ {
198
+ "from": "0x...",
199
+ "to": "0x...",
200
+ "amount": "0.1 USDC",
201
+ "txHash": "0x...",
202
+ "deductedAmount": "0.1 USDC",
203
+ "currentBalance": "9.9 USDC"
204
+ }
205
+ ```
119
206
 
120
- ### buy_glm_apikey
207
+ ### sync_opencode_config
121
208
 
122
- Purchase GLM4.7 LLM APIKEY.
209
+ Auto-configure opencode.json with quick commands (autopay_toA, autopay_toB, etc.).
123
210
 
124
211
  **Parameters:**
125
212
  ```json
@@ -129,10 +216,14 @@ Purchase GLM4.7 LLM APIKEY.
129
216
  **Returns:**
130
217
  ```json
131
218
  {
132
- "apiKey": "sk-ABCD12345678901234567890",
133
- "txHash": "0x4d757c7e121ad31607ee1e9c5af65bfe13b82c112fcf077638814c031ecc3a6b",
134
- "payState": "paid"
219
+ "message": "✅ 已添加 7 个命令到 opencode.json"
135
220
  }
221
+ ```
222
+
223
+ ### refresh_pricing
224
+
225
+ Refresh pricing from API. Use this if prices are changed on the server.
226
+
136
227
  **Parameters:**
137
228
  ```json
138
229
  {}
@@ -141,9 +232,9 @@ Purchase GLM4.7 LLM APIKEY.
141
232
  **Returns:**
142
233
  ```json
143
234
  {
144
- "apiKey": "sk-RxmFQ2cLfBaefDFfkYlEGY51E74pl5h06bAHbF41vyCCCC",
145
- "txHash": "0x4d757c7e121ad31607ee1e9c5af65bfe13b82c112fcf077638814c031ecc3a6b",
146
- "payState": "paid"
235
+ "1day": "0.09 USDC",
236
+ "7days": "0.49 USDC",
237
+ "30days": "0.99 USDC"
147
238
  }
148
239
  ```
149
240
 
@@ -151,65 +242,39 @@ Purchase GLM4.7 LLM APIKEY.
151
242
 
152
243
  The MCP server supports two environments configured in `src/server.ts`:
153
244
 
154
- ### Production (Base Mainnet)
155
- - Chain ID: 8453
156
- - RPC URL: https://mainnet.base.org
157
- - USDC Address: 0x833589fcd6edb6e08f4c7c32d4f71b54bda02913
158
- - Token Name: "USD Coin"
159
-
160
245
  ### Development (Base Sepolia)
161
246
  - Chain ID: 84532
162
247
  - RPC URL: https://sepolia.base.org
163
248
  - USDC Address: 0x036CbD53842c5426634e7929541eC2318f3dCF7e
164
249
  - Token Name: "USDC"
165
250
 
166
- To switch environments, modify `CUR_ENV` in `src/server.ts` and rebuild:
167
-
168
- ```bash
169
- # Edit src/server.ts: const CUR_ENV: 'dev' | 'prod' = 'prod';
170
- npm run build
171
- npm publish
172
- ```
251
+ ### Production (Base Mainnet)
252
+ - Chain ID: 8453
253
+ - RPC URL: https://mainnet.base.org
254
+ - USDC Address: 0x833589fcd6edb6e08f4c7c32d4f71b54bda02913
255
+ - Token Name: "USD Coin"
173
256
 
174
257
  ## Example Workflows
175
258
 
176
259
  ### Example 1: Purchase GLM4.7 API Key
177
260
 
178
261
  ```
179
- Use iauto-pay_buy_glm_apikey tool to purchase GLM4.7 LLM API Key
262
+ Use info tool to check stock and pricing
263
+ Use buy_apikey tool with duration: 1
264
+ Receive API key in response
180
265
  ```
181
266
 
182
267
  ### Example 2: Direct USDC Payment
183
268
 
184
269
  ```
185
- Use iauto-pay_pay_stablecoin tool to send 0.01 USDC to 0x1a85156c2943b63febeee7883bd84a7d1cf0da0c
270
+ Use pay_stablecoin tool with to: "0x1a85156c2943b63febeee7883bd84a7d1cf0da0c" and amount: "10000"
271
+ Transaction executes automatically
272
+ Receive transaction hash
186
273
  ```
187
- Use the iauto-pay_buy_apikey tool to purchase an API key
188
- ```
189
-
190
- ### Example 2: Send Payment
191
-
192
- ```
193
- Use the iauto-pay_pay_stablecoin tool to send 0.01 USDC to 0x1a85156c2943b63febeee7883bd84a7d1cf0da0c
194
- ```
195
-
196
- ## Requirements
197
-
198
- - Node.js >= 18.0.0
199
- - npm >= 9.0.0
200
-
201
- ## Dependencies
202
-
203
- - @modelcontextprotocol/sdk ^1.0.0
204
- - @x402/core ^2.3.0
205
- - @x402/evm ^2.3.0
206
- - viem ^2.21.35
207
- - zod ^3.24.1
208
- - zod-to-json-schema ^3.24.1
209
274
 
210
275
  ## License
211
276
 
212
- MIT License - see [LICENSE](LICENSE) file for details.
277
+ Creative Commons Attribution-NonCommercial 4.0 International License (CC BY-NC 4.0) - see [LICENSE](LICENSE) file for details.
213
278
 
214
279
  ## Repository
215
280
 
@@ -218,3 +283,8 @@ MIT License - see [LICENSE](LICENSE) file for details.
218
283
  ## Support
219
284
 
220
285
  For issues and questions, please use the [GitHub Issues](https://github.com/newblock/iautopay/issues).
286
+
287
+ ## Documentation
288
+
289
+ - [CLAUDE_CLI_MCP_SETUP.md](CLAUDE_CLI_MCP_SETUP.md) - Claude CLI integration guide
290
+ - [mcp-config.json.example](mcp-config.json.example) - MCP configuration template
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env node
2
+
3
+ import('../dist/iautopay-mcp.js').catch((err) => {
4
+ console.error('Failed to load iautopay-mcp:', err);
5
+ process.exit(1);
6
+ });
@@ -0,0 +1,114 @@
1
+ import { createPublicClient, http, formatUnits } from "viem";
2
+ import { privateKeyToAccount } from "viem/accounts";
3
+ import { baseSepolia, base } from "viem/chains";
4
+ // Hardcoded configuration
5
+ const CUR_ENV = 'prod';
6
+ const BUYER_PRIVATE_KEY = process.env.BUYER_PRIVATE_KEY;
7
+ if (!BUYER_PRIVATE_KEY) {
8
+ console.error("Please provide BUYER_PRIVATE_KEY env var via opencode.json");
9
+ process.exit(1);
10
+ }
11
+ const account = privateKeyToAccount(BUYER_PRIVATE_KEY);
12
+ console.log("付款地址 (Address):", account.address);
13
+ const chain = CUR_ENV === 'dev' ? baseSepolia : base;
14
+ const client = createPublicClient({
15
+ chain,
16
+ transport: http(),
17
+ });
18
+ console.log(`当前环境: ${CUR_ENV.toUpperCase()}`);
19
+ console.log(`区块链: ${chain.name} (chain ID: ${chain.id})`);
20
+ console.log("----------------------------------------");
21
+ // USDC addresses
22
+ const USDC_ADDRESSES = {
23
+ sepolia: {
24
+ official: "0x4200000000000000000000000000000000000006",
25
+ custom: "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
26
+ },
27
+ mainnet: {
28
+ official: "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
29
+ }
30
+ };
31
+ const currentUSDC = CUR_ENV === 'dev' ? USDC_ADDRESSES.sepolia : USDC_ADDRESSES.mainnet;
32
+ const usdcAbi = [
33
+ {
34
+ name: "balanceOf",
35
+ type: "function",
36
+ stateMutability: "view",
37
+ inputs: [{ name: "account", type: "address" }],
38
+ outputs: [{ name: "", type: "uint256" }],
39
+ },
40
+ {
41
+ name: "decimals",
42
+ type: "function",
43
+ stateMutability: "view",
44
+ inputs: [],
45
+ outputs: [{ name: "", type: "uint8" }],
46
+ },
47
+ {
48
+ name: "name",
49
+ type: "function",
50
+ stateMutability: "view",
51
+ inputs: [],
52
+ outputs: [{ name: "", type: "string" }],
53
+ },
54
+ {
55
+ name: "version",
56
+ type: "function",
57
+ stateMutability: "view",
58
+ inputs: [],
59
+ outputs: [{ name: "", type: "string" }],
60
+ }
61
+ ];
62
+ async function checkToken(address, label) {
63
+ try {
64
+ const decimals = await client.readContract({
65
+ address: address,
66
+ abi: usdcAbi,
67
+ functionName: "decimals",
68
+ });
69
+ const balance = await client.readContract({
70
+ address: address,
71
+ abi: usdcAbi,
72
+ functionName: "balanceOf",
73
+ args: [account.address],
74
+ });
75
+ let tokenName = "Unknown";
76
+ try {
77
+ tokenName = await client.readContract({
78
+ address: address,
79
+ abi: usdcAbi,
80
+ functionName: "name",
81
+ });
82
+ }
83
+ catch { }
84
+ let tokenVersion = "Unknown";
85
+ try {
86
+ tokenVersion = await client.readContract({
87
+ address: address,
88
+ abi: usdcAbi,
89
+ functionName: "version",
90
+ });
91
+ }
92
+ catch { }
93
+ console.log(`[${label}] ${tokenName} (v${tokenVersion}) - ${address}`);
94
+ console.log(` 余额: ${formatUnits(balance, decimals)}`);
95
+ console.log(` 原始: ${balance.toString()}`);
96
+ }
97
+ catch (e) {
98
+ console.error(`[${label}] 查询失败:`, e?.message || e);
99
+ }
100
+ }
101
+ async function main() {
102
+ const ethBalance = await client.getBalance({ address: account.address });
103
+ console.log("付款地址:", account.address);
104
+ console.log("ETH 余额:", formatUnits(ethBalance, 18), "ETH");
105
+ console.log("----------------------------------------");
106
+ if ('official' in currentUSDC) {
107
+ await checkToken(currentUSDC.official, "Official USDC");
108
+ console.log("----------------------------------------");
109
+ }
110
+ if ('custom' in currentUSDC) {
111
+ await checkToken(currentUSDC.custom, "Custom USDC");
112
+ }
113
+ }
114
+ main();