bsv-mcp 0.0.12 → 0.0.14
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
|
@@ -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.14",
|
|
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/getPrice.ts
CHANGED
|
@@ -14,11 +14,9 @@ let cachedPrice: { value: number; timestamp: number } | null = null;
|
|
|
14
14
|
async function getBsvPriceWithCache(): Promise<number> {
|
|
15
15
|
// Return cached price if it's still valid
|
|
16
16
|
if (cachedPrice && (Date.now() - cachedPrice.timestamp) < PRICE_CACHE_DURATION) {
|
|
17
|
-
console.log("Using cached BSV price");
|
|
18
17
|
return cachedPrice.value;
|
|
19
18
|
}
|
|
20
19
|
|
|
21
|
-
console.log("Fetching fresh BSV price");
|
|
22
20
|
// If no valid cache, fetch new price
|
|
23
21
|
const res = await fetch(
|
|
24
22
|
"https://api.whatsonchain.com/v1/bsv/main/exchangerate",
|
package/tools/index.ts
CHANGED
|
File without changes
|
|
@@ -166,7 +166,6 @@ export function registerMarketListingsTool(server: McpServer): void {
|
|
|
166
166
|
if (address) url.searchParams.append("address", address);
|
|
167
167
|
|
|
168
168
|
// Make the fetch request
|
|
169
|
-
console.log(`Fetching market listings from: ${url.toString()}`);
|
|
170
169
|
const response = await fetch(url.toString());
|
|
171
170
|
|
|
172
171
|
if (!response.ok) {
|
|
@@ -110,7 +110,6 @@ export function registerMarketSalesTool(server: McpServer): void {
|
|
|
110
110
|
if (address) url.searchParams.append("address", address);
|
|
111
111
|
|
|
112
112
|
// Fetch market sales from GorillaPool API
|
|
113
|
-
console.log(`Fetching market sales from: ${url.toString()}`);
|
|
114
113
|
const response = await fetch(url.toString());
|
|
115
114
|
|
|
116
115
|
if (!response.ok) {
|
|
@@ -75,7 +75,6 @@ interface OrdUtxo {
|
|
|
75
75
|
*/
|
|
76
76
|
export function registerPurchaseListingTool(server: McpServer, wallet: Wallet) {
|
|
77
77
|
// Store a reference to check if wallet is persistent
|
|
78
|
-
console.log("Registering purchaseListing tool with wallet:", wallet);
|
|
79
78
|
|
|
80
79
|
server.tool(
|
|
81
80
|
"wallet_purchaseListing",
|
|
@@ -86,11 +85,6 @@ export function registerPurchaseListingTool(server: McpServer, wallet: Wallet) {
|
|
|
86
85
|
extra: RequestHandlerExtra,
|
|
87
86
|
): Promise<CallToolResult> => {
|
|
88
87
|
try {
|
|
89
|
-
console.log(`Attempting to purchase listing: ${args.listingOutpoint}`);
|
|
90
|
-
console.log(`Listing type: ${args.listingType}`);
|
|
91
|
-
console.log("Using wallet instance:", wallet);
|
|
92
|
-
console.log("Wallet has UTXOs:", await wallet.getUtxos());
|
|
93
|
-
|
|
94
88
|
// Fetch the listing info directly from the API
|
|
95
89
|
const response = await fetch(
|
|
96
90
|
`https://ordinals.gorillapool.io/api/txos/${args.listingOutpoint}?script=true`,
|
|
@@ -122,11 +116,6 @@ export function registerPurchaseListingTool(server: McpServer, wallet: Wallet) {
|
|
|
122
116
|
marketFee = MINIMUM_MARKET_FEE_SATOSHIS;
|
|
123
117
|
}
|
|
124
118
|
|
|
125
|
-
console.log(`Listing price: ${listingPrice} satoshis`);
|
|
126
|
-
console.log(
|
|
127
|
-
`Market fee: ${marketFee} satoshis (${MARKET_FEE_PERCENTAGE * 100}%)`,
|
|
128
|
-
);
|
|
129
|
-
|
|
130
119
|
// Parse the listing outpoint to get txid and vout
|
|
131
120
|
const [txid, voutStr] = args.listingOutpoint.split("_");
|
|
132
121
|
if (!txid) {
|
|
@@ -142,7 +131,6 @@ export function registerPurchaseListingTool(server: McpServer, wallet: Wallet) {
|
|
|
142
131
|
|
|
143
132
|
// Get payment address
|
|
144
133
|
const paymentAddress = paymentPk.toAddress().toString();
|
|
145
|
-
console.log(`Using payment address: ${paymentAddress}`);
|
|
146
134
|
|
|
147
135
|
// Get payment UTXOs from the wallet's managed UTXOs
|
|
148
136
|
const { paymentUtxos } = await wallet.getUtxos();
|
|
@@ -242,7 +230,7 @@ Please fund this wallet address with enough BSV to cover the purchase price
|
|
|
242
230
|
try {
|
|
243
231
|
royalties = JSON.parse(listingData.origin.data.map.royalties);
|
|
244
232
|
} catch (error) {
|
|
245
|
-
console.warn
|
|
233
|
+
// Remove console.warn
|
|
246
234
|
}
|
|
247
235
|
}
|
|
248
236
|
|
|
@@ -262,10 +250,7 @@ Please fund this wallet address with enough BSV to cover the purchase price
|
|
|
262
250
|
try {
|
|
263
251
|
await wallet.refreshUtxos();
|
|
264
252
|
} catch (refreshError) {
|
|
265
|
-
console.warn
|
|
266
|
-
"Failed to refresh UTXOs after transaction:",
|
|
267
|
-
refreshError,
|
|
268
|
-
);
|
|
253
|
+
// Remove console.warn
|
|
269
254
|
}
|
|
270
255
|
|
|
271
256
|
// Broadcast the transaction
|
package/tools/wallet/wallet.ts
CHANGED
|
@@ -87,15 +87,13 @@ export class Wallet extends ProtoWallet implements WalletInterface {
|
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
const address = privateKey.toAddress();
|
|
90
|
-
|
|
91
|
-
|
|
90
|
+
|
|
92
91
|
const utxos = await fetchPayUtxos(address);
|
|
93
92
|
const nftUtxos = await fetchNftUtxos(address);
|
|
94
93
|
this.paymentUtxos = utxos;
|
|
95
94
|
this.nftUtxos = nftUtxos;
|
|
96
95
|
this.lastUtxoFetch = Date.now();
|
|
97
96
|
|
|
98
|
-
// console.log(`Fetched ${utxos.length} UTXOs for address ${address}`);
|
|
99
97
|
} catch (error) {
|
|
100
98
|
console.error("Error refreshing UTXOs:", error);
|
|
101
99
|
throw error;
|
|
@@ -172,8 +170,6 @@ export class Wallet extends ProtoWallet implements WalletInterface {
|
|
|
172
170
|
// return Promise.reject(new Error("Not implemented"));
|
|
173
171
|
// }
|
|
174
172
|
async createAction(args: CreateActionArgs): Promise<CreateActionResult> {
|
|
175
|
-
console.log("createAction called with", args);
|
|
176
|
-
|
|
177
173
|
const tx = new Transaction();
|
|
178
174
|
|
|
179
175
|
// Add outputs
|