bsv-mcp 0.0.13 → 0.0.15
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 +2 -0
- package/index.ts +1 -6
- package/package.json +1 -1
- package/tools/bsv/explore.ts +8 -3
- package/tools/wallet/schemas.ts +7 -6
- package/tools/wallet/tools.ts +23 -1
- package/tools/wallet/wallet.ts +0 -1
package/README.md
CHANGED
|
@@ -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
|
@@ -34,11 +34,10 @@ function validatePrivateKey(): PrivateKey {
|
|
|
34
34
|
|
|
35
35
|
// Validate private key early before starting the server
|
|
36
36
|
const privKey = validatePrivateKey();
|
|
37
|
-
console.log("\x1b[32mPrivate key validated successfully\x1b[0m");
|
|
38
37
|
|
|
39
38
|
const server = new McpServer({
|
|
40
39
|
name: "Bitcoin SV MCP Server",
|
|
41
|
-
version: "0.0.
|
|
40
|
+
version: "0.0.15",
|
|
42
41
|
});
|
|
43
42
|
|
|
44
43
|
// Initialize wallet with the validated private key
|
|
@@ -50,10 +49,6 @@ registerWalletTools(server, wallet);
|
|
|
50
49
|
// Register all other tools (BSV, Ordinals, Utils, etc.)
|
|
51
50
|
registerAllTools(server);
|
|
52
51
|
|
|
53
|
-
// Debug: Log all registered tools
|
|
54
|
-
console.log("Registered tools:", Object.keys(server));
|
|
55
|
-
console.log("MCP Server ready 🚀");
|
|
56
|
-
|
|
57
52
|
// Connect to the transport
|
|
58
53
|
const transport = new StdioServerTransport();
|
|
59
54
|
await server.connect(transport);
|
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/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> },
|
package/tools/wallet/wallet.ts
CHANGED
|
@@ -94,7 +94,6 @@ export class Wallet extends ProtoWallet implements WalletInterface {
|
|
|
94
94
|
this.nftUtxos = nftUtxos;
|
|
95
95
|
this.lastUtxoFetch = Date.now();
|
|
96
96
|
|
|
97
|
-
// console.log(`Fetched ${utxos.length} UTXOs for address ${address}`);
|
|
98
97
|
} catch (error) {
|
|
99
98
|
console.error("Error refreshing UTXOs:", error);
|
|
100
99
|
throw error;
|