bsv-mcp 0.0.3 → 0.0.5

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/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.3",
5
+ "version": "0.0.5",
6
6
  "bin": {
7
7
  "bsv-mcp": "./index.ts"
8
8
  },
@@ -37,11 +37,6 @@ export const marketListingsArgsSchema = z.object({
37
37
  .enum(["recent", "price", "num", "height", "price_per_token"])
38
38
  .default("recent")
39
39
  .describe("Sort method (recent, price, num, height, price_per_token)"),
40
- bsv20Type: z
41
- .enum(["v1", "v2", "all"])
42
- .default("all")
43
- .optional()
44
- .describe("BSV20 token type (v1, v2, or all)"),
45
40
  id: z.string().optional().describe("Token ID in outpoint format"),
46
41
  tick: z.string().optional().describe("Token ticker symbol"),
47
42
  pending: z.boolean().default(false).optional().describe("Include pending sales"),
@@ -114,7 +109,6 @@ export function registerMarketListingsTool(server: McpServer): void {
114
109
  minPrice,
115
110
  maxPrice,
116
111
  tokenType,
117
- bsv20Type,
118
112
  id,
119
113
  tick,
120
114
  pending,
@@ -124,12 +118,9 @@ export function registerMarketListingsTool(server: McpServer): void {
124
118
  let baseUrl = "https://ordinals.gorillapool.io/api";
125
119
  let useTokenParams = false;
126
120
 
127
- if (tokenType === "bsv20") {
121
+ if (tokenType === "bsv20" || tokenType === "bsv21") {
128
122
  baseUrl += "/bsv20/market";
129
123
  useTokenParams = true;
130
- } else if (tokenType === "bsv21") {
131
- baseUrl += "/bsv21/market"; // Assuming BSV21 endpoint follows similar pattern
132
- useTokenParams = true;
133
124
  } else if (tokenType === "nft" || tokenType === "all") {
134
125
  baseUrl += "/market";
135
126
  }
@@ -147,8 +138,8 @@ export function registerMarketListingsTool(server: McpServer): void {
147
138
  url.searchParams.append("sort", sort);
148
139
  }
149
140
  // Add token-specific parameters
150
- if (bsv20Type && bsv20Type !== "all") {
151
- url.searchParams.append("type", bsv20Type);
141
+ if (tokenType === "bsv21") {
142
+ url.searchParams.append("type", "v2");
152
143
  }
153
144
  if (id) url.searchParams.append("id", id);
154
145
  if (tick) url.searchParams.append("tick", tick);
@@ -24,11 +24,6 @@ export const marketSalesArgsSchema = z.object({
24
24
  .enum(["bsv20", "bsv21", "all"])
25
25
  .default("bsv20")
26
26
  .describe("Type of token to search for (bsv20, bsv21, or all)"),
27
- bsv20Type: z
28
- .enum(["v1", "v2", "all"])
29
- .default("all")
30
- .optional()
31
- .describe("BSV20 token type (v1, v2, or all)"),
32
27
  id: z.string().optional().describe("Token ID in outpoint format"),
33
28
  tick: z.string().optional().describe("Token ticker symbol"),
34
29
  pending: z.boolean().default(false).optional().describe("Include pending sales"),
@@ -85,7 +80,6 @@ export function registerMarketSalesTool(server: McpServer): void {
85
80
  offset,
86
81
  dir,
87
82
  tokenType,
88
- bsv20Type,
89
83
  id,
90
84
  tick,
91
85
  pending,
@@ -94,13 +88,9 @@ export function registerMarketSalesTool(server: McpServer): void {
94
88
 
95
89
  // Determine the API endpoint based on tokenType
96
90
  let baseUrl = "https://ordinals.gorillapool.io/api";
97
-
98
- if (tokenType === "bsv21") {
99
- baseUrl += "/bsv21/market/sales";
100
- } else {
101
- // Default to BSV20 for "bsv20" or "all"
102
- baseUrl += "/bsv20/market/sales";
103
- }
91
+
92
+ // Default to BSV20 for all token types
93
+ baseUrl += "/bsv20/market/sales";
104
94
 
105
95
  // Build the URL with query parameters
106
96
  const url = new URL(baseUrl);
@@ -108,9 +98,9 @@ export function registerMarketSalesTool(server: McpServer): void {
108
98
  url.searchParams.append("offset", offset.toString());
109
99
  url.searchParams.append("dir", dir);
110
100
 
111
- // Add type parameter for bsv20 only if specified
112
- if (bsv20Type && bsv20Type !== "all") {
113
- url.searchParams.append("type", bsv20Type);
101
+ // Add type parameter for bsv21 if needed
102
+ if (tokenType === "bsv21") {
103
+ url.searchParams.append("type", "v2");
114
104
  }
115
105
 
116
106
  if (id) url.searchParams.append("id", id);
@@ -6,6 +6,7 @@ import {
6
6
  type ChangeResult,
7
7
  type ExistingListing,
8
8
  type Payment,
9
+ type Royalty,
9
10
  type TokenUtxo,
10
11
  type Utxo,
11
12
  TokenType,
@@ -23,11 +24,27 @@ import { purchaseListingArgsSchema } from "./schemas";
23
24
  import type { Wallet } from "./wallet";
24
25
 
25
26
  // Define types for 1Sat API response
26
- interface ListingResponse {
27
+ interface OrdUtxo {
27
28
  txid: string;
28
29
  vout: number;
29
30
  satoshis: number;
30
31
  script: string;
32
+ origin?: {
33
+ outpoint: string;
34
+ data?: {
35
+ map?: {
36
+ royalties?: string;
37
+ [key: string]: string | number | boolean | null | undefined;
38
+ };
39
+ insc?: {
40
+ text?: string;
41
+ file?: {
42
+ type?: string;
43
+ size?: number;
44
+ };
45
+ };
46
+ };
47
+ };
31
48
  data?: {
32
49
  list?: {
33
50
  price: number;
@@ -79,7 +96,7 @@ export function registerPurchaseListingTool(server: McpServer, wallet: Wallet) {
79
96
  );
80
97
  }
81
98
 
82
- const listingData = (await response.json()) as ListingResponse;
99
+ const listingData = (await response.json()) as OrdUtxo;
83
100
 
84
101
  // Check if the listing is valid and has a price
85
102
  if (!listingData.data?.list?.price) {
@@ -183,6 +200,7 @@ Please fund this wallet address with enough BSV to cover the purchase price
183
200
  satoshis: 1, // TokenUtxo's satoshis must be exactly 1
184
201
  amt: listingData.data.bsv20.amt,
185
202
  id: args.tokenID,
203
+ payout: listingData.data.list.payout,
186
204
  };
187
205
 
188
206
  transaction = await purchaseOrdTokenListing({
@@ -210,6 +228,16 @@ Please fund this wallet address with enough BSV to cover the purchase price
210
228
  listingUtxo,
211
229
  };
212
230
 
231
+ // Check for royalties in the NFT origin data
232
+ let royalties: Royalty[] = [];
233
+ if (listingData.origin?.data?.map?.royalties) {
234
+ try {
235
+ royalties = JSON.parse(listingData.origin.data.map.royalties);
236
+ } catch (error) {
237
+ console.warn("Failed to parse royalties:", error);
238
+ }
239
+ }
240
+
213
241
  transaction = await purchaseOrdListing({
214
242
  utxos: paymentUtxos,
215
243
  paymentPk,
@@ -217,6 +245,7 @@ Please fund this wallet address with enough BSV to cover the purchase price
217
245
  listing,
218
246
  additionalPayments,
219
247
  metaData,
248
+ royalties,
220
249
  });
221
250
  }
222
251
 
@@ -263,6 +292,8 @@ Please fund this wallet address with enough BSV to cover the purchase price
263
292
  price: listingData.data.list.price,
264
293
  marketFee,
265
294
  marketFeeAddress: MARKET_WALLET_ADDRESS,
295
+ royaltiesPaid: args.listingType === "nft" && listingData.origin?.data?.map?.royalties ?
296
+ JSON.parse(listingData.origin.data.map.royalties) : undefined,
266
297
  }),
267
298
  },
268
299
  ],
@@ -261,7 +261,7 @@ export const getAddressArgsSchema = z.object({});
261
261
  export const sendToAddressArgsSchema = z.object({
262
262
  address: z.string(),
263
263
  amount: z.number(),
264
- currency: z.enum(["BSV", "USD"]).optional(),
264
+ currency: z.enum(["BSV", "USD"]).optional().default("BSV"),
265
265
  description: z.string().optional(),
266
266
  });
267
267
 
@@ -275,22 +275,24 @@ export const purchaseListingArgsSchema = z.object({
275
275
  ordAddress: z
276
276
  .string()
277
277
  .describe("The ordinal address to receive the purchased item"),
278
- description: z
279
- .string()
280
- .optional()
281
- .describe("Optional description for the transaction"),
282
278
  listingType: z
283
279
  .enum(["nft", "token"])
284
280
  .default("nft")
285
281
  .describe("Type of listing: 'nft' for ordinal NFTs, 'token' for BSV-20 tokens"),
286
282
  tokenProtocol: z
287
283
  .enum(["bsv-20", "bsv-21"])
288
- .optional()
284
+ .optional().default("bsv-21")
289
285
  .describe("Token protocol for token listings (required when listingType is 'token')"),
290
286
  tokenID: z
291
287
  .string()
292
288
  .optional()
293
289
  .describe("Token ID for BSV-21 tokens or ticker for BSV-20 tokens (required when listingType is 'token')"),
290
+ description: z
291
+ .string()
292
+ .optional()
293
+ .describe("Optional description for the transaction"),
294
294
  });
295
295
 
296
+ // Export types
297
+ export type SendToAddressArgs = z.infer<typeof sendToAddressArgsSchema>;
296
298
  export type PurchaseListingArgs = z.infer<typeof purchaseListingArgsSchema>;