bsv-mcp 0.0.26 → 0.0.28

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,17 @@
1
+ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ import { registerBRCsResources } from "./brcs";
3
+ import { registerChangelogResource } from "./changelog";
4
+
5
+ /**
6
+ * Register all resources with the MCP server
7
+ * @param server The MCP server instance
8
+ */
9
+ export function registerResources(server: McpServer): void {
10
+ // Register BRC-related resources
11
+ registerBRCsResources(server);
12
+
13
+ // Register changelog resource
14
+ registerChangelogResource(server);
15
+
16
+ // Add more resource categories here as needed
17
+ }
package/tools/index.ts CHANGED
@@ -7,7 +7,7 @@ import { registerUtilsTools } from "./utils";
7
7
 
8
8
  /**
9
9
  * Configuration options for tools
10
- *
10
+ *
11
11
  * These options can be controlled through environment variables:
12
12
  * - enableBsvTools: controlled by DISABLE_BSV_TOOLS
13
13
  * - enableOrdinalsTools: controlled by DISABLE_ORDINALS_TOOLS
@@ -27,19 +27,19 @@ export interface ToolsConfig {
27
27
  * @param config Configuration options
28
28
  */
29
29
  export function registerAllTools(
30
- server: McpServer,
30
+ server: McpServer,
31
31
  config: ToolsConfig = {
32
32
  enableBsvTools: true,
33
33
  enableOrdinalsTools: true,
34
34
  enableUtilsTools: true,
35
- enableA2bTools: true
36
- }
35
+ enableA2bTools: true,
36
+ },
37
37
  ): void {
38
38
  const {
39
39
  enableBsvTools = true,
40
40
  enableOrdinalsTools = true,
41
41
  enableUtilsTools = true,
42
- enableA2bTools = true
42
+ enableA2bTools = true,
43
43
  } = config;
44
44
 
45
45
  // Register BSV-related tools
@@ -65,11 +65,16 @@ export function registerSendMneeTool(server: McpServer, mnee: Mnee): void {
65
65
  content: [
66
66
  {
67
67
  type: "text",
68
- text: JSON.stringify({
69
- success: false,
70
- error: "No private key available",
71
- message: "Please set PRIVATE_KEY_WIF environment variable with a valid Bitcoin SV private key in WIF format.",
72
- }, null, 2),
68
+ text: JSON.stringify(
69
+ {
70
+ success: false,
71
+ error: "No private key available",
72
+ message:
73
+ "Please set PRIVATE_KEY_WIF environment variable with a valid Bitcoin SV private key in WIF format.",
74
+ },
75
+ null,
76
+ 2,
77
+ ),
73
78
  },
74
79
  ],
75
80
  isError: true,
@@ -26,17 +26,18 @@ export function registerGetAddressTool(server: McpServer): void {
26
26
  content: [
27
27
  {
28
28
  type: "text",
29
- text: JSON.stringify({
30
- error: "No private key available",
31
- message: "Please set PRIVATE_KEY_WIF environment variable with a valid Bitcoin SV private key in WIF format.",
32
- status: "error"
29
+ text: JSON.stringify({
30
+ error: "No private key available",
31
+ message:
32
+ "Please set PRIVATE_KEY_WIF environment variable with a valid Bitcoin SV private key in WIF format.",
33
+ status: "error",
33
34
  }),
34
35
  },
35
36
  ],
36
37
  isError: true,
37
38
  };
38
39
  }
39
-
40
+
40
41
  const privKey = PrivateKey.fromWif(wif);
41
42
  const address = privKey.toAddress();
42
43
  return {
@@ -50,14 +51,16 @@ export function registerGetAddressTool(server: McpServer): void {
50
51
  } catch (err: unknown) {
51
52
  const msg = err instanceof Error ? err.message : String(err);
52
53
  return {
53
- content: [{
54
- type: "text",
55
- text: JSON.stringify({
56
- error: "Invalid private key",
57
- message: msg,
58
- status: "error"
59
- })
60
- }],
54
+ content: [
55
+ {
56
+ type: "text",
57
+ text: JSON.stringify({
58
+ error: "Invalid private key",
59
+ message: msg,
60
+ status: "error",
61
+ }),
62
+ },
63
+ ],
61
64
  isError: true,
62
65
  };
63
66
  }
@@ -1,76 +0,0 @@
1
- import { expect, test } from "bun:test";
2
- import { PrivateKey } from "@bsv/sdk";
3
- import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
4
- import type { RequestHandlerExtra } from "@modelcontextprotocol/sdk/shared/protocol.js";
5
- import { getPublicKeyArgsSchema } from "./schemas";
6
- import { registerWalletTools } from "./tools";
7
- import { Wallet } from "./wallet";
8
-
9
- // Define type for tool names to ensure they match what's in tools.ts
10
- type WalletToolName =
11
- | "wallet_getPublicKey"
12
- | "wallet_createSignature"
13
- | "wallet_verifySignature"
14
- | "wallet_encryption";
15
-
16
- const toolNames: WalletToolName[] = [
17
- "wallet_getPublicKey",
18
- "wallet_createSignature",
19
- "wallet_verifySignature",
20
- "wallet_encryption",
21
- ];
22
-
23
- // Helper function to get dummy arguments for each tool
24
- function getDummyArgs(tool: WalletToolName): Record<string, unknown> {
25
- switch (tool) {
26
- case "wallet_getPublicKey":
27
- return getPublicKeyArgsSchema.parse({});
28
- case "wallet_createSignature":
29
- return { data: "test", keyType: "identity" };
30
- case "wallet_verifySignature":
31
- return {
32
- data: "test",
33
- keyType: "identity",
34
- signature: "sig",
35
- publicKey: "pubkey",
36
- };
37
- // TODO we merged encrypt and decrypt into encryption we need to update the test file
38
- // case "wallet_encryption":
39
- // if
40
- // return { data: "test", publicKey: "pubkey" };
41
- // case "wallet_decryption":
42
- // return { encryptedData: "data" };
43
- default:
44
- return {};
45
- }
46
- }
47
-
48
- // Bun test
49
- for (const tool of toolNames) {
50
- test(`tool ${tool} returns not implemented error`, async () => {
51
- const server = new McpServer({ name: "Test", version: "0.0.1" });
52
- const wallet = new Wallet(
53
- PrivateKey.fromWif(
54
- "KyqU1boXYdksJKyxfsCtvBxfbt2a8XQd2aPhVZHNxMzvms9hRAvz",
55
- ),
56
- );
57
- const handlers = registerWalletTools(server, wallet);
58
-
59
- // Get the handler for this tool
60
- const handler = handlers[tool];
61
- if (!handler) {
62
- throw new Error(`Tool ${tool} not registered`);
63
- }
64
-
65
- // Create a mock RequestHandlerExtra with required properties
66
- const mockExtra: RequestHandlerExtra = {
67
- signal: new AbortController().signal,
68
- };
69
-
70
- // Call the handler with dummy arguments
71
- const result = await handler({ args: getDummyArgs(tool) }, mockExtra);
72
-
73
- expect(result.isError).toBe(true);
74
- expect(result.content?.[0]?.text ?? "").toMatch(/not implemented/i);
75
- });
76
- }