@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.
Files changed (95) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/dist/cache.d.ts +1 -0
  3. package/dist/cache.d.ts.map +1 -1
  4. package/dist/cache.js +1 -0
  5. package/dist/client.d.ts +1 -0
  6. package/dist/client.d.ts.map +1 -1
  7. package/dist/client.js +16 -0
  8. package/dist/http.js +55 -0
  9. package/dist/index.js +30 -0
  10. package/dist/tools/account.d.ts +19 -0
  11. package/dist/tools/account.d.ts.map +1 -0
  12. package/dist/tools/account.js +49 -0
  13. package/dist/tools/balance.d.ts +29 -0
  14. package/dist/tools/balance.d.ts.map +1 -0
  15. package/dist/tools/balance.js +72 -0
  16. package/dist/tools/banks.d.ts +28 -0
  17. package/dist/tools/banks.d.ts.map +1 -0
  18. package/dist/tools/banks.js +68 -0
  19. package/dist/tools/batch_orders.d.ts +77 -0
  20. package/dist/tools/batch_orders.d.ts.map +1 -0
  21. package/dist/tools/batch_orders.js +154 -0
  22. package/dist/tools/cancel_all_orders.d.ts +34 -0
  23. package/dist/tools/cancel_all_orders.d.ts.map +1 -0
  24. package/dist/tools/cancel_all_orders.js +89 -0
  25. package/dist/tools/cancel_order_by_client_id.d.ts +34 -0
  26. package/dist/tools/cancel_order_by_client_id.d.ts.map +1 -0
  27. package/dist/tools/cancel_order_by_client_id.js +102 -0
  28. package/dist/tools/deposits.d.ts +83 -0
  29. package/dist/tools/deposits.d.ts.map +1 -0
  30. package/dist/tools/deposits.js +174 -0
  31. package/dist/tools/fees.d.ts +34 -0
  32. package/dist/tools/fees.d.ts.map +1 -0
  33. package/dist/tools/fees.js +72 -0
  34. package/dist/tools/lightning.d.ts +68 -0
  35. package/dist/tools/lightning.d.ts.map +1 -0
  36. package/dist/tools/lightning.js +171 -0
  37. package/dist/tools/order_lookup.d.ts +50 -0
  38. package/dist/tools/order_lookup.d.ts.map +1 -0
  39. package/dist/tools/order_lookup.js +112 -0
  40. package/dist/tools/place_order.d.ts +30 -0
  41. package/dist/tools/place_order.d.ts.map +1 -1
  42. package/dist/tools/place_order.js +100 -2
  43. package/dist/tools/quotation.d.ts +44 -0
  44. package/dist/tools/quotation.d.ts.map +1 -0
  45. package/dist/tools/quotation.js +99 -0
  46. package/dist/tools/receive_addresses.d.ts +78 -0
  47. package/dist/tools/receive_addresses.d.ts.map +1 -0
  48. package/dist/tools/receive_addresses.js +161 -0
  49. package/dist/tools/remittance_recipients.d.ts +54 -0
  50. package/dist/tools/remittance_recipients.d.ts.map +1 -0
  51. package/dist/tools/remittance_recipients.js +106 -0
  52. package/dist/tools/remittances.d.ts +115 -0
  53. package/dist/tools/remittances.d.ts.map +1 -0
  54. package/dist/tools/remittances.js +237 -0
  55. package/dist/tools/simulate_order.d.ts.map +1 -1
  56. package/dist/tools/simulate_order.js +2 -1
  57. package/dist/tools/withdrawals.d.ts +93 -0
  58. package/dist/tools/withdrawals.d.ts.map +1 -0
  59. package/dist/tools/withdrawals.js +215 -0
  60. package/dist/types.d.ts +155 -0
  61. package/dist/types.d.ts.map +1 -1
  62. package/dist/validation.d.ts +5 -0
  63. package/dist/validation.d.ts.map +1 -1
  64. package/dist/validation.js +12 -0
  65. package/marketplace/README.md +1 -1
  66. package/marketplace/claude-listing.md +30 -2
  67. package/marketplace/gemini-tools.json +155 -1
  68. package/marketplace/openapi.yaml +1 -1
  69. package/package.json +1 -1
  70. package/server.json +2 -2
  71. package/src/cache.ts +1 -0
  72. package/src/client.ts +20 -0
  73. package/src/http.ts +55 -0
  74. package/src/index.ts +30 -0
  75. package/src/tools/account.ts +66 -0
  76. package/src/tools/balance.ts +94 -0
  77. package/src/tools/banks.ts +94 -0
  78. package/src/tools/batch_orders.ts +199 -0
  79. package/src/tools/cancel_all_orders.ts +117 -0
  80. package/src/tools/cancel_order_by_client_id.ts +132 -0
  81. package/src/tools/deposits.ts +230 -0
  82. package/src/tools/fees.ts +91 -0
  83. package/src/tools/lightning.ts +231 -0
  84. package/src/tools/order_lookup.ts +139 -0
  85. package/src/tools/place_order.ts +119 -2
  86. package/src/tools/quotation.ts +124 -0
  87. package/src/tools/receive_addresses.ts +216 -0
  88. package/src/tools/remittance_recipients.ts +139 -0
  89. package/src/tools/remittances.ts +299 -0
  90. package/src/tools/simulate_order.ts +1 -0
  91. package/src/tools/withdrawals.ts +276 -0
  92. package/src/types.ts +210 -0
  93. package/src/validation.ts +16 -0
  94. package/test/run-all.ts +16 -0
  95. package/test/unit.ts +1905 -0
