@guiie/buda-mcp 1.4.2 → 1.5.0
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 +39 -0
- 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 +1 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +16 -0
- package/dist/http.js +55 -0
- package/dist/index.js +30 -0
- 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 +77 -0
- package/dist/tools/batch_orders.d.ts.map +1 -0
- package/dist/tools/batch_orders.js +154 -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_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/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 +171 -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 +100 -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 +78 -0
- package/dist/tools/receive_addresses.d.ts.map +1 -0
- package/dist/tools/receive_addresses.js +161 -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 +115 -0
- package/dist/tools/remittances.d.ts.map +1 -0
- package/dist/tools/remittances.js +237 -0
- package/dist/tools/simulate_order.d.ts.map +1 -1
- package/dist/tools/simulate_order.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 +215 -0
- package/dist/types.d.ts +155 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/validation.d.ts +5 -0
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +12 -0
- package/marketplace/README.md +1 -1
- package/marketplace/claude-listing.md +30 -2
- package/marketplace/gemini-tools.json +155 -1
- package/marketplace/openapi.yaml +1 -1
- package/package.json +1 -1
- package/server.json +2 -2
- package/src/cache.ts +1 -0
- package/src/client.ts +20 -0
- package/src/http.ts +55 -0
- package/src/index.ts +30 -0
- 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 +199 -0
- package/src/tools/cancel_all_orders.ts +117 -0
- package/src/tools/cancel_order_by_client_id.ts +132 -0
- package/src/tools/deposits.ts +230 -0
- package/src/tools/fees.ts +91 -0
- package/src/tools/lightning.ts +231 -0
- package/src/tools/order_lookup.ts +139 -0
- package/src/tools/place_order.ts +119 -2
- package/src/tools/quotation.ts +124 -0
- package/src/tools/receive_addresses.ts +216 -0
- package/src/tools/remittance_recipients.ts +139 -0
- package/src/tools/remittances.ts +299 -0
- package/src/tools/simulate_order.ts +1 -0
- package/src/tools/withdrawals.ts +276 -0
- package/src/types.ts +210 -0
- package/src/validation.ts +16 -0
- package/test/run-all.ts +16 -0
- package/test/unit.ts +1905 -0
|
@@ -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+DhF;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,171 @@
|
|
|
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
|
+
try {
|
|
70
|
+
const data = await client.post(`/reserves/ln-btc/withdrawals`, { invoice });
|
|
71
|
+
const lw = data.lightning_withdrawal;
|
|
72
|
+
const amount = flattenAmount(lw.amount);
|
|
73
|
+
const fee = flattenAmount(lw.fee);
|
|
74
|
+
return {
|
|
75
|
+
content: [
|
|
76
|
+
{
|
|
77
|
+
type: "text",
|
|
78
|
+
text: JSON.stringify({
|
|
79
|
+
id: lw.id,
|
|
80
|
+
state: lw.state,
|
|
81
|
+
amount: amount.value,
|
|
82
|
+
amount_currency: amount.currency,
|
|
83
|
+
fee: fee.value,
|
|
84
|
+
fee_currency: fee.currency,
|
|
85
|
+
payment_hash: lw.payment_hash,
|
|
86
|
+
created_at: lw.created_at,
|
|
87
|
+
}, null, 2),
|
|
88
|
+
},
|
|
89
|
+
],
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
catch (err) {
|
|
93
|
+
const msg = err instanceof BudaApiError
|
|
94
|
+
? { error: err.message, code: err.status, path: err.path }
|
|
95
|
+
: { error: String(err), code: "UNKNOWN" };
|
|
96
|
+
return {
|
|
97
|
+
content: [{ type: "text", text: JSON.stringify(msg) }],
|
|
98
|
+
isError: true,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
export async function handleCreateLightningInvoice(args, client) {
|
|
103
|
+
const { amount_satoshis, description, expiry_seconds } = args;
|
|
104
|
+
try {
|
|
105
|
+
const invoicePayload = { amount: amount_satoshis };
|
|
106
|
+
if (description !== undefined)
|
|
107
|
+
invoicePayload.description = description;
|
|
108
|
+
if (expiry_seconds !== undefined)
|
|
109
|
+
invoicePayload.expiry = expiry_seconds;
|
|
110
|
+
const data = await client.post(`/lightning_network_invoices`, { lightning_network_invoice: invoicePayload });
|
|
111
|
+
const inv = data.lightning_network_invoice;
|
|
112
|
+
const amount = flattenAmount(inv.amount);
|
|
113
|
+
return {
|
|
114
|
+
content: [
|
|
115
|
+
{
|
|
116
|
+
type: "text",
|
|
117
|
+
text: JSON.stringify({
|
|
118
|
+
id: inv.id,
|
|
119
|
+
payment_request: inv.payment_request,
|
|
120
|
+
amount_satoshis: amount.value,
|
|
121
|
+
description: inv.description,
|
|
122
|
+
expires_at: inv.expires_at,
|
|
123
|
+
state: inv.state,
|
|
124
|
+
created_at: inv.created_at,
|
|
125
|
+
}, null, 2),
|
|
126
|
+
},
|
|
127
|
+
],
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
catch (err) {
|
|
131
|
+
const msg = err instanceof BudaApiError
|
|
132
|
+
? { error: err.message, code: err.status, path: err.path }
|
|
133
|
+
: { error: String(err), code: "UNKNOWN" };
|
|
134
|
+
return {
|
|
135
|
+
content: [{ type: "text", text: JSON.stringify(msg) }],
|
|
136
|
+
isError: true,
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
export function register(server, client) {
|
|
141
|
+
server.tool(lightningWithdrawalToolSchema.name, lightningWithdrawalToolSchema.description, {
|
|
142
|
+
invoice: z
|
|
143
|
+
.string()
|
|
144
|
+
.min(1)
|
|
145
|
+
.describe("BOLT-11 Lightning invoice string (starts with 'lnbc', 'lntb', etc.)."),
|
|
146
|
+
confirmation_token: z
|
|
147
|
+
.string()
|
|
148
|
+
.describe("Safety confirmation. Must equal exactly 'CONFIRM' (case-sensitive) to execute. " +
|
|
149
|
+
"Any other value will reject the request without paying."),
|
|
150
|
+
}, (args) => handleLightningWithdrawal(args, client));
|
|
151
|
+
server.tool(createLightningInvoiceToolSchema.name, createLightningInvoiceToolSchema.description, {
|
|
152
|
+
amount_satoshis: z
|
|
153
|
+
.number()
|
|
154
|
+
.int()
|
|
155
|
+
.positive()
|
|
156
|
+
.describe("Invoice amount in satoshis (positive integer)."),
|
|
157
|
+
description: z
|
|
158
|
+
.string()
|
|
159
|
+
.max(140)
|
|
160
|
+
.optional()
|
|
161
|
+
.describe("Optional payment description (max 140 characters)."),
|
|
162
|
+
expiry_seconds: z
|
|
163
|
+
.number()
|
|
164
|
+
.int()
|
|
165
|
+
.min(60)
|
|
166
|
+
.max(86400)
|
|
167
|
+
.optional()
|
|
168
|
+
.describe("Invoice expiry in seconds (60–86400, default: 3600)."),
|
|
169
|
+
}, (args) => handleCreateLightningInvoice(args, client));
|
|
170
|
+
}
|
|
171
|
+
//# 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"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { BudaApiError } from "../client.js";
|
|
3
|
+
import { flattenAmount } from "../utils.js";
|
|
4
|
+
export const getOrderToolSchema = {
|
|
5
|
+
name: "get_order",
|
|
6
|
+
description: "Returns a single order by its numeric ID on Buda.com. " +
|
|
7
|
+
"Fetches full detail including state, amounts, fees, and timestamps. " +
|
|
8
|
+
"All monetary amounts are floats with separate _currency fields. " +
|
|
9
|
+
"Requires BUDA_API_KEY and BUDA_API_SECRET. " +
|
|
10
|
+
"Example: 'Show me the details of order 987654.'",
|
|
11
|
+
inputSchema: {
|
|
12
|
+
type: "object",
|
|
13
|
+
properties: {
|
|
14
|
+
order_id: {
|
|
15
|
+
type: "number",
|
|
16
|
+
description: "The numeric ID of the order.",
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
required: ["order_id"],
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
export const getOrderByClientIdToolSchema = {
|
|
23
|
+
name: "get_order_by_client_id",
|
|
24
|
+
description: "Returns an order by the client-assigned ID you set at placement on Buda.com. " +
|
|
25
|
+
"All monetary amounts are floats with separate _currency fields. " +
|
|
26
|
+
"Requires BUDA_API_KEY and BUDA_API_SECRET. " +
|
|
27
|
+
"Example: 'Find my order with client ID my-bot-order-42.'",
|
|
28
|
+
inputSchema: {
|
|
29
|
+
type: "object",
|
|
30
|
+
properties: {
|
|
31
|
+
client_id: {
|
|
32
|
+
type: "string",
|
|
33
|
+
description: "The client ID string assigned when placing the order.",
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
required: ["client_id"],
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
function normalizeOrder(o) {
|
|
40
|
+
const amount = flattenAmount(o.amount);
|
|
41
|
+
const originalAmount = flattenAmount(o.original_amount);
|
|
42
|
+
const tradedAmount = flattenAmount(o.traded_amount);
|
|
43
|
+
const totalExchanged = flattenAmount(o.total_exchanged);
|
|
44
|
+
const paidFee = flattenAmount(o.paid_fee);
|
|
45
|
+
const limitPrice = o.limit ? flattenAmount(o.limit) : null;
|
|
46
|
+
return {
|
|
47
|
+
id: o.id,
|
|
48
|
+
type: o.type,
|
|
49
|
+
state: o.state,
|
|
50
|
+
created_at: o.created_at,
|
|
51
|
+
market_id: o.market_id,
|
|
52
|
+
fee_currency: o.fee_currency,
|
|
53
|
+
price_type: o.price_type,
|
|
54
|
+
order_type: o.order_type,
|
|
55
|
+
client_id: o.client_id,
|
|
56
|
+
limit_price: limitPrice ? limitPrice.value : null,
|
|
57
|
+
limit_price_currency: limitPrice ? limitPrice.currency : null,
|
|
58
|
+
amount: amount.value,
|
|
59
|
+
amount_currency: amount.currency,
|
|
60
|
+
original_amount: originalAmount.value,
|
|
61
|
+
original_amount_currency: originalAmount.currency,
|
|
62
|
+
traded_amount: tradedAmount.value,
|
|
63
|
+
traded_amount_currency: tradedAmount.currency,
|
|
64
|
+
total_exchanged: totalExchanged.value,
|
|
65
|
+
total_exchanged_currency: totalExchanged.currency,
|
|
66
|
+
paid_fee: paidFee.value,
|
|
67
|
+
paid_fee_currency: paidFee.currency,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
export async function handleGetOrder(args, client) {
|
|
71
|
+
try {
|
|
72
|
+
const data = await client.get(`/orders/${args.order_id}`);
|
|
73
|
+
return {
|
|
74
|
+
content: [{ type: "text", text: JSON.stringify(normalizeOrder(data.order), null, 2) }],
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
catch (err) {
|
|
78
|
+
const msg = err instanceof BudaApiError
|
|
79
|
+
? { error: err.message, code: err.status, path: err.path }
|
|
80
|
+
: { error: String(err), code: "UNKNOWN" };
|
|
81
|
+
return {
|
|
82
|
+
content: [{ type: "text", text: JSON.stringify(msg) }],
|
|
83
|
+
isError: true,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
export async function handleGetOrderByClientId(args, client) {
|
|
88
|
+
try {
|
|
89
|
+
const data = await client.get(`/orders/by-client-id/${encodeURIComponent(args.client_id)}`);
|
|
90
|
+
return {
|
|
91
|
+
content: [{ type: "text", text: JSON.stringify(normalizeOrder(data.order), null, 2) }],
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
catch (err) {
|
|
95
|
+
const msg = err instanceof BudaApiError
|
|
96
|
+
? { error: err.message, code: err.status, path: err.path }
|
|
97
|
+
: { error: String(err), code: "UNKNOWN" };
|
|
98
|
+
return {
|
|
99
|
+
content: [{ type: "text", text: JSON.stringify(msg) }],
|
|
100
|
+
isError: true,
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
export function register(server, client) {
|
|
105
|
+
server.tool(getOrderToolSchema.name, getOrderToolSchema.description, {
|
|
106
|
+
order_id: z.number().int().positive().describe("The numeric ID of the order."),
|
|
107
|
+
}, (args) => handleGetOrder(args, client));
|
|
108
|
+
server.tool(getOrderByClientIdToolSchema.name, getOrderByClientIdToolSchema.description, {
|
|
109
|
+
client_id: z.string().min(1).describe("The client ID string assigned when placing the order."),
|
|
110
|
+
}, (args) => handleGetOrderByClientId(args, client));
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=order_lookup.js.map
|
|
@@ -26,6 +26,30 @@ export declare const toolSchema: {
|
|
|
26
26
|
type: string;
|
|
27
27
|
description: string;
|
|
28
28
|
};
|
|
29
|
+
ioc: {
|
|
30
|
+
type: string;
|
|
31
|
+
description: string;
|
|
32
|
+
};
|
|
33
|
+
fok: {
|
|
34
|
+
type: string;
|
|
35
|
+
description: string;
|
|
36
|
+
};
|
|
37
|
+
post_only: {
|
|
38
|
+
type: string;
|
|
39
|
+
description: string;
|
|
40
|
+
};
|
|
41
|
+
gtd_timestamp: {
|
|
42
|
+
type: string;
|
|
43
|
+
description: string;
|
|
44
|
+
};
|
|
45
|
+
stop_price: {
|
|
46
|
+
type: string;
|
|
47
|
+
description: string;
|
|
48
|
+
};
|
|
49
|
+
stop_type: {
|
|
50
|
+
type: string;
|
|
51
|
+
description: string;
|
|
52
|
+
};
|
|
29
53
|
confirmation_token: {
|
|
30
54
|
type: string;
|
|
31
55
|
description: string;
|
|
@@ -40,6 +64,12 @@ type PlaceOrderArgs = {
|
|
|
40
64
|
price_type: "limit" | "market";
|
|
41
65
|
amount: number;
|
|
42
66
|
limit_price?: number;
|
|
67
|
+
ioc?: boolean;
|
|
68
|
+
fok?: boolean;
|
|
69
|
+
post_only?: boolean;
|
|
70
|
+
gtd_timestamp?: string;
|
|
71
|
+
stop_price?: number;
|
|
72
|
+
stop_type?: ">=" | "<=";
|
|
43
73
|
confirmation_token: string;
|
|
44
74
|
};
|
|
45
75
|
export declare function handlePlaceOrder(args: PlaceOrderArgs, client: BudaClient): Promise<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"place_order.d.ts","sourceRoot":"","sources":["../../src/tools/place_order.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEpE,OAAO,EAAE,UAAU,EAAgB,MAAM,cAAc,CAAC;AAIxD,eAAO,MAAM,UAAU
|
|
1
|
+
{"version":3,"file":"place_order.d.ts","sourceRoot":"","sources":["../../src/tools/place_order.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEpE,OAAO,EAAE,UAAU,EAAgB,MAAM,cAAc,CAAC;AAIxD,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmEtB,CAAC;AAEF,KAAK,cAAc,GAAG;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,KAAK,GAAG,KAAK,CAAC;IACpB,UAAU,EAAE,OAAO,GAAG,QAAQ,CAAC;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IACxB,kBAAkB,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,cAAc,EACpB,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,CAqIhF;AAED,wBAAgB,QAAQ,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,GAAG,IAAI,CA4DpE"}
|