@guiie/buda-mcp 1.4.2 → 1.5.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/.cursor/rules/marketplace-docs-sync.mdc +32 -0
- package/CHANGELOG.md +79 -0
- package/PUBLISH_CHECKLIST.md +40 -88
- package/README.md +446 -78
- package/dist/cache.d.ts +1 -0
- package/dist/cache.d.ts.map +1 -1
- package/dist/cache.js +1 -0
- package/dist/client.d.ts +2 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +18 -1
- package/dist/http.js +97 -6
- package/dist/index.js +42 -3
- package/dist/tools/account.d.ts +19 -0
- package/dist/tools/account.d.ts.map +1 -0
- package/dist/tools/account.js +49 -0
- package/dist/tools/balance.d.ts +29 -0
- package/dist/tools/balance.d.ts.map +1 -0
- package/dist/tools/balance.js +72 -0
- package/dist/tools/banks.d.ts +28 -0
- package/dist/tools/banks.d.ts.map +1 -0
- package/dist/tools/banks.js +68 -0
- package/dist/tools/batch_orders.d.ts +82 -0
- package/dist/tools/batch_orders.d.ts.map +1 -0
- package/dist/tools/batch_orders.js +188 -0
- package/dist/tools/cancel_all_orders.d.ts +34 -0
- package/dist/tools/cancel_all_orders.d.ts.map +1 -0
- package/dist/tools/cancel_all_orders.js +89 -0
- package/dist/tools/cancel_order.js +1 -1
- package/dist/tools/cancel_order_by_client_id.d.ts +34 -0
- package/dist/tools/cancel_order_by_client_id.d.ts.map +1 -0
- package/dist/tools/cancel_order_by_client_id.js +102 -0
- package/dist/tools/dead_mans_switch.d.ts +1 -1
- package/dist/tools/dead_mans_switch.d.ts.map +1 -1
- package/dist/tools/dead_mans_switch.js +33 -3
- package/dist/tools/deposits.d.ts +83 -0
- package/dist/tools/deposits.d.ts.map +1 -0
- package/dist/tools/deposits.js +174 -0
- package/dist/tools/fees.d.ts +34 -0
- package/dist/tools/fees.d.ts.map +1 -0
- package/dist/tools/fees.js +72 -0
- package/dist/tools/lightning.d.ts +68 -0
- package/dist/tools/lightning.d.ts.map +1 -0
- package/dist/tools/lightning.js +185 -0
- package/dist/tools/order_lookup.d.ts +50 -0
- package/dist/tools/order_lookup.d.ts.map +1 -0
- package/dist/tools/order_lookup.js +112 -0
- package/dist/tools/place_order.d.ts +30 -0
- package/dist/tools/place_order.d.ts.map +1 -1
- package/dist/tools/place_order.js +131 -2
- package/dist/tools/quotation.d.ts +44 -0
- package/dist/tools/quotation.d.ts.map +1 -0
- package/dist/tools/quotation.js +99 -0
- package/dist/tools/receive_addresses.d.ts +83 -0
- package/dist/tools/receive_addresses.d.ts.map +1 -0
- package/dist/tools/receive_addresses.js +185 -0
- package/dist/tools/remittance_recipients.d.ts +54 -0
- package/dist/tools/remittance_recipients.d.ts.map +1 -0
- package/dist/tools/remittance_recipients.js +106 -0
- package/dist/tools/remittances.d.ts +120 -0
- package/dist/tools/remittances.d.ts.map +1 -0
- package/dist/tools/remittances.js +261 -0
- package/dist/tools/simulate_order.d.ts.map +1 -1
- package/dist/tools/simulate_order.js +2 -1
- package/dist/tools/technical_indicators.d.ts.map +1 -1
- package/dist/tools/technical_indicators.js +2 -1
- package/dist/tools/withdrawals.d.ts +93 -0
- package/dist/tools/withdrawals.d.ts.map +1 -0
- package/dist/tools/withdrawals.js +225 -0
- package/dist/types.d.ts +155 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +4 -1
- package/dist/validation.d.ts +11 -0
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +38 -0
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +8 -1
- package/marketplace/README.md +1 -1
- package/marketplace/claude-listing.md +101 -2
- package/marketplace/gemini-tools.json +478 -1
- package/marketplace/openapi.yaml +160 -1
- package/package.json +2 -1
- package/server.json +2 -2
- package/src/cache.ts +1 -0
- package/src/client.ts +23 -1
- package/src/http.ts +105 -6
- package/src/index.ts +40 -3
- package/src/tools/account.ts +66 -0
- package/src/tools/balance.ts +94 -0
- package/src/tools/banks.ts +94 -0
- package/src/tools/batch_orders.ts +238 -0
- package/src/tools/cancel_all_orders.ts +117 -0
- package/src/tools/cancel_order.ts +1 -1
- package/src/tools/cancel_order_by_client_id.ts +132 -0
- package/src/tools/dead_mans_switch.ts +39 -3
- package/src/tools/deposits.ts +230 -0
- package/src/tools/fees.ts +91 -0
- package/src/tools/lightning.ts +247 -0
- package/src/tools/order_lookup.ts +139 -0
- package/src/tools/place_order.ts +151 -2
- package/src/tools/quotation.ts +124 -0
- package/src/tools/receive_addresses.ts +242 -0
- package/src/tools/remittance_recipients.ts +139 -0
- package/src/tools/remittances.ts +325 -0
- package/src/tools/simulate_order.ts +1 -0
- package/src/tools/technical_indicators.ts +2 -1
- package/src/tools/withdrawals.ts +287 -0
- package/src/types.ts +210 -0
- package/src/utils.ts +3 -1
- package/src/validation.ts +45 -0
- package/src/version.ts +11 -3
- package/test/run-all.ts +16 -0
- package/test/unit.ts +2149 -1
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import { BudaClient } from "../client.js";
|
|
3
|
+
export declare const getDepositHistoryToolSchema: {
|
|
4
|
+
name: string;
|
|
5
|
+
description: string;
|
|
6
|
+
inputSchema: {
|
|
7
|
+
type: "object";
|
|
8
|
+
properties: {
|
|
9
|
+
currency: {
|
|
10
|
+
type: string;
|
|
11
|
+
description: string;
|
|
12
|
+
};
|
|
13
|
+
state: {
|
|
14
|
+
type: string;
|
|
15
|
+
description: string;
|
|
16
|
+
};
|
|
17
|
+
per: {
|
|
18
|
+
type: string;
|
|
19
|
+
description: string;
|
|
20
|
+
};
|
|
21
|
+
page: {
|
|
22
|
+
type: string;
|
|
23
|
+
description: string;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
required: string[];
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
type GetDepositHistoryArgs = {
|
|
30
|
+
currency: string;
|
|
31
|
+
state?: "pending_info" | "pending" | "confirmed" | "anulled" | "retained";
|
|
32
|
+
per?: number;
|
|
33
|
+
page?: number;
|
|
34
|
+
};
|
|
35
|
+
export declare function handleGetDepositHistory(args: GetDepositHistoryArgs, client: BudaClient): Promise<{
|
|
36
|
+
content: Array<{
|
|
37
|
+
type: "text";
|
|
38
|
+
text: string;
|
|
39
|
+
}>;
|
|
40
|
+
isError?: boolean;
|
|
41
|
+
}>;
|
|
42
|
+
export declare const createFiatDepositToolSchema: {
|
|
43
|
+
name: string;
|
|
44
|
+
description: string;
|
|
45
|
+
inputSchema: {
|
|
46
|
+
type: "object";
|
|
47
|
+
properties: {
|
|
48
|
+
currency: {
|
|
49
|
+
type: string;
|
|
50
|
+
description: string;
|
|
51
|
+
};
|
|
52
|
+
amount: {
|
|
53
|
+
type: string;
|
|
54
|
+
description: string;
|
|
55
|
+
};
|
|
56
|
+
bank: {
|
|
57
|
+
type: string;
|
|
58
|
+
description: string;
|
|
59
|
+
};
|
|
60
|
+
confirmation_token: {
|
|
61
|
+
type: string;
|
|
62
|
+
description: string;
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
required: string[];
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
type CreateFiatDepositArgs = {
|
|
69
|
+
currency: string;
|
|
70
|
+
amount: number;
|
|
71
|
+
bank?: string;
|
|
72
|
+
confirmation_token: string;
|
|
73
|
+
};
|
|
74
|
+
export declare function handleCreateFiatDeposit(args: CreateFiatDepositArgs, client: BudaClient): Promise<{
|
|
75
|
+
content: Array<{
|
|
76
|
+
type: "text";
|
|
77
|
+
text: string;
|
|
78
|
+
}>;
|
|
79
|
+
isError?: boolean;
|
|
80
|
+
}>;
|
|
81
|
+
export declare function register(server: McpServer, client: BudaClient): void;
|
|
82
|
+
export {};
|
|
83
|
+
//# sourceMappingURL=deposits.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deposits.d.ts","sourceRoot":"","sources":["../../src/tools/deposits.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEpE,OAAO,EAAE,UAAU,EAAgB,MAAM,cAAc,CAAC;AAKxD,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;CA6BvC,CAAC;AAEF,KAAK,qBAAqB,GAAG;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,cAAc,GAAG,SAAS,GAAG,WAAW,GAAG,SAAS,GAAG,UAAU,CAAC;IAC1E,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAoBF,wBAAsB,uBAAuB,CAC3C,IAAI,EAAE,qBAAqB,EAC3B,MAAM,EAAE,UAAU,GACjB,OAAO,CAAC;IAAE,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC,CA+ChF;AAED,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;CAoBvC,CAAC;AAEF,KAAK,qBAAqB,GAAG;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,kBAAkB,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF,wBAAsB,uBAAuB,CAC3C,IAAI,EAAE,qBAAqB,EAC3B,MAAM,EAAE,UAAU,GACjB,OAAO,CAAC;IAAE,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC,CAmDhF;AAED,wBAAgB,QAAQ,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,GAAG,IAAI,CA6BpE"}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { BudaApiError } from "../client.js";
|
|
3
|
+
import { validateCurrency } from "../validation.js";
|
|
4
|
+
import { flattenAmount } from "../utils.js";
|
|
5
|
+
export const getDepositHistoryToolSchema = {
|
|
6
|
+
name: "get_deposit_history",
|
|
7
|
+
description: "Returns deposit history for a currency on the authenticated Buda.com account. " +
|
|
8
|
+
"Supports state filtering and pagination. All amounts are floats with separate _currency fields. " +
|
|
9
|
+
"Requires BUDA_API_KEY and BUDA_API_SECRET. " +
|
|
10
|
+
"Example: 'Show my last 10 BTC deposits.'",
|
|
11
|
+
inputSchema: {
|
|
12
|
+
type: "object",
|
|
13
|
+
properties: {
|
|
14
|
+
currency: {
|
|
15
|
+
type: "string",
|
|
16
|
+
description: "Currency code (e.g. 'BTC', 'CLP').",
|
|
17
|
+
},
|
|
18
|
+
state: {
|
|
19
|
+
type: "string",
|
|
20
|
+
description: "Filter by state: 'pending_info', 'pending', 'confirmed', 'anulled', 'retained'.",
|
|
21
|
+
},
|
|
22
|
+
per: {
|
|
23
|
+
type: "number",
|
|
24
|
+
description: "Results per page (default: 20, max: 300).",
|
|
25
|
+
},
|
|
26
|
+
page: {
|
|
27
|
+
type: "number",
|
|
28
|
+
description: "Page number (default: 1).",
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
required: ["currency"],
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
function normalizeDeposit(d) {
|
|
35
|
+
const amount = flattenAmount(d.amount);
|
|
36
|
+
const fee = flattenAmount(d.fee);
|
|
37
|
+
return {
|
|
38
|
+
id: d.id,
|
|
39
|
+
state: d.state,
|
|
40
|
+
currency: d.currency,
|
|
41
|
+
amount: amount.value,
|
|
42
|
+
amount_currency: amount.currency,
|
|
43
|
+
fee: fee.value,
|
|
44
|
+
fee_currency: fee.currency,
|
|
45
|
+
created_at: d.created_at,
|
|
46
|
+
updated_at: d.updated_at,
|
|
47
|
+
transfer_account_id: d.transfer_account_id,
|
|
48
|
+
transaction_hash: d.transaction_hash,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
export async function handleGetDepositHistory(args, client) {
|
|
52
|
+
const { currency, state, per, page } = args;
|
|
53
|
+
const validationError = validateCurrency(currency);
|
|
54
|
+
if (validationError) {
|
|
55
|
+
return {
|
|
56
|
+
content: [{ type: "text", text: JSON.stringify({ error: validationError, code: "INVALID_CURRENCY" }) }],
|
|
57
|
+
isError: true,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
try {
|
|
61
|
+
const params = {};
|
|
62
|
+
if (state)
|
|
63
|
+
params.state = state;
|
|
64
|
+
if (per !== undefined)
|
|
65
|
+
params.per = per;
|
|
66
|
+
if (page !== undefined)
|
|
67
|
+
params.page = page;
|
|
68
|
+
const data = await client.get(`/currencies/${currency.toUpperCase()}/deposits`, Object.keys(params).length > 0 ? params : undefined);
|
|
69
|
+
return {
|
|
70
|
+
content: [
|
|
71
|
+
{
|
|
72
|
+
type: "text",
|
|
73
|
+
text: JSON.stringify({
|
|
74
|
+
deposits: data.deposits.map(normalizeDeposit),
|
|
75
|
+
meta: data.meta,
|
|
76
|
+
}, null, 2),
|
|
77
|
+
},
|
|
78
|
+
],
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
catch (err) {
|
|
82
|
+
const msg = err instanceof BudaApiError
|
|
83
|
+
? { error: err.message, code: err.status, path: err.path }
|
|
84
|
+
: { error: String(err), code: "UNKNOWN" };
|
|
85
|
+
return {
|
|
86
|
+
content: [{ type: "text", text: JSON.stringify(msg) }],
|
|
87
|
+
isError: true,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
export const createFiatDepositToolSchema = {
|
|
92
|
+
name: "create_fiat_deposit",
|
|
93
|
+
description: "Record a fiat deposit on Buda.com. " +
|
|
94
|
+
"IMPORTANT: Calling this twice creates duplicate records — the confirmation guard is critical. " +
|
|
95
|
+
"Pass confirmation_token='CONFIRM' to execute. " +
|
|
96
|
+
"Requires BUDA_API_KEY and BUDA_API_SECRET.",
|
|
97
|
+
inputSchema: {
|
|
98
|
+
type: "object",
|
|
99
|
+
properties: {
|
|
100
|
+
currency: { type: "string", description: "Fiat currency code (e.g. 'CLP', 'COP', 'PEN')." },
|
|
101
|
+
amount: { type: "number", description: "Deposit amount." },
|
|
102
|
+
bank: { type: "string", description: "Bank name or identifier for the deposit source." },
|
|
103
|
+
confirmation_token: {
|
|
104
|
+
type: "string",
|
|
105
|
+
description: "Safety confirmation. Must equal exactly 'CONFIRM' (case-sensitive) to execute.",
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
required: ["currency", "amount", "confirmation_token"],
|
|
109
|
+
},
|
|
110
|
+
};
|
|
111
|
+
export async function handleCreateFiatDeposit(args, client) {
|
|
112
|
+
const { currency, amount, bank, confirmation_token } = args;
|
|
113
|
+
if (confirmation_token !== "CONFIRM") {
|
|
114
|
+
return {
|
|
115
|
+
content: [
|
|
116
|
+
{
|
|
117
|
+
type: "text",
|
|
118
|
+
text: JSON.stringify({
|
|
119
|
+
error: "Deposit not created. confirmation_token must equal 'CONFIRM' to execute. " +
|
|
120
|
+
"Review the details and set confirmation_token='CONFIRM' to proceed.",
|
|
121
|
+
code: "CONFIRMATION_REQUIRED",
|
|
122
|
+
preview: { currency, amount, bank },
|
|
123
|
+
}),
|
|
124
|
+
},
|
|
125
|
+
],
|
|
126
|
+
isError: true,
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
const validationError = validateCurrency(currency);
|
|
130
|
+
if (validationError) {
|
|
131
|
+
return {
|
|
132
|
+
content: [{ type: "text", text: JSON.stringify({ error: validationError, code: "INVALID_CURRENCY" }) }],
|
|
133
|
+
isError: true,
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
try {
|
|
137
|
+
const payload = { amount: String(amount) };
|
|
138
|
+
if (bank)
|
|
139
|
+
payload.bank = bank;
|
|
140
|
+
const data = await client.post(`/currencies/${currency.toUpperCase()}/deposits`, payload);
|
|
141
|
+
return {
|
|
142
|
+
content: [{ type: "text", text: JSON.stringify(normalizeDeposit(data.deposit), null, 2) }],
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
catch (err) {
|
|
146
|
+
const msg = err instanceof BudaApiError
|
|
147
|
+
? { error: err.message, code: err.status, path: err.path }
|
|
148
|
+
: { error: String(err), code: "UNKNOWN" };
|
|
149
|
+
return {
|
|
150
|
+
content: [{ type: "text", text: JSON.stringify(msg) }],
|
|
151
|
+
isError: true,
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
export function register(server, client) {
|
|
156
|
+
server.tool(getDepositHistoryToolSchema.name, getDepositHistoryToolSchema.description, {
|
|
157
|
+
currency: z.string().min(2).max(10).describe("Currency code (e.g. 'BTC', 'CLP')."),
|
|
158
|
+
state: z
|
|
159
|
+
.enum(["pending_info", "pending", "confirmed", "anulled", "retained"])
|
|
160
|
+
.optional()
|
|
161
|
+
.describe("Filter by state."),
|
|
162
|
+
per: z.number().int().min(1).max(300).optional().describe("Results per page (default: 20, max: 300)."),
|
|
163
|
+
page: z.number().int().min(1).optional().describe("Page number (default: 1)."),
|
|
164
|
+
}, (args) => handleGetDepositHistory(args, client));
|
|
165
|
+
server.tool(createFiatDepositToolSchema.name, createFiatDepositToolSchema.description, {
|
|
166
|
+
currency: z.string().min(2).max(10).describe("Fiat currency code (e.g. 'CLP', 'COP', 'PEN')."),
|
|
167
|
+
amount: z.number().positive().describe("Deposit amount."),
|
|
168
|
+
bank: z.string().optional().describe("Bank name or identifier for the deposit source."),
|
|
169
|
+
confirmation_token: z
|
|
170
|
+
.string()
|
|
171
|
+
.describe("Safety confirmation. Must equal exactly 'CONFIRM' (case-sensitive) to execute."),
|
|
172
|
+
}, (args) => handleCreateFiatDeposit(args, client));
|
|
173
|
+
}
|
|
174
|
+
//# sourceMappingURL=deposits.js.map
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import { BudaClient } from "../client.js";
|
|
3
|
+
export declare const toolSchema: {
|
|
4
|
+
name: string;
|
|
5
|
+
description: string;
|
|
6
|
+
inputSchema: {
|
|
7
|
+
type: "object";
|
|
8
|
+
properties: {
|
|
9
|
+
currency: {
|
|
10
|
+
type: string;
|
|
11
|
+
description: string;
|
|
12
|
+
};
|
|
13
|
+
type: {
|
|
14
|
+
type: string;
|
|
15
|
+
description: string;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
required: string[];
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
type GetNetworkFeesArgs = {
|
|
22
|
+
currency: string;
|
|
23
|
+
type: "deposit" | "withdrawal";
|
|
24
|
+
};
|
|
25
|
+
export declare function handleGetNetworkFees(args: GetNetworkFeesArgs, client: BudaClient): Promise<{
|
|
26
|
+
content: Array<{
|
|
27
|
+
type: "text";
|
|
28
|
+
text: string;
|
|
29
|
+
}>;
|
|
30
|
+
isError?: boolean;
|
|
31
|
+
}>;
|
|
32
|
+
export declare function register(server: McpServer, client: BudaClient): void;
|
|
33
|
+
export {};
|
|
34
|
+
//# sourceMappingURL=fees.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fees.d.ts","sourceRoot":"","sources":["../../src/tools/fees.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEpE,OAAO,EAAE,UAAU,EAAgB,MAAM,cAAc,CAAC;AAKxD,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;CAqBtB,CAAC;AAEF,KAAK,kBAAkB,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,SAAS,GAAG,YAAY,CAAA;CAAE,CAAC;AAE/E,wBAAsB,oBAAoB,CACxC,IAAI,EAAE,kBAAkB,EACxB,MAAM,EAAE,UAAU,GACjB,OAAO,CAAC;IAAE,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC,CA2ChF;AAED,wBAAgB,QAAQ,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,GAAG,IAAI,CAUpE"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { BudaApiError } from "../client.js";
|
|
3
|
+
import { validateCurrency } from "../validation.js";
|
|
4
|
+
import { flattenAmount } from "../utils.js";
|
|
5
|
+
export const toolSchema = {
|
|
6
|
+
name: "get_network_fees",
|
|
7
|
+
description: "Returns the deposit or withdrawal network fee schedule for a currency on Buda.com. " +
|
|
8
|
+
"Useful before initiating a transfer to preview costs. " +
|
|
9
|
+
"Requires BUDA_API_KEY and BUDA_API_SECRET. " +
|
|
10
|
+
"Example: 'What are the withdrawal fees for BTC?'",
|
|
11
|
+
inputSchema: {
|
|
12
|
+
type: "object",
|
|
13
|
+
properties: {
|
|
14
|
+
currency: {
|
|
15
|
+
type: "string",
|
|
16
|
+
description: "Currency code (e.g. 'BTC', 'ETH', 'CLP').",
|
|
17
|
+
},
|
|
18
|
+
type: {
|
|
19
|
+
type: "string",
|
|
20
|
+
description: "Fee direction: 'deposit' or 'withdrawal'.",
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
required: ["currency", "type"],
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
export async function handleGetNetworkFees(args, client) {
|
|
27
|
+
const { currency, type } = args;
|
|
28
|
+
const validationError = validateCurrency(currency);
|
|
29
|
+
if (validationError) {
|
|
30
|
+
return {
|
|
31
|
+
content: [{ type: "text", text: JSON.stringify({ error: validationError, code: "INVALID_CURRENCY" }) }],
|
|
32
|
+
isError: true,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
try {
|
|
36
|
+
const data = await client.get(`/currencies/${currency.toUpperCase()}/fees/${type}`);
|
|
37
|
+
const fees = data.fees.map((f) => {
|
|
38
|
+
const baseFee = flattenAmount(f.base_fee);
|
|
39
|
+
return {
|
|
40
|
+
name: f.name,
|
|
41
|
+
fee_type: f.fee_type,
|
|
42
|
+
base_fee: baseFee.value,
|
|
43
|
+
base_fee_currency: baseFee.currency,
|
|
44
|
+
percent: f.percent !== null ? parseFloat(f.percent) : null,
|
|
45
|
+
};
|
|
46
|
+
});
|
|
47
|
+
return {
|
|
48
|
+
content: [
|
|
49
|
+
{
|
|
50
|
+
type: "text",
|
|
51
|
+
text: JSON.stringify({ currency: currency.toUpperCase(), type, fees }, null, 2),
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
catch (err) {
|
|
57
|
+
const msg = err instanceof BudaApiError
|
|
58
|
+
? { error: err.message, code: err.status, path: err.path }
|
|
59
|
+
: { error: String(err), code: "UNKNOWN" };
|
|
60
|
+
return {
|
|
61
|
+
content: [{ type: "text", text: JSON.stringify(msg) }],
|
|
62
|
+
isError: true,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
export function register(server, client) {
|
|
67
|
+
server.tool(toolSchema.name, toolSchema.description, {
|
|
68
|
+
currency: z.string().min(2).max(10).describe("Currency code (e.g. 'BTC', 'ETH', 'CLP')."),
|
|
69
|
+
type: z.enum(["deposit", "withdrawal"]).describe("Fee direction: 'deposit' or 'withdrawal'."),
|
|
70
|
+
}, (args) => handleGetNetworkFees(args, client));
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=fees.js.map
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import { BudaClient } from "../client.js";
|
|
3
|
+
export declare const lightningWithdrawalToolSchema: {
|
|
4
|
+
name: string;
|
|
5
|
+
description: string;
|
|
6
|
+
inputSchema: {
|
|
7
|
+
type: "object";
|
|
8
|
+
properties: {
|
|
9
|
+
invoice: {
|
|
10
|
+
type: string;
|
|
11
|
+
description: string;
|
|
12
|
+
};
|
|
13
|
+
confirmation_token: {
|
|
14
|
+
type: string;
|
|
15
|
+
description: string;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
required: string[];
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
export declare const createLightningInvoiceToolSchema: {
|
|
22
|
+
name: string;
|
|
23
|
+
description: string;
|
|
24
|
+
inputSchema: {
|
|
25
|
+
type: "object";
|
|
26
|
+
properties: {
|
|
27
|
+
amount_satoshis: {
|
|
28
|
+
type: string;
|
|
29
|
+
description: string;
|
|
30
|
+
};
|
|
31
|
+
description: {
|
|
32
|
+
type: string;
|
|
33
|
+
description: string;
|
|
34
|
+
};
|
|
35
|
+
expiry_seconds: {
|
|
36
|
+
type: string;
|
|
37
|
+
description: string;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
required: string[];
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
type LightningWithdrawalArgs = {
|
|
44
|
+
invoice: string;
|
|
45
|
+
confirmation_token: string;
|
|
46
|
+
};
|
|
47
|
+
type CreateLightningInvoiceArgs = {
|
|
48
|
+
amount_satoshis: number;
|
|
49
|
+
description?: string;
|
|
50
|
+
expiry_seconds?: number;
|
|
51
|
+
};
|
|
52
|
+
export declare function handleLightningWithdrawal(args: LightningWithdrawalArgs, client: BudaClient): Promise<{
|
|
53
|
+
content: Array<{
|
|
54
|
+
type: "text";
|
|
55
|
+
text: string;
|
|
56
|
+
}>;
|
|
57
|
+
isError?: boolean;
|
|
58
|
+
}>;
|
|
59
|
+
export declare function handleCreateLightningInvoice(args: CreateLightningInvoiceArgs, client: BudaClient): Promise<{
|
|
60
|
+
content: Array<{
|
|
61
|
+
type: "text";
|
|
62
|
+
text: string;
|
|
63
|
+
}>;
|
|
64
|
+
isError?: boolean;
|
|
65
|
+
}>;
|
|
66
|
+
export declare function register(server: McpServer, client: BudaClient): void;
|
|
67
|
+
export {};
|
|
68
|
+
//# sourceMappingURL=lightning.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lightning.d.ts","sourceRoot":"","sources":["../../src/tools/lightning.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEpE,OAAO,EAAE,UAAU,EAAgB,MAAM,cAAc,CAAC;AAIxD,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;;;;;CAuBzC,CAAC;AAEF,eAAO,MAAM,gCAAgC;;;;;;;;;;;;;;;;;;;;;CAwB5C,CAAC;AAEF,KAAK,uBAAuB,GAAG;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,kBAAkB,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF,KAAK,0BAA0B,GAAG;IAChC,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,wBAAsB,yBAAyB,CAC7C,IAAI,EAAE,uBAAuB,EAC7B,MAAM,EAAE,UAAU,GACjB,OAAO,CAAC;IAAE,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC,CA+EhF;AAED,wBAAsB,4BAA4B,CAChD,IAAI,EAAE,0BAA0B,EAChC,MAAM,EAAE,UAAU,GACjB,OAAO,CAAC;IAAE,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC,CA8ChF;AAED,wBAAgB,QAAQ,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,GAAG,IAAI,CA2CpE"}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { BudaApiError } from "../client.js";
|
|
3
|
+
import { flattenAmount } from "../utils.js";
|
|
4
|
+
export const lightningWithdrawalToolSchema = {
|
|
5
|
+
name: "lightning_withdrawal",
|
|
6
|
+
description: "Pay a Bitcoin Lightning Network invoice from your Buda.com LN-BTC reserve. " +
|
|
7
|
+
"IMPORTANT: Funds leave the account immediately on success. " +
|
|
8
|
+
"Pass confirmation_token='CONFIRM' to execute. " +
|
|
9
|
+
"Requires BUDA_API_KEY and BUDA_API_SECRET.",
|
|
10
|
+
inputSchema: {
|
|
11
|
+
type: "object",
|
|
12
|
+
properties: {
|
|
13
|
+
invoice: {
|
|
14
|
+
type: "string",
|
|
15
|
+
description: "BOLT-11 Lightning invoice string (starts with 'lnbc', 'lntb', etc.).",
|
|
16
|
+
},
|
|
17
|
+
confirmation_token: {
|
|
18
|
+
type: "string",
|
|
19
|
+
description: "Safety confirmation. Must equal exactly 'CONFIRM' (case-sensitive) to execute. " +
|
|
20
|
+
"Any other value will reject the request without paying.",
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
required: ["invoice", "confirmation_token"],
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
export const createLightningInvoiceToolSchema = {
|
|
27
|
+
name: "create_lightning_invoice",
|
|
28
|
+
description: "Create a Bitcoin Lightning Network invoice on Buda.com to receive a payment. " +
|
|
29
|
+
"No funds leave the account — no confirmation required. " +
|
|
30
|
+
"Requires BUDA_API_KEY and BUDA_API_SECRET.",
|
|
31
|
+
inputSchema: {
|
|
32
|
+
type: "object",
|
|
33
|
+
properties: {
|
|
34
|
+
amount_satoshis: {
|
|
35
|
+
type: "number",
|
|
36
|
+
description: "Invoice amount in satoshis (positive integer).",
|
|
37
|
+
},
|
|
38
|
+
description: {
|
|
39
|
+
type: "string",
|
|
40
|
+
description: "Optional payment description (max 140 characters).",
|
|
41
|
+
},
|
|
42
|
+
expiry_seconds: {
|
|
43
|
+
type: "number",
|
|
44
|
+
description: "Invoice expiry in seconds (60–86400, default: 3600).",
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
required: ["amount_satoshis"],
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
export async function handleLightningWithdrawal(args, client) {
|
|
51
|
+
const { invoice, confirmation_token } = args;
|
|
52
|
+
if (confirmation_token !== "CONFIRM") {
|
|
53
|
+
const preview = invoice.length > 20 ? invoice.substring(0, 20) + "..." : invoice;
|
|
54
|
+
return {
|
|
55
|
+
content: [
|
|
56
|
+
{
|
|
57
|
+
type: "text",
|
|
58
|
+
text: JSON.stringify({
|
|
59
|
+
error: "Lightning withdrawal not executed. confirmation_token must equal 'CONFIRM' to execute. " +
|
|
60
|
+
"Review the invoice and set confirmation_token='CONFIRM' to proceed.",
|
|
61
|
+
code: "CONFIRMATION_REQUIRED",
|
|
62
|
+
preview: { invoice_preview: preview },
|
|
63
|
+
}),
|
|
64
|
+
},
|
|
65
|
+
],
|
|
66
|
+
isError: true,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
const BOLT11_RE = /^ln(bc|tb|bcrt)\d/i;
|
|
70
|
+
if (!BOLT11_RE.test(invoice)) {
|
|
71
|
+
return {
|
|
72
|
+
content: [{
|
|
73
|
+
type: "text",
|
|
74
|
+
text: JSON.stringify({
|
|
75
|
+
error: "Invalid Lightning invoice format. " +
|
|
76
|
+
"Expected a BOLT-11 string starting with 'lnbc', 'lntb', or 'lnbcrt'.",
|
|
77
|
+
code: "INVALID_INVOICE",
|
|
78
|
+
}),
|
|
79
|
+
}],
|
|
80
|
+
isError: true,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
try {
|
|
84
|
+
const data = await client.post(`/reserves/ln-btc/withdrawals`, { invoice });
|
|
85
|
+
const lw = data.lightning_withdrawal;
|
|
86
|
+
const amount = flattenAmount(lw.amount);
|
|
87
|
+
const fee = flattenAmount(lw.fee);
|
|
88
|
+
return {
|
|
89
|
+
content: [
|
|
90
|
+
{
|
|
91
|
+
type: "text",
|
|
92
|
+
text: JSON.stringify({
|
|
93
|
+
id: lw.id,
|
|
94
|
+
state: lw.state,
|
|
95
|
+
amount: amount.value,
|
|
96
|
+
amount_currency: amount.currency,
|
|
97
|
+
fee: fee.value,
|
|
98
|
+
fee_currency: fee.currency,
|
|
99
|
+
payment_hash: lw.payment_hash,
|
|
100
|
+
created_at: lw.created_at,
|
|
101
|
+
}, null, 2),
|
|
102
|
+
},
|
|
103
|
+
],
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
catch (err) {
|
|
107
|
+
const msg = err instanceof BudaApiError
|
|
108
|
+
? { error: err.message, code: err.status, path: err.path }
|
|
109
|
+
: { error: String(err), code: "UNKNOWN" };
|
|
110
|
+
return {
|
|
111
|
+
content: [{ type: "text", text: JSON.stringify(msg) }],
|
|
112
|
+
isError: true,
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
export async function handleCreateLightningInvoice(args, client) {
|
|
117
|
+
const { amount_satoshis, description, expiry_seconds } = args;
|
|
118
|
+
try {
|
|
119
|
+
const invoicePayload = { amount: amount_satoshis };
|
|
120
|
+
if (description !== undefined)
|
|
121
|
+
invoicePayload.description = description;
|
|
122
|
+
if (expiry_seconds !== undefined)
|
|
123
|
+
invoicePayload.expiry = expiry_seconds;
|
|
124
|
+
const data = await client.post(`/lightning_network_invoices`, { lightning_network_invoice: invoicePayload });
|
|
125
|
+
const inv = data.lightning_network_invoice;
|
|
126
|
+
const amount = flattenAmount(inv.amount);
|
|
127
|
+
return {
|
|
128
|
+
content: [
|
|
129
|
+
{
|
|
130
|
+
type: "text",
|
|
131
|
+
text: JSON.stringify({
|
|
132
|
+
id: inv.id,
|
|
133
|
+
payment_request: inv.payment_request,
|
|
134
|
+
amount_satoshis: amount.value,
|
|
135
|
+
description: inv.description,
|
|
136
|
+
expires_at: inv.expires_at,
|
|
137
|
+
state: inv.state,
|
|
138
|
+
created_at: inv.created_at,
|
|
139
|
+
}, null, 2),
|
|
140
|
+
},
|
|
141
|
+
],
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
catch (err) {
|
|
145
|
+
const msg = err instanceof BudaApiError
|
|
146
|
+
? { error: err.message, code: err.status, path: err.path }
|
|
147
|
+
: { error: String(err), code: "UNKNOWN" };
|
|
148
|
+
return {
|
|
149
|
+
content: [{ type: "text", text: JSON.stringify(msg) }],
|
|
150
|
+
isError: true,
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
export function register(server, client) {
|
|
155
|
+
server.tool(lightningWithdrawalToolSchema.name, lightningWithdrawalToolSchema.description, {
|
|
156
|
+
invoice: z
|
|
157
|
+
.string()
|
|
158
|
+
.min(50)
|
|
159
|
+
.describe("BOLT-11 Lightning invoice string (starts with 'lnbc', 'lntb', etc.)."),
|
|
160
|
+
confirmation_token: z
|
|
161
|
+
.string()
|
|
162
|
+
.describe("Safety confirmation. Must equal exactly 'CONFIRM' (case-sensitive) to execute. " +
|
|
163
|
+
"Any other value will reject the request without paying."),
|
|
164
|
+
}, (args) => handleLightningWithdrawal(args, client));
|
|
165
|
+
server.tool(createLightningInvoiceToolSchema.name, createLightningInvoiceToolSchema.description, {
|
|
166
|
+
amount_satoshis: z
|
|
167
|
+
.number()
|
|
168
|
+
.int()
|
|
169
|
+
.positive()
|
|
170
|
+
.describe("Invoice amount in satoshis (positive integer)."),
|
|
171
|
+
description: z
|
|
172
|
+
.string()
|
|
173
|
+
.max(140)
|
|
174
|
+
.optional()
|
|
175
|
+
.describe("Optional payment description (max 140 characters)."),
|
|
176
|
+
expiry_seconds: z
|
|
177
|
+
.number()
|
|
178
|
+
.int()
|
|
179
|
+
.min(60)
|
|
180
|
+
.max(86400)
|
|
181
|
+
.optional()
|
|
182
|
+
.describe("Invoice expiry in seconds (60–86400, default: 3600)."),
|
|
183
|
+
}, (args) => handleCreateLightningInvoice(args, client));
|
|
184
|
+
}
|
|
185
|
+
//# sourceMappingURL=lightning.js.map
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import { BudaClient } from "../client.js";
|
|
3
|
+
export declare const getOrderToolSchema: {
|
|
4
|
+
name: string;
|
|
5
|
+
description: string;
|
|
6
|
+
inputSchema: {
|
|
7
|
+
type: "object";
|
|
8
|
+
properties: {
|
|
9
|
+
order_id: {
|
|
10
|
+
type: string;
|
|
11
|
+
description: string;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
required: string[];
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
export declare const getOrderByClientIdToolSchema: {
|
|
18
|
+
name: string;
|
|
19
|
+
description: string;
|
|
20
|
+
inputSchema: {
|
|
21
|
+
type: "object";
|
|
22
|
+
properties: {
|
|
23
|
+
client_id: {
|
|
24
|
+
type: string;
|
|
25
|
+
description: string;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
required: string[];
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
export declare function handleGetOrder(args: {
|
|
32
|
+
order_id: number;
|
|
33
|
+
}, client: BudaClient): Promise<{
|
|
34
|
+
content: Array<{
|
|
35
|
+
type: "text";
|
|
36
|
+
text: string;
|
|
37
|
+
}>;
|
|
38
|
+
isError?: boolean;
|
|
39
|
+
}>;
|
|
40
|
+
export declare function handleGetOrderByClientId(args: {
|
|
41
|
+
client_id: string;
|
|
42
|
+
}, client: BudaClient): Promise<{
|
|
43
|
+
content: Array<{
|
|
44
|
+
type: "text";
|
|
45
|
+
text: string;
|
|
46
|
+
}>;
|
|
47
|
+
isError?: boolean;
|
|
48
|
+
}>;
|
|
49
|
+
export declare function register(server: McpServer, client: BudaClient): void;
|
|
50
|
+
//# sourceMappingURL=order_lookup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"order_lookup.d.ts","sourceRoot":"","sources":["../../src/tools/order_lookup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEpE,OAAO,EAAE,UAAU,EAAgB,MAAM,cAAc,CAAC;AAIxD,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;CAkB9B,CAAC;AAEF,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;CAiBxC,CAAC;AAmCF,wBAAsB,cAAc,CAClC,IAAI,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,EAC1B,MAAM,EAAE,UAAU,GACjB,OAAO,CAAC;IAAE,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC,CAgBhF;AAED,wBAAsB,wBAAwB,CAC5C,IAAI,EAAE;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,EAC3B,MAAM,EAAE,UAAU,GACjB,OAAO,CAAC;IAAE,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC,CAgBhF;AAED,wBAAgB,QAAQ,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,GAAG,IAAI,CAkBpE"}
|