@@ -0,0 +1,154 @@
1
+ import { z } from "zod";
2
+ import { BudaApiError } from "../client.js";
3
+ import { validateMarketId } from "../validation.js";
4
+ export const toolSchema = {
5
+ name: "place_batch_orders",
6
+ description: "Place multiple orders sequentially on Buda.com (up to 20). " +
7
+ "All orders are pre-validated before any API call — a validation failure stops execution with zero orders placed. " +
8
+ "Partial API failures do NOT roll back already-placed orders. " +
9
+ "IMPORTANT: Pass confirmation_token='CONFIRM' to execute. " +
10
+ "Requires BUDA_API_KEY and BUDA_API_SECRET.",
11
+ inputSchema: {
12
+ type: "object",
13
+ properties: {
14
+ orders: {
15
+ type: "array",
16
+ description: "Array of 1–20 orders to place.",
17
+ items: {
18
+ type: "object",
19
+ properties: {
20
+ market_id: { type: "string", description: "Market ID (e.g. 'BTC-CLP')." },
21
+ type: { type: "string", enum: ["Bid", "Ask"], description: "Order side." },
22
+ price_type: { type: "string", enum: ["limit", "market"], description: "Order type." },
23
+ amount: { type: "number", description: "Order size in base currency." },
24
+ limit_price: { type: "number", description: "Required when price_type is 'limit'." },
25
+ },
26
+ required: ["market_id", "type", "price_type", "amount"],
27
+ },
28
+ },
29
+ confirmation_token: {
30
+ type: "string",
31
+ description: "Safety confirmation. Must equal exactly 'CONFIRM' (case-sensitive) to execute.",
32
+ },
33
+ },
34
+ required: ["orders", "confirmation_token"],
35
+ },
36
+ };
37
+ const orderShape = z.object({
38
+ market_id: z.string(),
39
+ type: z.enum(["Bid", "Ask"]),
40
+ price_type: z.enum(["limit", "market"]),
41
+ amount: z.number().positive(),
42
+ limit_price: z.number().positive().optional(),
43
+ });
44
+ export async function handlePlaceBatchOrders(args, client) {
45
+ const { orders, confirmation_token } = args;
46
+ if (confirmation_token !== "CONFIRM") {
47
+ return {
48
+ content: [
49
+ {
50
+ type: "text",
51
+ text: JSON.stringify({
52
+ error: "Orders not placed. confirmation_token must equal 'CONFIRM' to execute. " +
53
+ "Review all orders and set confirmation_token='CONFIRM' to proceed.",
54
+ code: "CONFIRMATION_REQUIRED",
55
+ preview: { order_count: orders.length },
56
+ }),
57
+ },
58
+ ],
59
+ isError: true,
60
+ };
61
+ }
62
+ // Pre-validate ALL orders before any API call
63
+ for (let i = 0; i < orders.length; i++) {
64
+ const order = orders[i];
65
+ const marketError = validateMarketId(order.market_id);
66
+ if (marketError) {
67
+ return {
68
+ content: [
69
+ {
70
+ type: "text",
71
+ text: JSON.stringify({
72
+ error: `Order at index ${i}: ${marketError}`,
73
+ code: "INVALID_MARKET_ID",
74
+ index: i,
75
+ }),
76
+ },
77
+ ],
78
+ isError: true,
79
+ };
80
+ }
81
+ if (order.price_type === "limit" && order.limit_price === undefined) {
82
+ return {
83
+ content: [
84
+ {
85
+ type: "text",
86
+ text: JSON.stringify({
87
+ error: `Order at index ${i}: limit_price is required when price_type is 'limit'.`,
88
+ code: "VALIDATION_ERROR",
89
+ index: i,
90
+ }),
91
+ },
92
+ ],
93
+ isError: true,
94
+ };
95
+ }
96
+ }
97
+ // Execute sequentially
98
+ const results = [];
99
+ for (let i = 0; i < orders.length; i++) {
100
+ const order = orders[i];
101
+ try {
102
+ const payload = {
103
+ type: order.type,
104
+ price_type: order.price_type,
105
+ amount: order.amount,
106
+ };
107
+ if (order.price_type === "limit") {
108
+ payload.limit = { price: order.limit_price, type: "gtc" };
109
+ }
110
+ const data = await client.post(`/markets/${order.market_id.toLowerCase()}/orders`, payload);
111
+ results.push({ index: i, market_id: order.market_id, success: true, order: data.order });
112
+ }
113
+ catch (err) {
114
+ const errInfo = err instanceof BudaApiError
115
+ ? { error: err.message, code: err.status }
116
+ : { error: String(err), code: "UNKNOWN" };
117
+ results.push({
118
+ index: i,
119
+ market_id: order.market_id,
120
+ success: false,
121
+ error: errInfo.error,
122
+ code: errInfo.code,
123
+ });
124
+ }
125
+ }
126
+ const succeeded = results.filter((r) => r.success).length;
127
+ const failed = results.filter((r) => !r.success).length;
128
+ const response = {
129
+ results,
130
+ total: orders.length,
131
+ succeeded,
132
+ failed,
133
+ };
134
+ if (failed > 0 && succeeded > 0) {
135
+ response.warning = "Some orders failed. Already-placed orders were NOT rolled back.";
136
+ }
137
+ return {
138
+ content: [{ type: "text", text: JSON.stringify(response, null, 2) }],
139
+ isError: failed > 0 && succeeded === 0 ? true : undefined,
140
+ };
141
+ }
142
+ export function register(server, client) {
143
+ server.tool(toolSchema.name, toolSchema.description, {
144
+ orders: z
145
+ .array(orderShape)
146
+ .min(1)
147
+ .max(20)
148
+ .describe("Array of 1–20 orders to place."),
149
+ confirmation_token: z
150
+ .string()
151
+ .describe("Safety confirmation. Must equal exactly 'CONFIRM' (case-sensitive) to execute."),
152
+ }, (args) => handlePlaceBatchOrders(args, client));
153
+ }
154
+ //# sourceMappingURL=batch_orders.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
+ market_id: {
10
+ type: string;
11
+ description: string;
12
+ };
13
+ confirmation_token: {
14
+ type: string;
15
+ description: string;
16
+ };
17
+ };
18
+ required: string[];
19
+ };
20
+ };
21
+ type CancelAllOrdersArgs = {
22
+ market_id: string;
23
+ confirmation_token: string;
24
+ };
25
+ export declare function handleCancelAllOrders(args: CancelAllOrdersArgs, 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=cancel_all_orders.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cancel_all_orders.d.ts","sourceRoot":"","sources":["../../src/tools/cancel_all_orders.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEpE,OAAO,EAAE,UAAU,EAAgB,MAAM,cAAc,CAAC;AAIxD,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;CAuBtB,CAAC;AAEF,KAAK,mBAAmB,GAAG;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,kBAAkB,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF,wBAAsB,qBAAqB,CACzC,IAAI,EAAE,mBAAmB,EACzB,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,CAyDhF;AAED,wBAAgB,QAAQ,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,GAAG,IAAI,CAkBpE"}
@@ -0,0 +1,89 @@
1
+ import { z } from "zod";
2
+ import { BudaApiError } from "../client.js";
3
+ import { validateMarketId } from "../validation.js";
4
+ export const toolSchema = {
5
+ name: "cancel_all_orders",
6
+ description: "Cancel all open orders on Buda.com, optionally filtered by a specific market. " +
7
+ "Pass market_id='*' to cancel across all markets, or a specific market ID (e.g. 'BTC-CLP'). " +
8
+ "IMPORTANT: This action is irreversible. Pass confirmation_token='CONFIRM' to execute. " +
9
+ "Requires BUDA_API_KEY and BUDA_API_SECRET.",
10
+ inputSchema: {
11
+ type: "object",
12
+ properties: {
13
+ market_id: {
14
+ type: "string",
15
+ description: "Market ID (e.g. 'BTC-CLP') or '*' to cancel orders across all markets.",
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 canceling.",
21
+ },
22
+ },
23
+ required: ["market_id", "confirmation_token"],
24
+ },
25
+ };
26
+ export async function handleCancelAllOrders(args, client) {
27
+ const { market_id, confirmation_token } = args;
28
+ if (confirmation_token !== "CONFIRM") {
29
+ return {
30
+ content: [
31
+ {
32
+ type: "text",
33
+ text: JSON.stringify({
34
+ error: "Orders not canceled. confirmation_token must equal 'CONFIRM' to execute. " +
35
+ "Review and set confirmation_token='CONFIRM' to proceed.",
36
+ code: "CONFIRMATION_REQUIRED",
37
+ preview: { market_id },
38
+ }),
39
+ },
40
+ ],
41
+ isError: true,
42
+ };
43
+ }
44
+ if (market_id !== "*") {
45
+ const validationError = validateMarketId(market_id);
46
+ if (validationError) {
47
+ return {
48
+ content: [
49
+ { type: "text", text: JSON.stringify({ error: validationError, code: "INVALID_MARKET_ID" }) },
50
+ ],
51
+ isError: true,
52
+ };
53
+ }
54
+ }
55
+ try {
56
+ const params = market_id !== "*" ? { market_id: market_id.toLowerCase() } : undefined;
57
+ const data = await client.delete(`/orders`, params);
58
+ return {
59
+ content: [
60
+ {
61
+ type: "text",
62
+ text: JSON.stringify({ canceled_count: data.canceled_count, market_id }),
63
+ },
64
+ ],
65
+ };
66
+ }
67
+ catch (err) {
68
+ const msg = err instanceof BudaApiError
69
+ ? { error: err.message, code: err.status, path: err.path }
70
+ : { error: String(err), code: "UNKNOWN" };
71
+ return {
72
+ content: [{ type: "text", text: JSON.stringify(msg) }],
73
+ isError: true,
74
+ };
75
+ }
76
+ }
77
+ export function register(server, client) {
78
+ server.tool(toolSchema.name, toolSchema.description, {
79
+ market_id: z
80
+ .string()
81
+ .min(1)
82
+ .describe("Market ID (e.g. 'BTC-CLP') or '*' to cancel orders across all markets."),
83
+ confirmation_token: z
84
+ .string()
85
+ .describe("Safety confirmation. Must equal exactly 'CONFIRM' (case-sensitive) to execute. " +
86
+ "Any other value will reject the request without canceling."),
87
+ }, (args) => handleCancelAllOrders(args, client));
88
+ }
89
+ //# sourceMappingURL=cancel_all_orders.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
+ client_id: {
10
+ type: string;
11
+ description: string;
12
+ };
13
+ confirmation_token: {
14
+ type: string;
15
+ description: string;
16
+ };
17
+ };
18
+ required: string[];
19
+ };
20
+ };
21
+ type CancelOrderByClientIdArgs = {
22
+ client_id: string;
23
+ confirmation_token: string;
24
+ };
25
+ export declare function handleCancelOrderByClientId(args: CancelOrderByClientIdArgs, 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=cancel_order_by_client_id.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cancel_order_by_client_id.d.ts","sourceRoot":"","sources":["../../src/tools/cancel_order_by_client_id.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEpE,OAAO,EAAE,UAAU,EAAgB,MAAM,cAAc,CAAC;AAIxD,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;CAsBtB,CAAC;AAEF,KAAK,yBAAyB,GAAG;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,kBAAkB,EAAE,MAAM,CAAC;CAC5B,CAAC;AAmCF,wBAAsB,2BAA2B,CAC/C,IAAI,EAAE,yBAAyB,EAC/B,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,CAwChF;AAED,wBAAgB,QAAQ,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,GAAG,IAAI,CAkBpE"}
@@ -0,0 +1,102 @@
1
+ import { z } from "zod";
2
+ import { BudaApiError } from "../client.js";
3
+ import { flattenAmount } from "../utils.js";
4
+ export const toolSchema = {
5
+ name: "cancel_order_by_client_id",
6
+ description: "Cancel an open order by its client-assigned ID on Buda.com. " +
7
+ "IMPORTANT: Pass confirmation_token='CONFIRM' to execute. " +
8
+ "Requires BUDA_API_KEY and BUDA_API_SECRET.",
9
+ inputSchema: {
10
+ type: "object",
11
+ properties: {
12
+ client_id: {
13
+ type: "string",
14
+ description: "The client ID string assigned when placing the order.",
15
+ },
16
+ confirmation_token: {
17
+ type: "string",
18
+ description: "Safety confirmation. Must equal exactly 'CONFIRM' (case-sensitive) to execute. " +
19
+ "Any other value will reject the request without canceling.",
20
+ },
21
+ },
22
+ required: ["client_id", "confirmation_token"],
23
+ },
24
+ };
25
+ function normalizeOrder(o) {
26
+ const amount = flattenAmount(o.amount);
27
+ const originalAmount = flattenAmount(o.original_amount);
28
+ const tradedAmount = flattenAmount(o.traded_amount);
29
+ const totalExchanged = flattenAmount(o.total_exchanged);
30
+ const paidFee = flattenAmount(o.paid_fee);
31
+ const limitPrice = o.limit ? flattenAmount(o.limit) : null;
32
+ return {
33
+ id: o.id,
34
+ type: o.type,
35
+ state: o.state,
36
+ created_at: o.created_at,
37
+ market_id: o.market_id,
38
+ fee_currency: o.fee_currency,
39
+ price_type: o.price_type,
40
+ order_type: o.order_type,
41
+ client_id: o.client_id,
42
+ limit_price: limitPrice ? limitPrice.value : null,
43
+ limit_price_currency: limitPrice ? limitPrice.currency : null,
44
+ amount: amount.value,
45
+ amount_currency: amount.currency,
46
+ original_amount: originalAmount.value,
47
+ original_amount_currency: originalAmount.currency,
48
+ traded_amount: tradedAmount.value,
49
+ traded_amount_currency: tradedAmount.currency,
50
+ total_exchanged: totalExchanged.value,
51
+ total_exchanged_currency: totalExchanged.currency,
52
+ paid_fee: paidFee.value,
53
+ paid_fee_currency: paidFee.currency,
54
+ };
55
+ }
56
+ export async function handleCancelOrderByClientId(args, client) {
57
+ const { client_id, confirmation_token } = args;
58
+ if (confirmation_token !== "CONFIRM") {
59
+ return {
60
+ content: [
61
+ {
62
+ type: "text",
63
+ text: JSON.stringify({
64
+ error: "Order not canceled. confirmation_token must equal 'CONFIRM' to execute. " +
65
+ "Verify the client ID and set confirmation_token='CONFIRM' to proceed.",
66
+ code: "CONFIRMATION_REQUIRED",
67
+ client_id,
68
+ }),
69
+ },
70
+ ],
71
+ isError: true,
72
+ };
73
+ }
74
+ try {
75
+ const data = await client.put(`/orders/by-client-id/${encodeURIComponent(client_id)}`, { order: { state: "canceling" } });
76
+ return {
77
+ content: [{ type: "text", text: JSON.stringify(normalizeOrder(data.order), null, 2) }],
78
+ };
79
+ }
80
+ catch (err) {
81
+ const msg = err instanceof BudaApiError
82
+ ? { error: err.message, code: err.status, path: err.path }
83
+ : { error: String(err), code: "UNKNOWN" };
84
+ return {
85
+ content: [{ type: "text", text: JSON.stringify(msg) }],
86
+ isError: true,
87
+ };
88
+ }
89
+ }
90
+ export function register(server, client) {
91
+ server.tool(toolSchema.name, toolSchema.description, {
92
+ client_id: z
93
+ .string()
94
+ .min(1)
95
+ .describe("The client ID string assigned when placing the order."),
96
+ confirmation_token: z
97
+ .string()
98
+ .describe("Safety confirmation. Must equal exactly 'CONFIRM' (case-sensitive) to execute. " +
99
+ "Any other value will reject the request without canceling."),
100
+ }, (args) => handleCancelOrderByClientId(args, client));
101
+ }
102
+ //# sourceMappingURL=cancel_order_by_client_id.js.map
@@ -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