bsv-mcp 0.0.17 → 0.0.18

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/index.ts CHANGED
@@ -37,7 +37,7 @@ const privKey = validatePrivateKey();
37
37
 
38
38
  const server = new McpServer({
39
39
  name: "Bitcoin SV MCP Server",
40
- version: "0.0.17",
40
+ version: "0.0.18",
41
41
  });
42
42
 
43
43
  // Initialize wallet with the validated private key
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.17",
5
+ "version": "0.0.18",
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",
@@ -74,21 +74,13 @@ export const walletDecryptArgsSchema = z.object({
74
74
 
75
75
  // Combined wallet encryption/decryption args
76
76
  export const walletEncryptionArgsSchema = z.object({
77
- mode: z.enum(["encrypt", "decrypt"]).describe("Operation mode: 'encrypt' to encrypt data or 'decrypt' to decrypt data"),
77
+ mode: z.enum(["encrypt", "decrypt"]).describe("Operation mode: 'encrypt' to encrypt plaintext or 'decrypt' to decrypt data"),
78
78
  data: z.union([
79
- z.string().describe("Text data (with encoding specified by the encoding parameter)"),
80
- z.array(z.number()).describe("Binary data as an array of numbers")
81
- ]).describe("Data to process: plaintext for encryption or ciphertext for decryption"),
79
+ z.string().describe("Text data to encrypt or decrypt"),
80
+ z.array(z.number()).describe("Binary data to encrypt or decrypt")
81
+ ]).describe("Data to process: text/data for encryption or decryption"),
82
82
  encoding: z.enum(["utf8", "hex", "base64"]).optional().default("utf8").describe("Encoding of text data (default: utf8)"),
83
- protocolID: walletProtocolSchema.describe("Protocol identifier - common values are 'aes' for symmetric encryption or 'ecies' for asymmetric encryption"),
84
- keyID: z.string().describe("Key identifier - use 'default' or 'primary' for the default wallet key"),
85
- privilegedReason: z.string().optional().describe("Required reason for privileged operations"),
86
- counterparty: z
87
- .union([z.string(), z.literal("self"), z.literal("anyone")])
88
- .optional()
89
- .describe("Recipient of encryption. Use 'self' for personal encryption, or provide a specific key for a recipient"),
90
- privileged: z.boolean().optional().describe("Indicates if operation requires elevated privileges"),
91
- }).describe("Combined schema for encryption and decryption operations. Use 'mode' to specify the operation type, with required parameters data, protocolID, and keyID.");
83
+ }).describe("Schema for encryption and decryption operations");
92
84
 
93
85
  // Create HMAC arguments
94
86
  export const createHmacArgsSchema = z.object({
@@ -39,7 +39,7 @@ import type { createOrdinalsArgsSchema } from "./createOrdinals";
39
39
  import { registerGetAddressTool } from "./getAddress";
40
40
  import { registerPurchaseListingTool } from "./purchaseListing";
41
41
  import { registerSendToAddressTool } from "./sendToAddress";
42
- import { Utils } from "@bsv/sdk";
42
+ import { Utils, type WalletProtocol } from "@bsv/sdk";
43
43
 
44
44
  // Define mapping from tool names to argument schemas
45
45
  type ToolArgSchemas = {
@@ -177,24 +177,18 @@ export function registerWalletTools(
177
177
  "Combined tool for encrypting and decrypting data using the wallet's cryptographic keys.\n\n" +
178
178
  "PARAMETERS:\n" +
179
179
  "- mode: (required) Either \"encrypt\" to encrypt plaintext or \"decrypt\" to decrypt ciphertext\n" +
180
- "- data: (required) Text string or array of numbers to process (plaintext for encryption or ciphertext for decryption)\n" +
181
- "- encoding: (optional) For text input, the encoding format (utf8, hex, base64) - default is utf8\n" +
182
- "- protocolID: (required) Protocol identifier - common values are 'aes' for symmetric encryption or 'ecies' for asymmetric encryption\n" +
183
- "- keyID: (required) Key identifier - use 'default' or 'primary' for the default wallet key\n\n" +
180
+ "- data: (required) Text string or array of numbers to process\n" +
181
+ "- encoding: (optional) For text input, the encoding format (utf8, hex, base64) - default is utf8\n\n" +
184
182
  "EXAMPLES:\n" +
185
183
  "1. Encrypt text data:\n" +
186
184
  " {\n" +
187
185
  " \"mode\": \"encrypt\",\n" +
188
- " \"data\": \"Hello World\",\n" +
189
- " \"protocolID\": [1, \"aes\"],\n" +
190
- " \"keyID\": \"default\"\n" +
186
+ " \"data\": \"Hello World\"\n" +
191
187
  " }\n\n" +
192
188
  "2. Decrypt previously encrypted data:\n" +
193
189
  " {\n" +
194
190
  " \"mode\": \"decrypt\",\n" +
195
- " \"data\": [encrypted bytes from previous response],\n" +
196
- " \"protocolID\": [1, \"aes\"],\n" +
197
- " \"keyID\": \"default\"\n" +
191
+ " \"data\": [encrypted bytes from previous response]\n" +
198
192
  " }",
199
193
  { args: walletEncryptionArgsSchema },
200
194
  async (
@@ -202,7 +196,11 @@ export function registerWalletTools(
202
196
  extra: RequestHandlerExtra,
203
197
  ) => {
204
198
  try {
205
- const { mode, data, protocolID, keyID, encoding } = args;
199
+ const { mode, data, encoding } = args;
200
+
201
+ // Set default values for required parameters
202
+ const protocolID: WalletProtocol = [1, "aes256"];
203
+ const keyID = "default";
206
204
 
207
205
  // Convert string data to binary if needed
208
206
  let binaryData: number[];
@@ -214,7 +212,7 @@ export function registerWalletTools(
214
212
  binaryData = toArray(data, encoding || "utf8");
215
213
  }
216
214
 
217
- let result: { ciphertext?: number[]; plaintext?: number[] } = {};
215
+ let result: { ciphertext?: number[]; plaintext?: number[] | string } = {};
218
216
  if (mode === "encrypt") {
219
217
  result = await wallet.encrypt({
220
218
  plaintext: binaryData,
@@ -229,10 +227,10 @@ export function registerWalletTools(
229
227
  });
230
228
 
231
229
  // For decryption, convert plaintext back to string if it's likely UTF-8 text
232
- if (result.plaintext) {
230
+ if (result.plaintext as number[]) {
233
231
  try {
234
232
  const { toUTF8 } = Utils;
235
- const textResult = toUTF8(result.plaintext);
233
+ const textResult = toUTF8(result.plaintext as number[]);
236
234
  // If conversion succeeds and seems like valid text, return as string
237
235
  if (textResult && textResult.length > 0) {
238
236
  return {