@pipeworx/mcp-mempool-space 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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Pipeworx
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.
package/README.md ADDED
@@ -0,0 +1,65 @@
1
+ # mcp-mempool-space
2
+
3
+ mempool.space MCP — Bitcoin block explorer + mempool/fee stats
4
+
5
+ Part of [Pipeworx](https://pipeworx.io) — an MCP gateway connecting AI agents to 250+ live data sources.
6
+
7
+ ## Tools
8
+
9
+ | Tool | Description |
10
+ |------|-------------|
11
+ | `recommended_fees` | Current sat/vB fee recommendations. |
12
+ | `mempool_stats` | Current mempool size + tx count + total fees. |
13
+ | `block_height` | Current chain tip block height. |
14
+ | `get_block` | Block detail by hash or height. |
15
+ | `get_transaction` | Transaction detail. |
16
+ | `get_tx_status` | Confirmation state. |
17
+ | `get_address` | Address summary (UTXO + tx counts). |
18
+ | `get_address_transactions` | Recent transactions for an address (~25 per call). |
19
+ | `hashrate` | Network hashrate + difficulty history. |
20
+ | `mining_pools` | Block share by mining pool. |
21
+
22
+ ## Quick Start
23
+
24
+ Add to your MCP client (Claude Desktop, Cursor, Windsurf, etc.):
25
+
26
+ ```json
27
+ {
28
+ "mcpServers": {
29
+ "mempool-space": {
30
+ "url": "https://gateway.pipeworx.io/mempool-space/mcp"
31
+ }
32
+ }
33
+ }
34
+ ```
35
+
36
+ Or connect to the full Pipeworx gateway for access to all 250+ data sources:
37
+
38
+ ```json
39
+ {
40
+ "mcpServers": {
41
+ "pipeworx": {
42
+ "url": "https://gateway.pipeworx.io/mcp"
43
+ }
44
+ }
45
+ }
46
+ ```
47
+
48
+ ## Using with ask_pipeworx
49
+
50
+ Instead of calling tools directly, you can ask questions in plain English:
51
+
52
+ ```
53
+ ask_pipeworx({ question: "your question about Mempool Space data" })
54
+ ```
55
+
56
+ The gateway picks the right tool and fills the arguments automatically.
57
+
58
+ ## More
59
+
60
+ - [All tools and guides](https://github.com/pipeworx-io/examples)
61
+ - [pipeworx.io](https://pipeworx.io)
62
+
63
+ ## License
64
+
65
+ MIT
package/package.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "@pipeworx/mcp-mempool-space",
3
+ "version": "0.1.0",
4
+ "description": "mempool.space MCP — Bitcoin block explorer + mempool/fee stats",
5
+ "type": "module",
6
+ "main": "src/index.ts",
7
+ "types": "src/index.ts",
8
+ "keywords": ["mcp", "mcp-server", "model-context-protocol", "pipeworx", "mempool-space"],
9
+ "license": "MIT",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "https://github.com/pipeworx-io/mcp-mempool-space"
13
+ },
14
+ "scripts": {
15
+ "typecheck": "tsc --noEmit"
16
+ },
17
+ "devDependencies": {
18
+ "typescript": "^5.7.0"
19
+ }
20
+ }
package/server.json ADDED
@@ -0,0 +1,18 @@
1
+ {
2
+ "$schema": "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json",
3
+ "name": "io.github.pipeworx-io/mempool-space",
4
+ "title": "Mempool Space",
5
+ "description": "mempool.space MCP — Bitcoin block explorer + mempool/fee stats",
6
+ "version": "0.1.0",
7
+ "websiteUrl": "https://pipeworx.io/packs/mempool-space",
8
+ "repository": {
9
+ "url": "https://github.com/pipeworx-io/mcp-mempool-space",
10
+ "source": "github"
11
+ },
12
+ "remotes": [
13
+ {
14
+ "type": "streamable-http",
15
+ "url": "https://gateway.pipeworx.io/mempool-space/mcp"
16
+ }
17
+ ]
18
+ }
package/src/index.ts ADDED
@@ -0,0 +1,206 @@
1
+ interface McpToolDefinition {
2
+ name: string;
3
+ description: string;
4
+ inputSchema: {
5
+ type: 'object';
6
+ properties: Record<string, unknown>;
7
+ required?: string[];
8
+ };
9
+ }
10
+
11
+ interface McpToolExport {
12
+ tools: McpToolDefinition[];
13
+ callTool: (name: string, args: Record<string, unknown>) => Promise<unknown>;
14
+ meter?: { credits: number };
15
+ cost?: Record<string, unknown>;
16
+ provider?: string;
17
+ }
18
+
19
+ /**
20
+ * mempool.space MCP — Bitcoin block explorer + mempool/fee stats
21
+ *
22
+ * Auth: none.
23
+ * Docs: https://mempool.space/docs/api/rest
24
+ */
25
+
26
+
27
+ const NETWORKS: Record<string, string> = {
28
+ mainnet: 'https://mempool.space/api',
29
+ testnet: 'https://mempool.space/testnet/api',
30
+ signet: 'https://mempool.space/signet/api',
31
+ liquid: 'https://liquid.network/api',
32
+ };
33
+
34
+ function networkBase(args: Record<string, unknown>): string {
35
+ const net = ((args.network as string | undefined) ?? 'mainnet').toLowerCase();
36
+ const base = NETWORKS[net];
37
+ if (!base) throw new Error(`Unsupported network "${net}". Supported: ${Object.keys(NETWORKS).join(', ')}.`);
38
+ return base;
39
+ }
40
+
41
+ const tools: McpToolExport['tools'] = [
42
+ {
43
+ name: 'recommended_fees',
44
+ description: 'Current sat/vB fee recommendations.',
45
+ inputSchema: { type: 'object', properties: { network: { type: 'string' } } },
46
+ },
47
+ {
48
+ name: 'mempool_stats',
49
+ description: 'Current mempool size + tx count + total fees.',
50
+ inputSchema: { type: 'object', properties: { network: { type: 'string' } } },
51
+ },
52
+ {
53
+ name: 'block_height',
54
+ description: 'Current chain tip block height.',
55
+ inputSchema: { type: 'object', properties: { network: { type: 'string' } } },
56
+ },
57
+ {
58
+ name: 'get_block',
59
+ description: 'Block detail by hash or height.',
60
+ inputSchema: {
61
+ type: 'object',
62
+ properties: {
63
+ hash_or_height: { type: 'string', description: 'Block hash or numeric height' },
64
+ network: { type: 'string' },
65
+ },
66
+ required: ['hash_or_height'],
67
+ },
68
+ },
69
+ {
70
+ name: 'get_transaction',
71
+ description: 'Transaction detail.',
72
+ inputSchema: {
73
+ type: 'object',
74
+ properties: { txid: { type: 'string' }, network: { type: 'string' } },
75
+ required: ['txid'],
76
+ },
77
+ },
78
+ {
79
+ name: 'get_tx_status',
80
+ description: 'Confirmation state.',
81
+ inputSchema: {
82
+ type: 'object',
83
+ properties: { txid: { type: 'string' }, network: { type: 'string' } },
84
+ required: ['txid'],
85
+ },
86
+ },
87
+ {
88
+ name: 'get_address',
89
+ description: 'Address summary (UTXO + tx counts).',
90
+ inputSchema: {
91
+ type: 'object',
92
+ properties: {
93
+ address: { type: 'string' },
94
+ network: { type: 'string' },
95
+ },
96
+ required: ['address'],
97
+ },
98
+ },
99
+ {
100
+ name: 'get_address_transactions',
101
+ description: 'Recent transactions for an address (~25 per call).',
102
+ inputSchema: {
103
+ type: 'object',
104
+ properties: {
105
+ address: { type: 'string' },
106
+ limit: { type: 'number', description: 'Default 25 (max ~50)' },
107
+ network: { type: 'string' },
108
+ },
109
+ required: ['address'],
110
+ },
111
+ },
112
+ {
113
+ name: 'hashrate',
114
+ description: 'Network hashrate + difficulty history.',
115
+ inputSchema: {
116
+ type: 'object',
117
+ properties: {
118
+ period: { type: 'string', description: '1d | 3d | 1w | 1m | 3m | 6m | 1y | 2y | 3y | all (default 3m)' },
119
+ network: { type: 'string' },
120
+ },
121
+ },
122
+ },
123
+ {
124
+ name: 'mining_pools',
125
+ description: 'Block share by mining pool.',
126
+ inputSchema: {
127
+ type: 'object',
128
+ properties: {
129
+ period: { type: 'string', description: '24h | 3d | 1w | 1m | 3m | 6m | 1y | 2y | 3y | all (default 1w)' },
130
+ network: { type: 'string' },
131
+ },
132
+ },
133
+ },
134
+ ];
135
+
136
+ async function callTool(name: string, args: Record<string, unknown>): Promise<unknown> {
137
+ const base = networkBase(args);
138
+ switch (name) {
139
+ case 'recommended_fees':
140
+ return msGet(`${base}/v1/fees/recommended`);
141
+ case 'mempool_stats':
142
+ return msGet(`${base}/mempool`);
143
+ case 'block_height': {
144
+ const tipText = await msGetText(`${base}/blocks/tip/height`);
145
+ return { network: (args.network as string) ?? 'mainnet', height: Number(tipText.trim()) };
146
+ }
147
+ case 'get_block':
148
+ return msGet(`${base}/block/${encodeURIComponent(reqStr(args, 'hash_or_height', '"850000"'))}`);
149
+ case 'get_transaction':
150
+ return msGet(`${base}/tx/${encodeURIComponent(reqStr(args, 'txid', '"abc...txid"'))}`);
151
+ case 'get_tx_status':
152
+ return msGet(`${base}/tx/${encodeURIComponent(reqStr(args, 'txid', '"abc...txid"'))}/status`);
153
+ case 'get_address':
154
+ return msGet(`${base}/address/${encodeURIComponent(reqStr(args, 'address', '"bc1q..."'))}`);
155
+ case 'get_address_transactions': {
156
+ const data = (await msGet(
157
+ `${base}/address/${encodeURIComponent(reqStr(args, 'address', '"bc1q..."'))}/txs`,
158
+ )) as unknown[];
159
+ const limit = Math.min(50, Math.max(1, (args.limit as number) ?? 25));
160
+ return { count: Math.min(limit, data.length), transactions: data.slice(0, limit) };
161
+ }
162
+ case 'hashrate':
163
+ return msGet(`${base}/v1/mining/hashrate/${encodeURIComponent(String(args.period ?? '3m'))}`);
164
+ case 'mining_pools':
165
+ return msGet(`${base}/v1/mining/pools/${encodeURIComponent(String(args.period ?? '1w'))}`);
166
+ default:
167
+ throw new Error(`Unknown tool: ${name}`);
168
+ }
169
+ }
170
+
171
+ async function msGet(url: string) {
172
+ const res = await fetch(url, {
173
+ headers: {
174
+ Accept: 'application/json',
175
+ 'User-Agent': 'pipeworx-mcp-mempool-space/1.0 (+https://pipeworx.io)',
176
+ },
177
+ });
178
+ if (res.status === 404) throw new Error('mempool.space: not found');
179
+ if (res.status === 429) throw new Error('mempool.space: rate-limit (HTTP 429)');
180
+ if (!res.ok) {
181
+ const t = await res.text();
182
+ throw new Error(`mempool.space error: ${res.status} ${t.slice(0, 200)}`);
183
+ }
184
+ return res.json();
185
+ }
186
+
187
+ async function msGetText(url: string): Promise<string> {
188
+ const res = await fetch(url, {
189
+ headers: { 'User-Agent': 'pipeworx-mcp-mempool-space/1.0 (+https://pipeworx.io)' },
190
+ });
191
+ if (!res.ok) {
192
+ const t = await res.text();
193
+ throw new Error(`mempool.space error: ${res.status} ${t.slice(0, 200)}`);
194
+ }
195
+ return res.text();
196
+ }
197
+
198
+ function reqStr(args: Record<string, unknown>, key: string, example: string): string {
199
+ const v = args[key];
200
+ if (typeof v !== 'string' || !v.trim()) {
201
+ throw new Error(`Required argument "${key}" is missing. Pass a string like ${example}.`);
202
+ }
203
+ return v;
204
+ }
205
+
206
+ export default { tools, callTool, meter: { credits: 1 } } satisfies McpToolExport;
package/tsconfig.json ADDED
@@ -0,0 +1,14 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "ESNext",
5
+ "moduleResolution": "bundler",
6
+ "strict": true,
7
+ "esModuleInterop": true,
8
+ "skipLibCheck": true,
9
+ "outDir": "dist",
10
+ "rootDir": "src",
11
+ "declaration": true
12
+ },
13
+ "include": ["src"]
14
+ }