bsv-mcp 0.2.15 → 0.3.1
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/CHANGELOG.md +94 -10
- package/README.md +95 -13
- package/dist/app.html +483 -106
- package/dist/index.js +227724 -117380
- package/index.ts +523 -63
- package/package.json +24 -15
- package/prompts/bsvSdk/auth.ts +1 -1
- package/prompts/bsvSdk/cryptography.ts +1 -1
- package/prompts/bsvSdk/overview.ts +1 -1
- package/prompts/bsvSdk/primitives.ts +1 -1
- package/prompts/bsvSdk/script.ts +1 -1
- package/prompts/bsvSdk/transaction.ts +1 -1
- package/prompts/bsvSdk/wallet.ts +1 -1
- package/prompts/ordinals.ts +1 -1
- package/tools/a2b/discover.ts +2 -2
- package/tools/bap/friend.ts +17 -24
- package/tools/bap/generate.test.ts +34 -32
- package/tools/bap/generate.ts +48 -43
- package/tools/bap/getCurrentAddress.ts +1 -3
- package/tools/bap/getId.test.ts +18 -10
- package/tools/bap/getId.ts +8 -6
- package/tools/bap/utils.ts +1 -1
- package/tools/bsocial/bmapReadPosts.ts +16 -2
- package/tools/bsocial/createPost.ts +21 -10
- package/tools/bsocial/readPosts.ts +10 -4
- package/tools/bsv/decodeTransaction.ts +1 -1
- package/tools/bsv/explore.ts +0 -4
- package/tools/bsv/getPrice.ts +1 -1
- package/tools/bsv/token.ts +14 -6
- package/tools/constants.ts +6 -2
- package/tools/index.ts +22 -13
- package/tools/mnee/getBalance.ts +1 -1
- package/tools/mnee/parseTx.ts +1 -1
- package/tools/mnee/sendMnee.ts +30 -8
- package/tools/ordinals/getInscription.ts +1 -3
- package/tools/ordinals/getTokenByIdOrTicker.ts +1 -3
- package/tools/ordinals/index.ts +4 -1
- package/tools/ordinals/marketListings.ts +1 -1
- package/tools/ordinals/marketSales.ts +1 -1
- package/tools/ordinals/searchInscriptions.ts +1 -1
- package/tools/utils/aip.ts +31 -22
- package/tools/utils/installAgentMaster.ts +8 -9
- package/tools/utils/toolRegistration.ts +21 -22
- package/tools/utils/transactionBuilder.ts +21 -14
- package/tools/wallet/a2bPublishMcp.ts +15 -5
- package/tools/wallet/brc100.ts +567 -312
- package/tools/wallet/cancelListing.ts +29 -37
- package/tools/wallet/createOrdinals.ts +43 -27
- package/tools/wallet/droplit.ts +124 -0
- package/tools/wallet/fetchPaymentUtxos.ts +7 -5
- package/tools/wallet/gatherCollectionInfo.ts +3 -5
- package/tools/wallet/getAddress.ts +1 -4
- package/tools/wallet/getBalance.ts +15 -15
- package/tools/wallet/{getBalanceDroplet.ts → getBalanceDroplit.ts} +6 -6
- package/tools/wallet/getBsv21Balances.ts +20 -14
- package/tools/wallet/getLockData.ts +11 -11
- package/tools/wallet/getOrdinals.ts +26 -20
- package/tools/wallet/integratedWallet.ts +53 -53
- package/tools/wallet/listOrdinal.ts +40 -39
- package/tools/wallet/listTokens.ts +18 -17
- package/tools/wallet/lockBsv.ts +36 -22
- package/tools/wallet/mintCollection.ts +15 -10
- package/tools/wallet/opnsDeregister.ts +29 -39
- package/tools/wallet/opnsRegister.ts +29 -39
- package/tools/wallet/purchaseListing.test.ts +27 -0
- package/tools/wallet/purchaseListing.ts +59 -40
- package/tools/wallet/refreshUtxos.ts +1 -1
- package/tools/wallet/schemas.ts +0 -13
- package/tools/wallet/sendAllBsv.ts +26 -20
- package/tools/wallet/sendBsv.ts +107 -0
- package/tools/wallet/setupDroplit.ts +151 -0
- package/tools/wallet/signBsm.ts +18 -18
- package/tools/wallet/sweepBsv.ts +48 -27
- package/tools/wallet/sweepBsv21.ts +42 -28
- package/tools/wallet/sweepOrdinals.ts +38 -26
- package/tools/wallet/tools.ts +17 -17
- package/tools/wallet/transactionHelper.ts +13 -5
- package/tools/wallet/transferOrdToken.ts +72 -84
- package/tools/wallet/unlockBsv.ts +23 -17
- package/tools/wallet/utxo.ts +1 -0
- package/tools/wallet/wallet.ts +1 -13
- package/test-mcp-server.ts +0 -157
- package/tools/wallet/sendToAddress.ts +0 -74
- package/tools/wallet/setupDroplet.ts +0 -161
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* Common tool registration utilities for the BSV MCP server
|
|
3
3
|
*/
|
|
4
4
|
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
5
|
+
import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
|
|
5
6
|
import type { z } from "zod";
|
|
6
7
|
|
|
7
8
|
export interface ToolConfig<TArgs = Record<string, unknown>> {
|
|
@@ -11,13 +12,7 @@ export interface ToolConfig<TArgs = Record<string, unknown>> {
|
|
|
11
12
|
handler: (args: TArgs) => Promise<ToolResponse>;
|
|
12
13
|
}
|
|
13
14
|
|
|
14
|
-
export
|
|
15
|
-
content: Array<{
|
|
16
|
-
type: "text";
|
|
17
|
-
text: string;
|
|
18
|
-
}>;
|
|
19
|
-
isError?: boolean;
|
|
20
|
-
}
|
|
15
|
+
export type ToolResponse = CallToolResult;
|
|
21
16
|
|
|
22
17
|
/**
|
|
23
18
|
* Register a tool with standard error handling and response formatting
|
|
@@ -26,21 +21,25 @@ export function registerTool<TArgs = Record<string, unknown>>(
|
|
|
26
21
|
server: McpServer,
|
|
27
22
|
config: ToolConfig<TArgs>,
|
|
28
23
|
): void {
|
|
29
|
-
server.
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
24
|
+
server.registerTool(
|
|
25
|
+
config.name,
|
|
26
|
+
{ description: config.description, inputSchema: config.schema },
|
|
27
|
+
async (args) => {
|
|
28
|
+
try {
|
|
29
|
+
return await config.handler(args as TArgs);
|
|
30
|
+
} catch (error) {
|
|
31
|
+
return {
|
|
32
|
+
content: [
|
|
33
|
+
{
|
|
34
|
+
type: "text" as const,
|
|
35
|
+
text: `Error: ${error instanceof Error ? error.message : String(error)}`,
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
isError: true,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
);
|
|
44
43
|
}
|
|
45
44
|
|
|
46
45
|
/**
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
|
+
fromUtxo,
|
|
2
3
|
isBroadcastFailure,
|
|
3
4
|
isBroadcastResponse,
|
|
5
|
+
OP,
|
|
4
6
|
P2PKH,
|
|
5
7
|
type PrivateKey,
|
|
6
8
|
Script,
|
|
7
9
|
Transaction,
|
|
8
|
-
Utils,
|
|
9
10
|
} from "@bsv/sdk";
|
|
11
|
+
import type { Utxo } from "js-1sat-ord";
|
|
10
12
|
import { V5Broadcaster } from "../../utils/broadcaster";
|
|
11
|
-
import type { Utxo } from "../wallet/utxo";
|
|
12
13
|
|
|
13
14
|
const DEFAULT_SAT_PER_BYTE = 0.05;
|
|
14
15
|
const DUST_LIMIT = 546;
|
|
@@ -90,12 +91,18 @@ export async function buildAndSendTransaction(
|
|
|
90
91
|
selectedUtxos.push(utxo);
|
|
91
92
|
totalInputSatoshis += utxo.satoshis;
|
|
92
93
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
94
|
+
tx.addInput(
|
|
95
|
+
fromUtxo(
|
|
96
|
+
utxo,
|
|
97
|
+
p2pkh.unlock(
|
|
98
|
+
paymentKey,
|
|
99
|
+
"all",
|
|
100
|
+
false,
|
|
101
|
+
utxo.satoshis,
|
|
102
|
+
Script.fromHex(utxo.script),
|
|
103
|
+
),
|
|
104
|
+
),
|
|
105
|
+
);
|
|
99
106
|
|
|
100
107
|
// Estimate fee with current inputs
|
|
101
108
|
const estimatedSize = tx.toHex().length / 2 + 150; // rough estimate for unsigned tx
|
|
@@ -187,10 +194,10 @@ export async function buildAndSendTransaction(
|
|
|
187
194
|
/**
|
|
188
195
|
* Build OP_RETURN script from data arrays
|
|
189
196
|
*/
|
|
190
|
-
export function buildOpReturnScript(dataArrays:
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
197
|
+
export function buildOpReturnScript(dataArrays: number[][]): Script {
|
|
198
|
+
const script = new Script([{ op: OP.OP_FALSE }, { op: OP.OP_RETURN }]);
|
|
199
|
+
for (const data of dataArrays) {
|
|
200
|
+
script.writeBin(data);
|
|
201
|
+
}
|
|
202
|
+
return script;
|
|
196
203
|
}
|
|
@@ -35,7 +35,10 @@ export const McpConfigSchema = z.object({
|
|
|
35
35
|
tools: z.array(z.string()).optional().describe("Available tool names"),
|
|
36
36
|
prompts: z.array(z.string()).optional().describe("Available prompt names"),
|
|
37
37
|
resources: z.array(z.string()).optional().describe("Available resource URIs"),
|
|
38
|
-
env: z
|
|
38
|
+
env: z
|
|
39
|
+
.record(z.string(), z.string())
|
|
40
|
+
.optional()
|
|
41
|
+
.describe("Environment variables"),
|
|
39
42
|
});
|
|
40
43
|
|
|
41
44
|
export type McpConfig = z.infer<typeof McpConfigSchema>;
|
|
@@ -89,7 +92,7 @@ async function callIngestEndpoint(txid: string): Promise<boolean> {
|
|
|
89
92
|
return false;
|
|
90
93
|
}
|
|
91
94
|
|
|
92
|
-
const
|
|
95
|
+
const _result = await response.json();
|
|
93
96
|
// console.log('Ingest result:', result);
|
|
94
97
|
return true;
|
|
95
98
|
} catch (error) {
|
|
@@ -195,7 +198,15 @@ export function registerA2bPublishMcpTool(
|
|
|
195
198
|
"wallet_a2bPublishMcp",
|
|
196
199
|
"Publish an MCP tool configuration record on-chain via Ordinal inscription. This creates a permanent, immutable, and discoverable tool definition that can be accessed by other MCP servers. The tool is published as a JSON inscription with metadata and optional digital signatures for authenticity verification.",
|
|
197
200
|
{ ...a2bPublishMcpArgsSchema.shape },
|
|
198
|
-
async ({
|
|
201
|
+
async ({
|
|
202
|
+
toolName,
|
|
203
|
+
command,
|
|
204
|
+
args,
|
|
205
|
+
keywords,
|
|
206
|
+
env,
|
|
207
|
+
description,
|
|
208
|
+
destinationAddress,
|
|
209
|
+
}) => {
|
|
199
210
|
try {
|
|
200
211
|
if (!identityPk) {
|
|
201
212
|
console.warn(
|
|
@@ -334,8 +345,7 @@ export function registerA2bPublishMcpTool(
|
|
|
334
345
|
toolCount: metadata.tools.length,
|
|
335
346
|
promptCount: metadata.prompts.length,
|
|
336
347
|
resourceCount: metadata.resources.length,
|
|
337
|
-
description:
|
|
338
|
-
description || `MCP Tool: ${toolName}`,
|
|
348
|
+
description: description || `MCP Tool: ${toolName}`,
|
|
339
349
|
address: targetAddress,
|
|
340
350
|
},
|
|
341
351
|
null,
|