bsv-mcp 0.0.14 → 0.0.16
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 +3 -1
- package/index.ts +1 -1
- package/package.json +1 -1
- package/tools/bsv/explore.ts +8 -3
- package/tools/index.ts +0 -0
- package/tools/utils/index.ts +14 -1
- package/tools/wallet/schemas.ts +7 -6
- package/tools/wallet/tools.ts +23 -1
package/README.md
CHANGED
|
@@ -177,7 +177,7 @@ General-purpose utility functions:
|
|
|
177
177
|
|
|
178
178
|
| Tool Name | Description | Example Output |
|
|
179
179
|
|-----------|-------------|----------------|
|
|
180
|
-
| `utils_convertData` | Converts data between different
|
|
180
|
+
| `utils_convertData` | Converts data between different encoding formats (utf8, hex, base64, binary).<br><br>**Parameters:**<br>- `data` (required): The string to convert<br>- `from` (required): Source encoding format (utf8, hex, base64, or binary)<br>- `to` (required): Target encoding format (utf8, hex, base64, or binary)<br><br>**Examples:**<br>- UTF-8 to hex: `{"data": "hello world", "from": "utf8", "to": "hex"}` → `68656c6c6f20776f726c64`<br>- UTF-8 to base64: `{"data": "Hello World", "from": "utf8", "to": "base64"}` → `SGVsbG8gV29ybGQ=`<br>- base64 to UTF-8: `{"data": "SGVsbG8gV29ybGQ=", "from": "base64", "to": "utf8"}` → `Hello World`<br>- hex to base64: `{"data": "68656c6c6f20776f726c64", "from": "hex", "to": "base64"}` → `aGVsbG8gd29ybGQ=`<br><br>**Notes:**<br>- All parameters are required<br>- The tool returns the converted data as a string<br>- For binary conversion, data is represented as an array of byte values | `"SGVsbG8gV29ybGQ="` (UTF-8 "Hello World" converted to base64) |
|
|
181
181
|
|
|
182
182
|
## Using the Tools with MCP
|
|
183
183
|
|
|
@@ -266,6 +266,7 @@ The tool supports the following endpoint categories and specific endpoints:
|
|
|
266
266
|
|----------|-------------|---------------------|------------------|
|
|
267
267
|
| `block_by_hash` | Complete block data via hash | `blockHash` | `{"hash":"000000000000...","confirmations":1000,"size":1000000,...}` |
|
|
268
268
|
| `block_by_height` | Complete block data via height | `blockHeight` | `{"hash":"000000000000...","confirmations":1000,"size":1000000,...}` |
|
|
269
|
+
| `tag_count_by_height` | Stats on tag count for a specific block | `blockHeight` | `{"tags":{"amp":3,"bitkey":5,"metanet":12,"planaria":7,"b":120}}` |
|
|
269
270
|
|
|
270
271
|
#### Transaction Data
|
|
271
272
|
| Endpoint | Description | Required Parameters | Example Response |
|
|
@@ -292,6 +293,7 @@ The `bsv_explore` tool can be used with natural language prompts like:
|
|
|
292
293
|
```
|
|
293
294
|
"Get the current Bitcoin SV blockchain information"
|
|
294
295
|
"Show me block #800000 details"
|
|
296
|
+
"Get tag count statistics for block #800000"
|
|
295
297
|
"Fetch transaction history for address 1ExampleBsvAddressXXXXXXXX"
|
|
296
298
|
"Get unspent outputs for my wallet address"
|
|
297
299
|
"Check transaction details for txid a1b2c3d4e5f6..."
|
package/index.ts
CHANGED
package/package.json
CHANGED
package/tools/bsv/explore.ts
CHANGED
|
@@ -17,6 +17,7 @@ enum ExploreEndpoint {
|
|
|
17
17
|
// Block endpoints
|
|
18
18
|
BLOCK_BY_HASH = "block_by_hash",
|
|
19
19
|
BLOCK_BY_HEIGHT = "block_by_height",
|
|
20
|
+
TAG_COUNT_BY_HEIGHT = "tag_count_by_height",
|
|
20
21
|
|
|
21
22
|
// Transaction endpoints
|
|
22
23
|
TX_BY_HASH = "tx_by_hash",
|
|
@@ -65,7 +66,8 @@ export function registerExploreTool(server: McpServer): void {
|
|
|
65
66
|
"- peer_info: Connected peer statistics\n\n" +
|
|
66
67
|
"BLOCK DATA:\n" +
|
|
67
68
|
"- block_by_hash: Complete block data via hash (requires blockHash parameter)\n" +
|
|
68
|
-
"- block_by_height: Complete block data via height (requires blockHeight parameter)\n
|
|
69
|
+
"- block_by_height: Complete block data via height (requires blockHeight parameter)\n" +
|
|
70
|
+
"- tag_count_by_height: Stats on tag count for a specific block via height (requires blockHeight parameter)\n\n" +
|
|
69
71
|
"TRANSACTION DATA:\n" +
|
|
70
72
|
"- tx_by_hash: Detailed transaction data (requires txHash parameter)\n" +
|
|
71
73
|
"- tx_raw: Raw transaction hex data (requires txHash parameter)\n" +
|
|
@@ -86,8 +88,8 @@ export function registerExploreTool(server: McpServer): void {
|
|
|
86
88
|
throw new Error("blockHash is required for block_by_hash endpoint");
|
|
87
89
|
}
|
|
88
90
|
|
|
89
|
-
if (params.endpoint === ExploreEndpoint.BLOCK_BY_HEIGHT && params.blockHeight === undefined) {
|
|
90
|
-
throw new Error("blockHeight is required for block_by_height
|
|
91
|
+
if ((params.endpoint === ExploreEndpoint.BLOCK_BY_HEIGHT || params.endpoint === ExploreEndpoint.TAG_COUNT_BY_HEIGHT) && params.blockHeight === undefined) {
|
|
92
|
+
throw new Error("blockHeight is required for block_by_height and tag_count_by_height endpoints");
|
|
91
93
|
}
|
|
92
94
|
|
|
93
95
|
if ([ExploreEndpoint.TX_BY_HASH, ExploreEndpoint.TX_RAW, ExploreEndpoint.TX_RECEIPT].includes(params.endpoint) && !params.txHash) {
|
|
@@ -120,6 +122,9 @@ export function registerExploreTool(server: McpServer): void {
|
|
|
120
122
|
case ExploreEndpoint.BLOCK_BY_HEIGHT:
|
|
121
123
|
apiUrl += `/block/height/${params.blockHeight}`;
|
|
122
124
|
break;
|
|
125
|
+
case ExploreEndpoint.TAG_COUNT_BY_HEIGHT:
|
|
126
|
+
apiUrl += `/block/tagcount/height/${params.blockHeight}/stats`;
|
|
127
|
+
break;
|
|
123
128
|
case ExploreEndpoint.TX_BY_HASH:
|
|
124
129
|
apiUrl += `/tx/hash/${params.txHash}`;
|
|
125
130
|
break;
|
package/tools/index.ts
CHANGED
|
File without changes
|
package/tools/utils/index.ts
CHANGED
|
@@ -11,7 +11,20 @@ const encodingSchema = z.enum(["utf8", "hex", "base64", "binary"]);
|
|
|
11
11
|
export function registerUtilsTools(server: McpServer): void {
|
|
12
12
|
server.tool(
|
|
13
13
|
"utils_convertData",
|
|
14
|
-
"Converts data between different encodings (utf8, hex, base64, binary). Useful for transforming data formats when working with blockchain data, encryption, or file processing
|
|
14
|
+
"Converts data between different encodings (utf8, hex, base64, binary). Useful for transforming data formats when working with blockchain data, encryption, or file processing.\n\n" +
|
|
15
|
+
"Parameters:\n" +
|
|
16
|
+
"- data (required): The string to convert\n" +
|
|
17
|
+
"- from (required): Source encoding format (utf8, hex, base64, or binary)\n" +
|
|
18
|
+
"- to (required): Target encoding format (utf8, hex, base64, or binary)\n\n" +
|
|
19
|
+
"Example usage:\n" +
|
|
20
|
+
"- UTF-8 to hex: {\"data\": \"hello world\", \"from\": \"utf8\", \"to\": \"hex\"} → 68656c6c6f20776f726c64\n" +
|
|
21
|
+
"- UTF-8 to base64: {\"data\": \"Hello World\", \"from\": \"utf8\", \"to\": \"base64\"} → SGVsbG8gV29ybGQ=\n" +
|
|
22
|
+
"- base64 to UTF-8: {\"data\": \"SGVsbG8gV29ybGQ=\", \"from\": \"base64\", \"to\": \"utf8\"} → Hello World\n" +
|
|
23
|
+
"- hex to base64: {\"data\": \"68656c6c6f20776f726c64\", \"from\": \"hex\", \"to\": \"base64\"} → aGVsbG8gd29ybGQ=\n\n" +
|
|
24
|
+
"Notes:\n" +
|
|
25
|
+
"- All parameters are required\n" +
|
|
26
|
+
"- The tool returns the converted data as a string\n" +
|
|
27
|
+
"- For binary conversion, data is represented as an array of byte values",
|
|
15
28
|
{
|
|
16
29
|
args: z.object({
|
|
17
30
|
data: z.string().describe("The data string to be converted"),
|
package/tools/wallet/schemas.ts
CHANGED
|
@@ -76,14 +76,15 @@ export const walletDecryptArgsSchema = z.object({
|
|
|
76
76
|
export const walletEncryptionArgsSchema = z.object({
|
|
77
77
|
mode: z.enum(["encrypt", "decrypt"]).describe("Operation mode: 'encrypt' to encrypt data or 'decrypt' to decrypt data"),
|
|
78
78
|
data: z.array(z.number()).describe("Data to process: plaintext for encryption or ciphertext for decryption"),
|
|
79
|
-
protocolID: walletProtocolSchema,
|
|
80
|
-
keyID: z.string(),
|
|
81
|
-
privilegedReason: z.string().optional(),
|
|
79
|
+
protocolID: walletProtocolSchema.describe("Protocol identifier - common values are 'aes' for symmetric encryption or 'ecies' for asymmetric encryption"),
|
|
80
|
+
keyID: z.string().describe("Key identifier - use 'default' or 'primary' for the default wallet key"),
|
|
81
|
+
privilegedReason: z.string().optional().describe("Required reason for privileged operations"),
|
|
82
82
|
counterparty: z
|
|
83
83
|
.union([z.string(), z.literal("self"), z.literal("anyone")])
|
|
84
|
-
.optional()
|
|
85
|
-
|
|
86
|
-
|
|
84
|
+
.optional()
|
|
85
|
+
.describe("Recipient of encryption. Use 'self' for personal encryption, or provide a specific key for a recipient"),
|
|
86
|
+
privileged: z.boolean().optional().describe("Indicates if operation requires elevated privileges"),
|
|
87
|
+
}).describe("Combined schema for encryption and decryption operations. Use 'mode' to specify the operation type, with required parameters data, protocolID, and keyID.");
|
|
87
88
|
|
|
88
89
|
// Create HMAC arguments
|
|
89
90
|
export const createHmacArgsSchema = z.object({
|
package/tools/wallet/tools.ts
CHANGED
|
@@ -173,7 +173,29 @@ export function registerWalletTools(
|
|
|
173
173
|
// Register combined wallet_encryption tool
|
|
174
174
|
registerTool(
|
|
175
175
|
"wallet_encryption",
|
|
176
|
-
"Combined tool for encrypting and decrypting data using the wallet's cryptographic keys
|
|
176
|
+
"Combined tool for encrypting and decrypting data using the wallet's cryptographic keys.\n\n" +
|
|
177
|
+
"PARAMETERS:\n" +
|
|
178
|
+
"- mode: (required) Either \"encrypt\" to encrypt plaintext or \"decrypt\" to decrypt ciphertext\n" +
|
|
179
|
+
"- data: (required) Array of byte values to process (plaintext for encryption or ciphertext for decryption)\n" +
|
|
180
|
+
"- protocolID: (required) Protocol to use (commonly \"aes\" or \"ecies\")\n" +
|
|
181
|
+
"- keyID: (required) Key identifier (use \"default\" or \"primary\" for default wallet key)\n" +
|
|
182
|
+
"- counterparty: (optional) Set to \"self\" for personal encryption or specific key for recipient\n" +
|
|
183
|
+
"- privileged: (optional) Boolean indicating if operation requires elevated privileges\n\n" +
|
|
184
|
+
"EXAMPLES:\n" +
|
|
185
|
+
"1. Encrypt data:\n" +
|
|
186
|
+
" {\n" +
|
|
187
|
+
" \"mode\": \"encrypt\",\n" +
|
|
188
|
+
" \"data\": [84, 104, 105, 115, 32, 105, 115, 32, 116, 101, 115, 116],\n" +
|
|
189
|
+
" \"protocolID\": \"aes\",\n" +
|
|
190
|
+
" \"keyID\": \"default\"\n" +
|
|
191
|
+
" }\n\n" +
|
|
192
|
+
"2. Decrypt previously encrypted data:\n" +
|
|
193
|
+
" {\n" +
|
|
194
|
+
" \"mode\": \"decrypt\",\n" +
|
|
195
|
+
" \"data\": [encrypted bytes from previous response],\n" +
|
|
196
|
+
" \"protocolID\": \"aes\",\n" +
|
|
197
|
+
" \"keyID\": \"default\"\n" +
|
|
198
|
+
" }",
|
|
177
199
|
{ args: walletEncryptionArgsSchema },
|
|
178
200
|
async (
|
|
179
201
|
{ args }: { args: z.infer<typeof walletEncryptionArgsSchema> },
|