bsv-mcp 0.2.9 → 0.2.11
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 +19 -0
- package/README.md +26 -2
- package/dist/index.js +6777 -126216
- package/index.ts +287 -265
- package/package.json +4 -3
- package/tools/bap/generate.test.ts +17 -16
- package/tools/index.ts +8 -3
- package/tools/ordinals/getInscription.ts +15 -65
- package/tools/ordinals/getTokenByIdOrTicker.ts +14 -80
- package/tools/ordinals/index.ts +8 -7
- package/tools/ordinals/marketListings.ts +21 -188
- package/tools/ordinals/marketSales.ts +21 -127
- package/tools/ordinals/searchInscriptions.ts +21 -108
- package/tools/wallet/brc100.ts +572 -0
- package/tools/wallet/cancelListing.ts +80 -0
- package/tools/wallet/createOrdinals.ts +62 -143
- package/tools/wallet/getAddress.ts +19 -13
- package/tools/wallet/getBalance.ts +29 -25
- package/tools/wallet/getBsv21Balances.ts +28 -0
- package/tools/wallet/getLockData.ts +25 -0
- package/tools/wallet/getOrdinals.ts +35 -0
- package/tools/wallet/listOrdinal.ts +86 -0
- package/tools/wallet/listTokens.ts +28 -0
- package/tools/wallet/lockBsv.ts +69 -0
- package/tools/wallet/opnsDeregister.ts +80 -0
- package/tools/wallet/opnsRegister.ts +80 -0
- package/tools/wallet/purchaseListing.ts +89 -290
- package/tools/wallet/refreshUtxos.ts +21 -32
- package/tools/wallet/schemas.ts +7 -11
- package/tools/wallet/sendAllBsv.ts +64 -0
- package/tools/wallet/sendToAddress.ts +46 -47
- package/tools/wallet/signBsm.ts +29 -0
- package/tools/wallet/sweepBsv.ts +70 -0
- package/tools/wallet/sweepBsv21.ts +71 -0
- package/tools/wallet/sweepOrdinals.ts +69 -0
- package/tools/wallet/tools.ts +50 -88
- package/tools/wallet/transferOrdToken.ts +137 -129
- package/tools/wallet/unlockBsv.ts +57 -0
- package/tools/wallet/a2bPublishAgent.ts +0 -307
- package/tools/wallet/sendOrdinals.ts +0 -160
|
@@ -1,136 +1,30 @@
|
|
|
1
|
+
import type { OneSatContext } from "@1sat/actions";
|
|
1
2
|
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
-
import type { RequestHandlerExtra } from "@modelcontextprotocol/sdk/shared/protocol.js";
|
|
3
|
-
import { z } from "zod";
|
|
4
|
-
|
|
5
|
-
// Schema for unified market sales arguments
|
|
6
|
-
export const marketSalesArgsSchema = z.object({
|
|
7
|
-
// Common parameters
|
|
8
|
-
limit: z
|
|
9
|
-
.number()
|
|
10
|
-
.int()
|
|
11
|
-
.min(1)
|
|
12
|
-
.max(100)
|
|
13
|
-
.default(20)
|
|
14
|
-
.describe("Number of results (1-100, default 20)"),
|
|
15
|
-
offset: z.number().int().min(0).default(0).describe("Pagination offset"),
|
|
16
|
-
dir: z
|
|
17
|
-
.enum(["asc", "desc"])
|
|
18
|
-
.default("desc")
|
|
19
|
-
.describe("Sort direction (asc or desc)"),
|
|
20
|
-
address: z.string().optional().describe("Bitcoin address"),
|
|
21
|
-
|
|
22
|
-
// Token-specific parameters
|
|
23
|
-
tokenType: z
|
|
24
|
-
.enum(["bsv20", "bsv21", "all"])
|
|
25
|
-
.default("bsv20")
|
|
26
|
-
.describe("Type of token to search for (bsv20, bsv21, or all)"),
|
|
27
|
-
id: z.string().optional().describe("Token ID in outpoint format"),
|
|
28
|
-
tick: z.string().optional().describe("Token ticker symbol"),
|
|
29
|
-
pending: z
|
|
30
|
-
.boolean()
|
|
31
|
-
.default(false)
|
|
32
|
-
.optional()
|
|
33
|
-
.describe("Include pending sales"),
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
export type MarketSalesArgs = z.infer<typeof marketSalesArgsSchema>;
|
|
37
|
-
|
|
38
|
-
// Unified response type for token sales
|
|
39
|
-
interface MarketSaleResponse {
|
|
40
|
-
results: Array<{
|
|
41
|
-
outpoint: string;
|
|
42
|
-
data?: {
|
|
43
|
-
bsv20?: {
|
|
44
|
-
id?: string;
|
|
45
|
-
tick?: string;
|
|
46
|
-
sym?: string;
|
|
47
|
-
amt?: string;
|
|
48
|
-
op?: string;
|
|
49
|
-
};
|
|
50
|
-
list?: {
|
|
51
|
-
price?: number;
|
|
52
|
-
payout?: string;
|
|
53
|
-
sale?: boolean;
|
|
54
|
-
};
|
|
55
|
-
};
|
|
56
|
-
satoshis?: number;
|
|
57
|
-
height?: number;
|
|
58
|
-
owner?: string;
|
|
59
|
-
spend?: string;
|
|
60
|
-
spendHeight?: number;
|
|
61
|
-
spendIdx?: string;
|
|
62
|
-
[key: string]: unknown;
|
|
63
|
-
}>;
|
|
64
|
-
total: number;
|
|
65
|
-
}
|
|
66
3
|
|
|
67
4
|
/**
|
|
68
|
-
* Register the
|
|
69
|
-
* Handles BSV20 and BSV21 token sales
|
|
5
|
+
* Register the market sales tool (stub — awaiting 1sat-stack implementation)
|
|
70
6
|
*/
|
|
71
|
-
export function registerMarketSalesTool(
|
|
7
|
+
export function registerMarketSalesTool(
|
|
8
|
+
server: McpServer,
|
|
9
|
+
ctx?: OneSatContext,
|
|
10
|
+
): void {
|
|
72
11
|
server.tool(
|
|
73
12
|
"ordinals_marketSales",
|
|
74
|
-
"
|
|
75
|
-
{
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
url.searchParams.append("limit", limit.toString());
|
|
90
|
-
url.searchParams.append("offset", offset.toString());
|
|
91
|
-
url.searchParams.append("dir", dir);
|
|
92
|
-
|
|
93
|
-
// Add type parameter for bsv21 if needed
|
|
94
|
-
if (tokenType === "bsv21") {
|
|
95
|
-
url.searchParams.append("type", "v2");
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
if (id) url.searchParams.append("id", id);
|
|
99
|
-
if (tick) url.searchParams.append("tick", tick);
|
|
100
|
-
if (pending !== undefined)
|
|
101
|
-
url.searchParams.append("pending", pending.toString());
|
|
102
|
-
if (address) url.searchParams.append("address", address);
|
|
103
|
-
|
|
104
|
-
// Fetch market sales from GorillaPool API
|
|
105
|
-
const response = await fetch(url.toString());
|
|
106
|
-
|
|
107
|
-
if (!response.ok) {
|
|
108
|
-
throw new Error(
|
|
109
|
-
`API error: ${response.status} ${response.statusText}`,
|
|
110
|
-
);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
const data = (await response.json()) as MarketSaleResponse;
|
|
114
|
-
|
|
115
|
-
return {
|
|
116
|
-
content: [
|
|
117
|
-
{
|
|
118
|
-
type: "text",
|
|
119
|
-
text: JSON.stringify(data, null, 2),
|
|
120
|
-
},
|
|
121
|
-
],
|
|
122
|
-
};
|
|
123
|
-
} catch (error) {
|
|
124
|
-
return {
|
|
125
|
-
content: [
|
|
126
|
-
{
|
|
127
|
-
type: "text",
|
|
128
|
-
text: error instanceof Error ? error.message : String(error),
|
|
129
|
-
},
|
|
130
|
-
],
|
|
131
|
-
isError: true,
|
|
132
|
-
};
|
|
133
|
-
}
|
|
13
|
+
"Query past marketplace sales for ordinals and tokens. Currently awaiting 1sat-stack marketplace API implementation.",
|
|
14
|
+
{},
|
|
15
|
+
async () => {
|
|
16
|
+
return {
|
|
17
|
+
content: [
|
|
18
|
+
{
|
|
19
|
+
type: "text",
|
|
20
|
+
text: JSON.stringify({
|
|
21
|
+
error: "Marketplace sales API not yet available on 1sat-stack",
|
|
22
|
+
status: "not_implemented",
|
|
23
|
+
}),
|
|
24
|
+
},
|
|
25
|
+
],
|
|
26
|
+
isError: true,
|
|
27
|
+
};
|
|
134
28
|
},
|
|
135
29
|
);
|
|
136
30
|
}
|
|
@@ -1,117 +1,30 @@
|
|
|
1
|
+
import type { OneSatContext } from "@1sat/actions";
|
|
1
2
|
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
-
import type { RequestHandlerExtra } from "@modelcontextprotocol/sdk/shared/protocol.js";
|
|
3
|
-
import { z } from "zod";
|
|
4
|
-
|
|
5
|
-
// Schema for search inscriptions arguments
|
|
6
|
-
export const searchInscriptionsArgsSchema = z.object({
|
|
7
|
-
limit: z
|
|
8
|
-
.number()
|
|
9
|
-
.int()
|
|
10
|
-
.min(1)
|
|
11
|
-
.max(100)
|
|
12
|
-
.default(20)
|
|
13
|
-
.describe("Number of results (1-100, default 20)"),
|
|
14
|
-
offset: z.number().int().min(0).default(0).describe("Pagination offset"),
|
|
15
|
-
dir: z
|
|
16
|
-
.enum(["asc", "desc"])
|
|
17
|
-
.default("desc")
|
|
18
|
-
.describe("Sort direction (asc or desc)"),
|
|
19
|
-
num: z.string().optional().describe("Inscription number"),
|
|
20
|
-
origin: z.string().optional().describe("Origin outpoint"),
|
|
21
|
-
address: z.string().optional().describe("Bitcoin address"),
|
|
22
|
-
map: z.string().optional().describe("Map field"),
|
|
23
|
-
terms: z.string().optional().describe("Search terms"),
|
|
24
|
-
mime: z.string().optional().describe("MIME type filter"),
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
export type SearchInscriptionsArgs = z.infer<
|
|
28
|
-
typeof searchInscriptionsArgsSchema
|
|
29
|
-
>;
|
|
30
|
-
|
|
31
|
-
// Simplified inscription response type
|
|
32
|
-
interface InscriptionSearchResponse {
|
|
33
|
-
results: Array<{
|
|
34
|
-
outpoint: string;
|
|
35
|
-
origin: {
|
|
36
|
-
outpoint: string;
|
|
37
|
-
data?: {
|
|
38
|
-
insc?: {
|
|
39
|
-
text?: string;
|
|
40
|
-
file?: {
|
|
41
|
-
type?: string;
|
|
42
|
-
size?: number;
|
|
43
|
-
};
|
|
44
|
-
};
|
|
45
|
-
};
|
|
46
|
-
};
|
|
47
|
-
height?: number;
|
|
48
|
-
satoshis?: number;
|
|
49
|
-
[key: string]: unknown;
|
|
50
|
-
}>;
|
|
51
|
-
total: number;
|
|
52
|
-
}
|
|
53
3
|
|
|
54
4
|
/**
|
|
55
|
-
* Register the
|
|
5
|
+
* Register the inscription search tool (stub — awaiting 1sat-stack implementation)
|
|
56
6
|
*/
|
|
57
|
-
export function registerSearchInscriptionsTool(
|
|
7
|
+
export function registerSearchInscriptionsTool(
|
|
8
|
+
server: McpServer,
|
|
9
|
+
ctx?: OneSatContext,
|
|
10
|
+
): void {
|
|
58
11
|
server.tool(
|
|
59
12
|
"ordinals_searchInscriptions",
|
|
60
|
-
"
|
|
61
|
-
{
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
url.searchParams.append("offset", offset.toString());
|
|
76
|
-
url.searchParams.append("dir", dir);
|
|
77
|
-
|
|
78
|
-
if (num) url.searchParams.append("num", num);
|
|
79
|
-
if (origin) url.searchParams.append("origin", origin);
|
|
80
|
-
if (address) url.searchParams.append("address", address);
|
|
81
|
-
if (map) url.searchParams.append("map", map);
|
|
82
|
-
if (terms) url.searchParams.append("terms", terms);
|
|
83
|
-
if (mime) url.searchParams.append("mime", mime);
|
|
84
|
-
|
|
85
|
-
// Fetch inscriptions data from GorillaPool API
|
|
86
|
-
const response = await fetch(url.toString());
|
|
87
|
-
|
|
88
|
-
if (!response.ok) {
|
|
89
|
-
throw new Error(
|
|
90
|
-
`API error: ${response.status} ${response.statusText}`,
|
|
91
|
-
);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
const data = (await response.json()) as InscriptionSearchResponse;
|
|
95
|
-
|
|
96
|
-
return {
|
|
97
|
-
content: [
|
|
98
|
-
{
|
|
99
|
-
type: "text",
|
|
100
|
-
text: JSON.stringify(data, null, 2),
|
|
101
|
-
},
|
|
102
|
-
],
|
|
103
|
-
};
|
|
104
|
-
} catch (error) {
|
|
105
|
-
return {
|
|
106
|
-
content: [
|
|
107
|
-
{
|
|
108
|
-
type: "text",
|
|
109
|
-
text: error instanceof Error ? error.message : String(error),
|
|
110
|
-
},
|
|
111
|
-
],
|
|
112
|
-
isError: true,
|
|
113
|
-
};
|
|
114
|
-
}
|
|
13
|
+
"Search for inscriptions by various criteria. Currently awaiting 1sat-stack search API implementation.",
|
|
14
|
+
{},
|
|
15
|
+
async () => {
|
|
16
|
+
return {
|
|
17
|
+
content: [
|
|
18
|
+
{
|
|
19
|
+
type: "text",
|
|
20
|
+
text: JSON.stringify({
|
|
21
|
+
error: "Inscription search API not yet available on 1sat-stack",
|
|
22
|
+
status: "not_implemented",
|
|
23
|
+
}),
|
|
24
|
+
},
|
|
25
|
+
],
|
|
26
|
+
isError: true,
|
|
27
|
+
};
|
|
115
28
|
},
|
|
116
29
|
);
|
|
117
30
|
}
|