bsv-mcp 0.0.22 → 0.0.24

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 CHANGED
@@ -8,48 +8,94 @@
8
8
 
9
9
  A collection of Bitcoin SV (BSV) tools for the Model Context Protocol (MCP) framework. This library provides wallet, ordinals, and utility functions for BSV blockchain interaction.
10
10
 
11
+ ## Installation and Setup
12
+
13
+ ### Prerequisites
14
+
15
+ This project is built using [Bun](https://bun.sh/), a fast JavaScript runtime and package manager. While Bun is recommended for best performance, the server can also run with Node.js and npm.
16
+
17
+ #### Installing Bun (Recommended)
18
+
19
+ **macOS (using Homebrew):**
20
+ ```bash
21
+ brew tap oven-sh/bun
22
+ brew install bun
23
+ ```
24
+
25
+ **macOS/Linux/WSL (using installer script):**
26
+ ```bash
27
+ curl -fsSL https://bun.sh/install | bash
28
+ ```
29
+
30
+ **Windows:**
31
+ Windows users should use WSL (Windows Subsystem for Linux) or Docker to run Bun.
32
+
33
+ Node.js and npm will also work but may not offer the same performance benefits.
34
+
11
35
  ## Connecting to MCP Clients
12
36
 
13
37
  This server implements the [Model Context Protocol](https://modelcontextprotocol.io/) (MCP), allowing AI assistants to utilize Bitcoin SV functionalities. You can connect this server to various MCP-compatible clients.
14
38
 
39
+ ![MCP Configuration Example](docs/images/mcp-config-example.png)
40
+
15
41
  ### Cursor
16
42
 
17
43
  To use the BSV MCP server with [Cursor](https://cursor.sh/):
18
44
 
19
45
  1. Install Cursor if you haven't already
20
- 2. Clone this repository and run `bun install` in the project directory
21
- 3. Open Cursor and navigate to Settings → Extensions → Model Context Protocol
22
- 4. Click "Add a new global MCP server"
23
- 5. Enter the following configuration in JSON format:
46
+ 2. Open Cursor and navigate to Settings Extensions Model Context Protocol
47
+ 3. Click "Add a new global MCP server"
48
+ 4. Enter the following configuration in JSON format:
24
49
 
25
50
  ```json
26
- {
27
- "mcpServers": {
28
- "Bitcoin SV": {
29
- "command": "bunx",
30
- "args": [
31
- "bsv-mcp@latest"
32
- ],
33
- "env": {
34
- "PRIVATE_KEY_WIF": "<your_private_key_wif>"
35
- }
51
+ {
52
+ "mcpServers": {
53
+ "Bitcoin SV": {
54
+ "command": "bunx",
55
+ "args": [
56
+ "bsv-mcp@latest"
57
+ ],
58
+ "env": {
59
+ "PRIVATE_KEY_WIF": "<your_private_key_wif>"
36
60
  }
37
61
  }
38
62
  }
63
+ }
39
64
  ```
40
65
 
41
- 6. Replace `<your_private_key_wif>` with your actual private key WIF (keep this secure!)
42
- 7. Click "Save"
66
+ 5. Replace `<your_private_key_wif>` with your actual private key WIF (keep this secure!)
67
+ 6. Click "Save"
43
68
 
44
69
  The BSV tools will now be available to Cursor's AI assistant under the "Bitcoin SV" namespace.
45
70
 
71
+ #### Alternative for npm users
72
+
73
+ If you prefer to use npm instead of Bun:
74
+
75
+ ```json
76
+ {
77
+ "mcpServers": {
78
+ "Bitcoin SV": {
79
+ "command": "npx",
80
+ "args": [
81
+ "bsv-mcp@latest"
82
+ ],
83
+ "env": {
84
+ "PRIVATE_KEY_WIF": "<your_private_key_wif>"
85
+ }
86
+ }
87
+ }
88
+ }
89
+ ```
90
+
46
91
  ### Claude for Desktop
47
92
 
48
93
  To connect this server to Claude for Desktop:
49
94
 
50
- 1. Ensure you have [Claude for Desktop](https://claude.ai/desktop) installed and updated to the latest version
51
- 2. Clone this repository and run `bun install` in the project directory
52
- 3. Open your Claude for Desktop configuration file:
95
+ 1. Open [Claude for Desktop](https://claude.ai/desktop) and go to Claude > Settings > Developer
96
+ 2. Click "Edit Config".
97
+
98
+ Open the Claude configuration json file in your favorite text editor. If you prefer to do it from the cli:
53
99
 
54
100
  ```bash
55
101
  # macOS/Linux
@@ -59,25 +105,29 @@ To connect this server to Claude for Desktop:
59
105
  code %APPDATA%\Claude\claude_desktop_config.json
60
106
  ```
61
107
 
62
- 4. Add the BSV MCP server to your configuration (create the file if it doesn't exist):
108
+ 3. Add the BSV MCP server to your configuration:
63
109
  ```json
64
- {
65
- "mcpServers": {
66
- "Bitcoin SV": {
67
- "command": "bunx",
68
- "args": [
69
- "bsv-mcp@latest"
70
- ],
71
- "env": {
72
- "PRIVATE_KEY_WIF": "<your_private_key_wif>"
73
- }
74
- }
75
- }
76
- }
110
+ {
111
+ "mcpServers": {
112
+ "Bitcoin SV": {
113
+ "command": "bunx",
114
+ "args": [
115
+ "bsv-mcp@latest"
116
+ ],
117
+ "env": {
118
+ "PRIVATE_KEY_WIF": "<your_private_key_wif>"
119
+ }
120
+ }
121
+ }
122
+ }
77
123
  ```
78
- 5. Replace `<your_private_key_wif>` with your actual private key WIF
79
- 6. Save the file and restart Claude for Desktop
80
- 7. The BSV tools will appear when you click the tools icon (hammer) in Claude for Desktop
124
+ 4. Replace `<your_private_key_wif>` with your actual private key WIF
125
+ 5. Save the file and restart Claude for Desktop
126
+ 6. The BSV tools will appear when you click the tools icon (hammer) in Claude for Desktop
127
+
128
+ #### Alternative for npm users (Claude)
129
+
130
+ If you prefer to use npm instead of Bun, replace the "command" field with "npx".
81
131
 
82
132
  ## Available Tools
83
133
 
@@ -177,6 +227,102 @@ Once connected, you can use natural language to interact with Bitcoin SV through
177
227
 
178
228
  - "Convert 'Hello World' from UTF-8 to hex format"
179
229
 
230
+ ## MCP Prompts and Resources
231
+
232
+ The BSV MCP server exposes specialized prompts and resources that provide detailed information and context about Bitcoin SV technologies. These can be accessed by AI models to enhance their understanding and capabilities.
233
+
234
+ ### Available Prompts
235
+
236
+ The server provides the following educational prompts that can be accessed directly via the MCP protocol:
237
+
238
+ #### Ordinals Prompt
239
+ - **Identifier**: `bitcoin_sv_ordinals`
240
+ - **Description**: Comprehensive information about Bitcoin SV ordinals, including what they are, how they work, and how to use them.
241
+ - **Usage**: Ask the assistant about "Bitcoin SV ordinals" or "1Sat Ordinals" to access this information.
242
+
243
+ #### BSV SDK Prompts
244
+ A collection of prompts providing detailed information about the Bitcoin SV SDK:
245
+
246
+ - **Overview**
247
+ - **Identifier**: `bitcoin_sv_sdk_overview`
248
+ - **Description**: General overview of the Bitcoin SV SDK, including its purpose and main components.
249
+ - **Usage**: "Tell me about the BSV SDK" or "What is the Bitcoin SV SDK?"
250
+
251
+ - **Wallet Operations**
252
+ - **Identifier**: `bitcoin_sv_sdk_wallet`
253
+ - **Description**: Information about wallet operations in the BSV SDK.
254
+ - **Usage**: "How do wallet operations work in the BSV SDK?"
255
+
256
+ - **Transaction Building**
257
+ - **Identifier**: `bitcoin_sv_sdk_transaction`
258
+ - **Description**: Details about transaction creation and manipulation.
259
+ - **Usage**: "Explain BSV SDK transaction building" or "How do I create transactions with BSV SDK?"
260
+
261
+ - **Authentication**
262
+ - **Identifier**: `bitcoin_sv_sdk_auth`
263
+ - **Description**: Authentication and identity protocols in BSV SDK.
264
+ - **Usage**: "How does authentication work with BSV SDK?"
265
+
266
+ - **Cryptography**
267
+ - **Identifier**: `bitcoin_sv_sdk_cryptography`
268
+ - **Description**: Signing, encryption, and verification functionality.
269
+ - **Usage**: "Explain BSV SDK cryptography features"
270
+
271
+ - **Scripting**
272
+ - **Identifier**: `bitcoin_sv_sdk_script`
273
+ - **Description**: Bitcoin scripting and contract capabilities.
274
+ - **Usage**: "How do I work with Bitcoin scripts using the BSV SDK?"
275
+
276
+ - **Primitives**
277
+ - **Identifier**: `bitcoin_sv_sdk_primitives`
278
+ - **Description**: Core data types and structures in the BSV SDK.
279
+ - **Usage**: "What primitives are available in the BSV SDK?"
280
+
281
+ ### Available Resources
282
+
283
+ The server also provides access to Bitcoin Request for Comments (BRC) specifications and documentation:
284
+
285
+ #### BRC Resources
286
+ - **BRCs Overview**
287
+ - **Identifier**: `brcs_readme`
288
+ - **Description**: Overview of all Bitcoin SV protocol specifications in the BRCs repository.
289
+ - **Usage**: "Show me the Bitcoin SV BRCs overview"
290
+
291
+ - **BRCs Summary**
292
+ - **Identifier**: `brcs_summary`
293
+ - **Description**: Table of contents for all Bitcoin SV BRCs.
294
+ - **Usage**: "Give me a summary of Bitcoin SV BRCs"
295
+
296
+ - **Specific BRC Specifications**
297
+ - **Identifier**: `brc_spec`
298
+ - **Description**: Access specific BRC specifications by category and number.
299
+ - **Usage**: "Show me BRC 8 on Transaction Envelopes" or "What does BRC 1 specify?"
300
+
301
+ #### BRC Categories
302
+ The BRC specifications are organized into the following categories:
303
+ - Wallet
304
+ - Transactions
305
+ - Scripts
306
+ - Tokens
307
+ - Overlays
308
+ - Payments
309
+ - Peer-to-Peer
310
+ - Key Derivation
311
+ - Outpoints
312
+ - Opinions
313
+ - State Machines
314
+ - Apps
315
+
316
+ ### Using Prompts and Resources
317
+
318
+ AI models can use these prompts and resources to provide more accurate and detailed responses about Bitcoin SV technologies. As a user, you can:
319
+
320
+ 1. **Ask about a specific topic**: "Tell me about Bitcoin SV ordinals" or "Explain BSV SDK transaction building"
321
+ 2. **Request specific BRC details**: "What does BRC 8 specify?" or "Show me the BRC on Transaction Creation"
322
+ 3. **Get general overviews**: "What is the BSV SDK?" or "Show me a summary of all BRCs"
323
+
324
+ These prompts and resources enhance the AI's knowledge base, enabling more technical and accurate responses even for complex Bitcoin SV topics.
325
+
180
326
  ## How MCP Works
181
327
 
182
328
  When you interact with an MCP-enabled AI assistant:
@@ -189,17 +335,39 @@ When you interact with an MCP-enabled AI assistant:
189
335
 
190
336
  ## Troubleshooting
191
337
 
192
- If you're having issues connecting to the server:
338
+ If you're having issues with the BSV MCP server:
193
339
 
194
- 1. Ensure the package dependencies are properly installed: `bun install`
340
+ ### Connection Issues
341
+
342
+ 1. Make sure Bun or Node.js is installed on your system
195
343
  2. Verify your WIF private key is correctly set in the environment
196
344
  3. Check that your client supports MCP and is properly configured
197
345
  4. Look for error messages in the client's console output
198
346
 
347
+ ### Keeping Bun Up to Date
348
+
349
+ It's important to keep Bun updated to the latest version to ensure compatibility:
350
+
351
+ ```bash
352
+ # Update Bun to the latest version
353
+ bun upgrade
354
+ ```
355
+
356
+ To verify your current Bun version:
357
+ ```bash
358
+ bun --version
359
+ ```
360
+
361
+ ### Logging and Debugging
362
+
199
363
  For Claude for Desktop, check the logs at:
200
364
 
201
365
  ```bash
366
+ # macOS/Linux
202
367
  tail -n 20 -f ~/Library/Logs/Claude/mcp*.log
368
+
369
+ # Windows
370
+ type %APPDATA%\Claude\Logs\mcp*.log
203
371
  ```
204
372
 
205
373
  For Cursor, check the Cursor MCP logs in Settings → Extensions → Model Context Protocol.
@@ -312,16 +480,37 @@ The tool supports both mainnet and testnet:
312
480
 
313
481
  # Development
314
482
 
483
+ ## Project Setup
484
+
485
+ If you want to contribute to the project or run it locally:
486
+
487
+ 1. Clone the repository:
488
+ ```bash
489
+ git clone https://github.com/b-open-io/bsv-mcp.git
490
+ cd bsv-mcp
491
+ ```
492
+
493
+ 2. Install dependencies:
494
+ ```bash
495
+ bun install
496
+ # or with npm
497
+ npm install
498
+ ```
499
+
315
500
  ## Running the Server
316
501
 
317
502
  ```bash
318
503
  bun run index.ts
504
+ # or with npm
505
+ npm run start
319
506
  ```
320
507
 
321
508
  ### Running Tests
322
509
 
323
510
  ```bash
324
511
  bun test
512
+ # or with npm
513
+ npm test
325
514
  ```
326
515
 
327
516
  ## License
package/index.ts CHANGED
@@ -2,6 +2,8 @@
2
2
  import { PrivateKey } from "@bsv/sdk";
3
3
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
4
4
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
5
+ import { registerAllPrompts } from "./prompts";
6
+ import { registerResources } from "./resources/resources";
5
7
  import { registerAllTools } from "./tools";
6
8
  import { registerWalletTools } from "./tools/wallet/tools";
7
9
  import { Wallet } from "./tools/wallet/wallet";
@@ -11,42 +13,57 @@ import { Wallet } from "./tools/wallet/wallet";
11
13
  * Exits the process with an error message if validation fails
12
14
  */
13
15
  function validatePrivateKey(): PrivateKey {
14
- const privateKeyWif = process.env.PRIVATE_KEY_WIF;
15
-
16
- // Check if private key is set
17
- if (!privateKeyWif) {
18
- console.error(
19
- "\x1b[31mError: PRIVATE_KEY_WIF environment variable is not set\x1b[0m"
20
- );
21
- console.error(
22
- "Please set this variable with a valid Bitcoin SV private key in WIF format"
23
- );
24
- console.error(
25
- "Example: PRIVATE_KEY_WIF=your_private_key_wif bun run index.ts"
26
- );
27
- process.exit(1);
28
- }
29
-
30
- // Validate the private key format
31
- try {
32
- return PrivateKey.fromWif(privateKeyWif);
33
- } catch (error) {
34
- console.error("\x1b[31mError: Invalid private key format\x1b[0m");
35
- console.error(
36
- "The PRIVATE_KEY_WIF provided is not a valid Bitcoin SV private key in WIF format"
37
- );
38
- console.error("Please check your key and try again");
39
- process.exit(1);
40
- }
16
+ const privateKeyWif = process.env.PRIVATE_KEY_WIF;
17
+
18
+ // Check if private key is set
19
+ if (!privateKeyWif) {
20
+ console.error(
21
+ "\x1b[31mError: PRIVATE_KEY_WIF environment variable is not set\x1b[0m",
22
+ );
23
+ console.error(
24
+ "Please set this variable with a valid Bitcoin SV private key in WIF format",
25
+ );
26
+ console.error(
27
+ "Example: PRIVATE_KEY_WIF=your_private_key_wif bun run index.ts",
28
+ );
29
+ process.exit(1);
30
+ }
31
+
32
+ // Validate the private key format
33
+ try {
34
+ return PrivateKey.fromWif(privateKeyWif);
35
+ } catch (error) {
36
+ console.error("\x1b[31mError: Invalid private key format\x1b[0m");
37
+ console.error(
38
+ "The PRIVATE_KEY_WIF provided is not a valid Bitcoin SV private key in WIF format",
39
+ );
40
+ console.error("Please check your key and try again");
41
+ process.exit(1);
42
+ }
41
43
  }
42
44
 
43
45
  // Validate private key early before starting the server
44
46
  const privKey = validatePrivateKey();
45
47
 
46
- const server = new McpServer({
47
- name: "Bitcoin SV MCP Server",
48
- version: "0.0.22",
49
- });
48
+ const server = new McpServer(
49
+ { name: "Bitcoin SV", version: "0.0.24" },
50
+ // {
51
+ // // Advertise only what you actually implement
52
+ // capabilities: {
53
+ // completions: {},
54
+ // experimental: {},
55
+ // logging: {},
56
+ // prompts: {},
57
+ // resources: {},
58
+ // tools: {},
59
+ // },
60
+ // // Optional instructions banner for clients
61
+ // instructions: `
62
+ // This server exposes Bitcoin SV helpers.
63
+ // Tools are idempotent unless marked destructive.
64
+ // `,
65
+ // },
66
+ );
50
67
 
51
68
  // Initialize wallet with the validated private key
52
69
  const wallet = new Wallet(privKey);
@@ -57,6 +74,12 @@ registerWalletTools(server, wallet);
57
74
  // Register all other tools (BSV, Ordinals, Utils, etc.)
58
75
  registerAllTools(server);
59
76
 
77
+ // Register resources
78
+ registerResources(server);
79
+
80
+ // Register prompts
81
+ registerAllPrompts(server);
82
+
60
83
  // Connect to the transport
61
84
  const transport = new StdioServerTransport();
62
85
  await server.connect(transport);
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "bsv-mcp",
3
3
  "module": "index.ts",
4
4
  "type": "module",
5
- "version": "0.0.22",
5
+ "version": "0.0.24",
6
6
  "license": "MIT",
7
7
  "author": "satchmo",
8
8
  "description": "A collection of Bitcoin SV (BSV) tools for the Model Context Protocol (MCP) framework",
@@ -41,8 +41,8 @@
41
41
  "typescript": "^5.8.3"
42
42
  },
43
43
  "dependencies": {
44
- "@bsv/sdk": "^1.4.19",
45
- "@modelcontextprotocol/sdk": "^1.10.1",
44
+ "@bsv/sdk": "^1.4.20",
45
+ "@modelcontextprotocol/sdk": "^1.10.2",
46
46
  "@types/node": "^22.14.1",
47
47
  "js-1sat-ord": "^0.1.81",
48
48
  "mnee": "^2.0.0",
@@ -0,0 +1,32 @@
1
+ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ import type { RequestHandlerExtra } from "@modelcontextprotocol/sdk/shared/protocol.js";
3
+ import { z } from "zod";
4
+
5
+ // Schema for invoking another agent via A2A protocol
6
+ export const a2aCallArgsSchema = z.object({
7
+ url: z.string().url().describe("Full agent-to-agent endpoint URL"),
8
+ method: z.string().describe("A2A method name to invoke"),
9
+ params: z
10
+ .record(z.any())
11
+ .optional()
12
+ .describe("Payload parameters for the A2A call"),
13
+ });
14
+ export type A2aCallArgs = z.infer<typeof a2aCallArgsSchema>;
15
+
16
+ /**
17
+ * Registers the a2a_call tool for agent-to-agent HTTP/SSE calls
18
+ */
19
+ export function registerA2aCallTool(server: McpServer) {
20
+ server.tool(
21
+ "a2a_call",
22
+ "Invoke a remote agent's A2A endpoint via HTTP/SSE",
23
+ { args: a2aCallArgsSchema },
24
+ async ({ args }: { args: A2aCallArgs }, extra: RequestHandlerExtra) => {
25
+ // TODO: implement HTTP request logic (e.g., fetch, SSE)
26
+ return {
27
+ content: [{ type: "text", text: "Not implemented" }],
28
+ isError: true,
29
+ };
30
+ },
31
+ );
32
+ }
@@ -0,0 +1,101 @@
1
+ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ import type { RequestHandlerExtra } from "@modelcontextprotocol/sdk/shared/protocol.js";
3
+ import type {
4
+ ServerNotification,
5
+ ServerRequest,
6
+ } from "@modelcontextprotocol/sdk/types.js";
7
+ import { z } from "zod";
8
+
9
+ type OverlayRequest = {
10
+ type: "agent" | "tool";
11
+ query: string;
12
+ limit: number;
13
+ offset: number;
14
+ fromBlock?: number;
15
+ toBlock?: number;
16
+ };
17
+
18
+ type OverlayResponse = {
19
+ agents: {
20
+ name: string;
21
+ description: string;
22
+ capabilities: string[];
23
+ }[];
24
+ tools: {
25
+ name: string;
26
+ description: string;
27
+ }[];
28
+ };
29
+
30
+ // Schema for agent discovery parameters
31
+ export const a2bDiscoverArgsSchema = z.object({
32
+ queryType: z.enum(["agent", "tool"]).describe("Type of discovery to perform"),
33
+ query: z.string().describe("Search agent or tool names, descriptions"),
34
+ limit: z.number().optional().describe("Limit the number of results"),
35
+ offset: z.number().optional().describe("Offset the results"),
36
+ fromBlock: z.number().optional().describe("From block"),
37
+ toBlock: z.number().optional().describe("To block"),
38
+ });
39
+ export type A2bDiscoverArgs = z.infer<typeof a2bDiscoverArgsSchema>;
40
+
41
+ /**
42
+ * Registers the a2b_discover tool for on-chain agent discovery
43
+ */
44
+ export function registerA2bDiscoverTool(server: McpServer) {
45
+ server.tool(
46
+ "a2b_discover",
47
+ "Search on-chain agent and MCP tool records. Use 'agent' to search for agents, 'tool' to search for MCP tools.",
48
+ { args: a2bDiscoverArgsSchema },
49
+ async (
50
+ { args }: { args: A2bDiscoverArgs },
51
+ extra: RequestHandlerExtra<ServerRequest, ServerNotification>,
52
+ ) => {
53
+ if (args.queryType === "agent") {
54
+ return {
55
+ content: [
56
+ { type: "text", text: "Agent discovery is not supported yet" },
57
+ ],
58
+ isError: true,
59
+ };
60
+ }
61
+
62
+ if (args.queryType !== "tool") {
63
+ return {
64
+ content: [
65
+ {
66
+ type: "text",
67
+ text: "Only tool discovery is supported currently",
68
+ },
69
+ ],
70
+ isError: true,
71
+ };
72
+ }
73
+
74
+ try {
75
+ const params = new URLSearchParams();
76
+ params.set("type", args.queryType);
77
+ params.set("query", args.query);
78
+ params.set("limit", args.limit?.toString() ?? "5");
79
+ params.set("offset", args.offset?.toString() ?? "0");
80
+ if (args.fromBlock) {
81
+ params.set("fromBlock", args.fromBlock.toString());
82
+ }
83
+ if (args.toBlock) {
84
+ params.set("toBlock", args.toBlock.toString());
85
+ }
86
+ const OVERLAY_URL = `https://overlay.a2b.network/v1/search?${params.toString()}`;
87
+ const response = await fetch(OVERLAY_URL);
88
+ const data = (await response.json()) as OverlayResponse;
89
+ return {
90
+ content: [{ type: "text", text: JSON.stringify(data) }],
91
+ isError: false,
92
+ };
93
+ } catch (error) {
94
+ return {
95
+ content: [{ type: "text", text: `Error querying overlay: ${error}` }],
96
+ isError: true,
97
+ };
98
+ }
99
+ },
100
+ );
101
+ }