agentwallet-mcp 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.
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * AgentWallet MCP Server
4
+ *
5
+ * Gives AI agents access to AgentWallet infrastructure:
6
+ * create wallets, check balances, sign transactions,
7
+ * broadcast on any EVM chain, and track usage.
8
+ *
9
+ * All operations go through the AgentWallet WordPress REST API.
10
+ * Requires authentication via WordPress application password.
11
+ */
12
+ export {};
package/build/index.js ADDED
@@ -0,0 +1,174 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * AgentWallet MCP Server
4
+ *
5
+ * Gives AI agents access to AgentWallet infrastructure:
6
+ * create wallets, check balances, sign transactions,
7
+ * broadcast on any EVM chain, and track usage.
8
+ *
9
+ * All operations go through the AgentWallet WordPress REST API.
10
+ * Requires authentication via WordPress application password.
11
+ */
12
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
13
+ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
14
+ import { z } from 'zod';
15
+ // ─── Configuration ──────────────────────────────────────────────
16
+ const API_BASE = process.env.AGENTWALLET_API_URL || 'https://hifriendbot.com/wp-json/agentwallet/v1';
17
+ const API_USER = process.env.AGENTWALLET_USER || '';
18
+ const API_PASS = process.env.AGENTWALLET_PASS || ''; // WordPress application password
19
+ // ─── API Helper ─────────────────────────────────────────────────
20
+ async function api(path, method = 'GET', body) {
21
+ const url = `${API_BASE}${path}`;
22
+ const headers = {
23
+ 'Content-Type': 'application/json',
24
+ };
25
+ // Add basic auth if credentials provided
26
+ if (API_USER && API_PASS) {
27
+ headers['Authorization'] = 'Basic ' + Buffer.from(`${API_USER}:${API_PASS}`).toString('base64');
28
+ }
29
+ const options = { method, headers };
30
+ if (body && method !== 'GET') {
31
+ options.body = JSON.stringify(body);
32
+ }
33
+ const res = await fetch(url, options);
34
+ const data = await res.json();
35
+ if (!res.ok) {
36
+ const error = data.error || `HTTP ${res.status}`;
37
+ throw new Error(error);
38
+ }
39
+ return data;
40
+ }
41
+ function jsonResponse(data) {
42
+ return { content: [{ type: 'text', text: JSON.stringify(data, null, 2) }] };
43
+ }
44
+ // ─── Server ──────────────────────────────────────────────────────
45
+ const server = new McpServer({
46
+ name: 'agentwallet',
47
+ version: '1.0.0',
48
+ });
49
+ // ─── Tool: create_wallet ─────────────────────────────────────────
50
+ server.tool('create_wallet', 'Create a new EVM wallet. Returns the wallet ID and address. ' +
51
+ 'Private key is encrypted server-side and never exposed.', {
52
+ label: z.string().default('').describe('Friendly name for the wallet'),
53
+ chain_id: z.number().int().default(1).describe('Default chain ID (1=Ethereum, 8453=Base, 137=Polygon, 56=BSC, 369=PulseChain)'),
54
+ }, async ({ label, chain_id }) => {
55
+ const data = await api('/wallets', 'POST', { label, chain_id });
56
+ return jsonResponse(data);
57
+ });
58
+ // ─── Tool: list_wallets ──────────────────────────────────────────
59
+ server.tool('list_wallets', 'List all wallets owned by the authenticated user. ' +
60
+ 'Returns wallet IDs, addresses, labels, chain IDs, and status.', {}, async () => {
61
+ const data = await api('/wallets');
62
+ return jsonResponse(data);
63
+ });
64
+ // ─── Tool: get_wallet ────────────────────────────────────────────
65
+ server.tool('get_wallet', 'Get details for a specific wallet by ID. ' +
66
+ 'Returns address, label, chain, spending limits, and pause status.', {
67
+ wallet_id: z.number().int().describe('Wallet ID'),
68
+ }, async ({ wallet_id }) => {
69
+ const data = await api(`/wallets/${wallet_id}`);
70
+ return jsonResponse(data);
71
+ });
72
+ // ─── Tool: get_balance ───────────────────────────────────────────
73
+ server.tool('get_balance', 'Get the native token balance for a wallet on a specific chain. ' +
74
+ 'Returns balance in both wei and human-readable format.', {
75
+ wallet_id: z.number().int().describe('Wallet ID'),
76
+ chain_id: z.number().int().optional().describe('Chain ID to check (defaults to wallet\'s default chain)'),
77
+ }, async ({ wallet_id, chain_id }) => {
78
+ const params = chain_id ? `?chain_id=${chain_id}` : '';
79
+ const data = await api(`/wallets/${wallet_id}/balance${params}`);
80
+ return jsonResponse(data);
81
+ });
82
+ // ─── Tool: sign_transaction ──────────────────────────────────────
83
+ server.tool('sign_transaction', 'Sign an EVM transaction with a wallet\'s private key. ' +
84
+ 'Returns the signed raw transaction hex (ready for manual broadcast). ' +
85
+ 'Does NOT broadcast — use send_transaction for sign + broadcast.', {
86
+ wallet_id: z.number().int().describe('Wallet ID'),
87
+ to: z.string().regex(/^0x[a-fA-F0-9]{40}$/).describe('Destination address'),
88
+ chain_id: z.number().int().optional().describe('Chain ID (defaults to wallet\'s default)'),
89
+ value: z.string().default('0').describe('Value in wei (decimal string)'),
90
+ data: z.string().default('').describe('Hex-encoded calldata (0x-prefixed) for contract calls'),
91
+ gas_limit: z.string().optional().describe('Gas limit (auto-estimated if omitted)'),
92
+ max_fee: z.string().optional().describe('Max fee per gas in wei (auto if omitted)'),
93
+ priority_fee: z.string().optional().describe('Max priority fee per gas in wei (auto if omitted)'),
94
+ }, async ({ wallet_id, to, chain_id, value, data, gas_limit, max_fee, priority_fee }) => {
95
+ const body = { to, value, data };
96
+ if (chain_id)
97
+ body.chain_id = chain_id;
98
+ if (gas_limit)
99
+ body.gas_limit = gas_limit;
100
+ if (max_fee)
101
+ body.max_fee = max_fee;
102
+ if (priority_fee)
103
+ body.priority_fee = priority_fee;
104
+ const result = await api(`/wallets/${wallet_id}/sign`, 'POST', body);
105
+ return jsonResponse(result);
106
+ });
107
+ // ─── Tool: send_transaction ──────────────────────────────────────
108
+ server.tool('send_transaction', 'Sign and broadcast an EVM transaction. ' +
109
+ 'Returns the transaction hash on success. ' +
110
+ 'The transaction is signed server-side and broadcast via RPC.', {
111
+ wallet_id: z.number().int().describe('Wallet ID'),
112
+ to: z.string().regex(/^0x[a-fA-F0-9]{40}$/).describe('Destination address'),
113
+ chain_id: z.number().int().optional().describe('Chain ID (defaults to wallet\'s default)'),
114
+ value: z.string().default('0').describe('Value in wei (decimal string)'),
115
+ data: z.string().default('').describe('Hex-encoded calldata (0x-prefixed) for contract calls'),
116
+ gas_limit: z.string().optional().describe('Gas limit (auto-estimated if omitted)'),
117
+ max_fee: z.string().optional().describe('Max fee per gas in wei (auto if omitted)'),
118
+ priority_fee: z.string().optional().describe('Max priority fee per gas in wei (auto if omitted)'),
119
+ }, async ({ wallet_id, to, chain_id, value, data, gas_limit, max_fee, priority_fee }) => {
120
+ const body = { to, value, data };
121
+ if (chain_id)
122
+ body.chain_id = chain_id;
123
+ if (gas_limit)
124
+ body.gas_limit = gas_limit;
125
+ if (max_fee)
126
+ body.max_fee = max_fee;
127
+ if (priority_fee)
128
+ body.priority_fee = priority_fee;
129
+ const result = await api(`/wallets/${wallet_id}/send`, 'POST', body);
130
+ return jsonResponse(result);
131
+ });
132
+ // ─── Tool: get_usage ─────────────────────────────────────────────
133
+ server.tool('get_usage', 'Get the current month\'s usage statistics. ' +
134
+ 'Returns operations count, tier info, remaining quota, and fees.', {}, async () => {
135
+ const data = await api('/usage');
136
+ return jsonResponse(data);
137
+ });
138
+ // ─── Tool: pause_wallet ──────────────────────────────────────────
139
+ server.tool('pause_wallet', 'Emergency pause a wallet. No transactions can be signed while paused.', {
140
+ wallet_id: z.number().int().describe('Wallet ID to pause'),
141
+ }, async ({ wallet_id }) => {
142
+ const data = await api(`/wallets/${wallet_id}/pause`, 'POST');
143
+ return jsonResponse(data);
144
+ });
145
+ // ─── Tool: unpause_wallet ────────────────────────────────────────
146
+ server.tool('unpause_wallet', 'Resume a paused wallet so transactions can be signed again.', {
147
+ wallet_id: z.number().int().describe('Wallet ID to unpause'),
148
+ }, async ({ wallet_id }) => {
149
+ const data = await api(`/wallets/${wallet_id}/unpause`, 'POST');
150
+ return jsonResponse(data);
151
+ });
152
+ // ─── Tool: get_chains ────────────────────────────────────────────
153
+ server.tool('get_chains', 'List all supported EVM chains with their chain IDs, native tokens, ' +
154
+ 'stablecoins, and RPC configuration status.', {}, async () => {
155
+ const data = await api('/chains');
156
+ return jsonResponse(data);
157
+ });
158
+ // ─── Tool: delete_wallet ─────────────────────────────────────────
159
+ server.tool('delete_wallet', 'Delete (soft-delete) a wallet. The wallet will no longer appear in listings ' +
160
+ 'and cannot be used for transactions.', {
161
+ wallet_id: z.number().int().describe('Wallet ID to delete'),
162
+ }, async ({ wallet_id }) => {
163
+ const data = await api(`/wallets/${wallet_id}`, 'DELETE');
164
+ return jsonResponse(data);
165
+ });
166
+ // ─── Start ──────────────────────────────────────────────────────
167
+ async function main() {
168
+ const transport = new StdioServerTransport();
169
+ await server.connect(transport);
170
+ }
171
+ main().catch((error) => {
172
+ console.error('AgentWallet MCP server failed to start:', error);
173
+ process.exit(1);
174
+ });
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "agentwallet-mcp",
3
+ "version": "1.0.0",
4
+ "description": "MCP server for AgentWallet — lets AI agents create wallets, sign transactions, and broadcast on any EVM chain",
5
+ "type": "module",
6
+ "main": "build/index.js",
7
+ "bin": {
8
+ "agentwallet-mcp": "build/index.js"
9
+ },
10
+ "files": [
11
+ "build",
12
+ "README.md",
13
+ "LICENSE"
14
+ ],
15
+ "scripts": {
16
+ "build": "tsc",
17
+ "start": "node build/index.js",
18
+ "prepublishOnly": "npm run build"
19
+ },
20
+ "keywords": [
21
+ "mcp",
22
+ "model-context-protocol",
23
+ "wallet",
24
+ "ai-agent",
25
+ "blockchain",
26
+ "evm",
27
+ "ethereum",
28
+ "base",
29
+ "polygon",
30
+ "bsc",
31
+ "pulsechain",
32
+ "transaction-signing",
33
+ "agentwallet"
34
+ ],
35
+ "author": "HiFriendbot (https://hifriendbot.com)",
36
+ "license": "MIT",
37
+ "homepage": "https://hifriendbot.com/agentwallet",
38
+ "engines": {
39
+ "node": ">=18.0.0"
40
+ },
41
+ "dependencies": {
42
+ "@modelcontextprotocol/sdk": "^1.11.4",
43
+ "zod": "^3.24.0"
44
+ },
45
+ "devDependencies": {
46
+ "@types/node": "^20.0.0",
47
+ "typescript": "^5.3.0"
48
+ }
49
+ }