@guiie/buda-mcp 1.1.2 → 1.2.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.
Files changed (77) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/PUBLISH.md +5 -5
  3. package/PUBLISH_CHECKLIST.md +59 -62
  4. package/README.md +3 -3
  5. package/dist/client.d.ts +15 -1
  6. package/dist/client.d.ts.map +1 -1
  7. package/dist/client.js +56 -52
  8. package/dist/http.js +30 -148
  9. package/dist/index.js +2 -1
  10. package/dist/tools/balances.d.ts +8 -0
  11. package/dist/tools/balances.d.ts.map +1 -1
  12. package/dist/tools/balances.js +11 -3
  13. package/dist/tools/cancel_order.d.ts +30 -0
  14. package/dist/tools/cancel_order.d.ts.map +1 -1
  15. package/dist/tools/cancel_order.js +59 -38
  16. package/dist/tools/compare_markets.d.ts +14 -0
  17. package/dist/tools/compare_markets.d.ts.map +1 -1
  18. package/dist/tools/compare_markets.js +17 -3
  19. package/dist/tools/markets.d.ts +13 -0
  20. package/dist/tools/markets.d.ts.map +1 -1
  21. package/dist/tools/markets.js +23 -2
  22. package/dist/tools/orderbook.d.ts +18 -0
  23. package/dist/tools/orderbook.d.ts.map +1 -1
  24. package/dist/tools/orderbook.js +28 -2
  25. package/dist/tools/orders.d.ts +26 -0
  26. package/dist/tools/orders.d.ts.map +1 -1
  27. package/dist/tools/orders.js +36 -2
  28. package/dist/tools/place_order.d.ts +50 -0
  29. package/dist/tools/place_order.d.ts.map +1 -1
  30. package/dist/tools/place_order.js +104 -58
  31. package/dist/tools/price_history.d.ts +22 -0
  32. package/dist/tools/price_history.d.ts.map +1 -1
  33. package/dist/tools/price_history.js +42 -7
  34. package/dist/tools/spread.d.ts +14 -0
  35. package/dist/tools/spread.d.ts.map +1 -1
  36. package/dist/tools/spread.js +24 -2
  37. package/dist/tools/ticker.d.ts +14 -0
  38. package/dist/tools/ticker.d.ts.map +1 -1
  39. package/dist/tools/ticker.js +24 -2
  40. package/dist/tools/trades.d.ts +22 -0
  41. package/dist/tools/trades.d.ts.map +1 -1
  42. package/dist/tools/trades.js +32 -2
  43. package/dist/tools/volume.d.ts +14 -0
  44. package/dist/tools/volume.d.ts.map +1 -1
  45. package/dist/tools/volume.js +24 -2
  46. package/dist/validation.d.ts +6 -0
  47. package/dist/validation.d.ts.map +1 -0
  48. package/dist/validation.js +14 -0
  49. package/dist/version.d.ts +2 -0
  50. package/dist/version.d.ts.map +1 -0
  51. package/dist/version.js +6 -0
  52. package/marketplace/README.md +1 -1
  53. package/marketplace/claude-listing.md +2 -2
  54. package/marketplace/gemini-tools.json +3 -3
  55. package/marketplace/openapi.yaml +7 -6
  56. package/package.json +5 -2
  57. package/scripts/sync-version.mjs +19 -0
  58. package/server.json +2 -2
  59. package/src/client.ts +77 -53
  60. package/src/http.ts +32 -150
  61. package/src/index.ts +2 -1
  62. package/src/tools/balances.ts +14 -4
  63. package/src/tools/cancel_order.ts +77 -43
  64. package/src/tools/compare_markets.ts +21 -4
  65. package/src/tools/markets.ts +27 -3
  66. package/src/tools/orderbook.ts +32 -3
  67. package/src/tools/orders.ts +41 -3
  68. package/src/tools/place_order.ts +134 -69
  69. package/src/tools/price_history.ts +50 -8
  70. package/src/tools/spread.ts +28 -3
  71. package/src/tools/ticker.ts +28 -3
  72. package/src/tools/trades.ts +37 -3
  73. package/src/tools/volume.ts +28 -3
  74. package/src/validation.ts +16 -0
  75. package/src/version.ts +8 -0
  76. package/test/run-all.ts +13 -1
  77. package/test/unit.ts +414 -0
package/dist/http.js CHANGED
@@ -3,6 +3,7 @@ import { McpServer, ResourceTemplate } from "@modelcontextprotocol/sdk/server/mc
3
3
  import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
4
4
  import { BudaClient } from "./client.js";
5
5
  import { MemoryCache, CACHE_TTL } from "./cache.js";
6
+ import { VERSION } from "./version.js";
6
7
  import * as markets from "./tools/markets.js";
7
8
  import * as ticker from "./tools/ticker.js";
8
9
  import * as orderbook from "./tools/orderbook.js";
@@ -18,8 +19,26 @@ import * as cancelOrder from "./tools/cancel_order.js";
18
19
  const PORT = parseInt(process.env.PORT ?? "3000", 10);
19
20
  const client = new BudaClient(undefined, process.env.BUDA_API_KEY, process.env.BUDA_API_SECRET);
20
21
  const authEnabled = client.hasAuth();
22
+ // Schemas for the Smithery server-card — assembled from the same definitions used in register().
23
+ // Adding a new tool only requires exporting its toolSchema; no changes needed here.
24
+ const PUBLIC_TOOL_SCHEMAS = [
25
+ markets.toolSchema,
26
+ ticker.toolSchema,
27
+ orderbook.toolSchema,
28
+ trades.toolSchema,
29
+ volume.toolSchema,
30
+ spread.toolSchema,
31
+ compareMarkets.toolSchema,
32
+ priceHistory.toolSchema,
33
+ ];
34
+ const AUTH_TOOL_SCHEMAS = [
35
+ balances.toolSchema,
36
+ orders.toolSchema,
37
+ placeOrder.toolSchema,
38
+ cancelOrder.toolSchema,
39
+ ];
21
40
  function createServer() {
22
- const server = new McpServer({ name: "buda-mcp", version: "1.1.2" });
41
+ const server = new McpServer({ name: "buda-mcp", version: VERSION });
23
42
  // Per-request cache so caching works correctly for stateless HTTP
24
43
  const reqCache = new MemoryCache();
25
44
  markets.register(server, client, reqCache);
@@ -68,157 +87,20 @@ const app = express();
68
87
  app.use(express.json());
69
88
  // Health check for Railway / uptime monitors
70
89
  app.get("/health", (_req, res) => {
71
- res.json({ status: "ok", server: "buda-mcp", version: "1.1.2", auth_mode: authEnabled ? "authenticated" : "public" });
90
+ res.json({
91
+ status: "ok",
92
+ server: "buda-mcp",
93
+ version: VERSION,
94
+ auth_mode: authEnabled ? "authenticated" : "public",
95
+ });
72
96
  });
73
- // Smithery static server card — lets Smithery scan tools without running the server
97
+ // Smithery static server card — assembled programmatically from tool definitions.
98
+ // Adding a new tool only requires exporting its toolSchema; this handler needs no changes.
74
99
  app.get("/.well-known/mcp/server-card.json", (_req, res) => {
75
- const publicTools = [
76
- {
77
- name: "get_markets",
78
- description: "List all available trading pairs on Buda.com, or get details for a specific market.",
79
- inputSchema: {
80
- type: "object",
81
- properties: {
82
- market_id: { type: "string", description: "Optional market ID (e.g. BTC-CLP)" },
83
- },
84
- },
85
- },
86
- {
87
- name: "get_ticker",
88
- description: "Get current price, bid/ask, volume, and price change for a Buda.com market.",
89
- inputSchema: {
90
- type: "object",
91
- properties: {
92
- market_id: { type: "string", description: "Market ID (e.g. BTC-CLP)" },
93
- },
94
- required: ["market_id"],
95
- },
96
- },
97
- {
98
- name: "get_orderbook",
99
- description: "Get the full order book (bids and asks) for a Buda.com market.",
100
- inputSchema: {
101
- type: "object",
102
- properties: {
103
- market_id: { type: "string", description: "Market ID (e.g. BTC-CLP)" },
104
- limit: { type: "number", description: "Max levels per side" },
105
- },
106
- required: ["market_id"],
107
- },
108
- },
109
- {
110
- name: "get_trades",
111
- description: "Get recent trade history for a Buda.com market.",
112
- inputSchema: {
113
- type: "object",
114
- properties: {
115
- market_id: { type: "string", description: "Market ID (e.g. BTC-CLP)" },
116
- limit: { type: "number", description: "Number of trades (max 100)" },
117
- timestamp: { type: "number", description: "Unix timestamp for pagination" },
118
- },
119
- required: ["market_id"],
120
- },
121
- },
122
- {
123
- name: "get_market_volume",
124
- description: "Get 24h and 7-day transacted volume for a Buda.com market.",
125
- inputSchema: {
126
- type: "object",
127
- properties: {
128
- market_id: { type: "string", description: "Market ID (e.g. BTC-CLP)" },
129
- },
130
- required: ["market_id"],
131
- },
132
- },
133
- {
134
- name: "get_spread",
135
- description: "Calculate bid/ask spread (absolute and percentage) for a Buda.com market.",
136
- inputSchema: {
137
- type: "object",
138
- properties: {
139
- market_id: { type: "string", description: "Market ID (e.g. BTC-CLP)" },
140
- },
141
- required: ["market_id"],
142
- },
143
- },
144
- {
145
- name: "compare_markets",
146
- description: "Compare ticker data for all trading pairs of a given base currency side by side.",
147
- inputSchema: {
148
- type: "object",
149
- properties: {
150
- base_currency: { type: "string", description: "Base currency (e.g. BTC, ETH)" },
151
- },
152
- required: ["base_currency"],
153
- },
154
- },
155
- {
156
- name: "get_price_history",
157
- description: "Get OHLCV price history for a market, derived from recent trade history.",
158
- inputSchema: {
159
- type: "object",
160
- properties: {
161
- market_id: { type: "string", description: "Market ID (e.g. BTC-CLP)" },
162
- period: { type: "string", enum: ["1h", "4h", "1d"], description: "Candle period" },
163
- limit: { type: "number", description: "Raw trades to fetch (max 100)" },
164
- },
165
- required: ["market_id"],
166
- },
167
- },
168
- ];
169
- const authTools = authEnabled
170
- ? [
171
- {
172
- name: "get_balances",
173
- description: "Get all currency balances for the authenticated account.",
174
- inputSchema: { type: "object", properties: {} },
175
- },
176
- {
177
- name: "get_orders",
178
- description: "Get orders for a given market.",
179
- inputSchema: {
180
- type: "object",
181
- properties: {
182
- market_id: { type: "string" },
183
- state: { type: "string" },
184
- },
185
- required: ["market_id"],
186
- },
187
- },
188
- {
189
- name: "place_order",
190
- description: "Place a limit or market order. Requires confirmation_token='CONFIRM'.",
191
- inputSchema: {
192
- type: "object",
193
- properties: {
194
- market_id: { type: "string" },
195
- type: { type: "string", enum: ["Bid", "Ask"] },
196
- price_type: { type: "string", enum: ["limit", "market"] },
197
- amount: { type: "number" },
198
- limit_price: { type: "number" },
199
- confirmation_token: { type: "string" },
200
- },
201
- required: ["market_id", "type", "price_type", "amount", "confirmation_token"],
202
- },
203
- },
204
- {
205
- name: "cancel_order",
206
- description: "Cancel an order by ID. Requires confirmation_token='CONFIRM'.",
207
- inputSchema: {
208
- type: "object",
209
- properties: {
210
- order_id: { type: "number" },
211
- confirmation_token: { type: "string" },
212
- },
213
- required: ["order_id", "confirmation_token"],
214
- },
215
- },
216
- ]
217
- : [];
218
100
  res.json({
219
- serverInfo: { name: "buda-mcp", version: "1.1.2" },
101
+ serverInfo: { name: "buda-mcp", version: VERSION },
220
102
  authentication: { required: authEnabled },
221
- tools: [...publicTools, ...authTools],
103
+ tools: [...PUBLIC_TOOL_SCHEMAS, ...(authEnabled ? AUTH_TOOL_SCHEMAS : [])],
222
104
  resources: [
223
105
  { uri: "buda://markets", name: "All Buda.com markets", mimeType: "application/json" },
224
106
  { uri: "buda://ticker/{market}", name: "Ticker for a specific market", mimeType: "application/json" },
package/dist/index.js CHANGED
@@ -3,6 +3,7 @@ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"
3
3
  import { ResourceTemplate } from "@modelcontextprotocol/sdk/server/mcp.js";
4
4
  import { BudaClient } from "./client.js";
5
5
  import { cache, CACHE_TTL } from "./cache.js";
6
+ import { VERSION } from "./version.js";
6
7
  import * as markets from "./tools/markets.js";
7
8
  import * as ticker from "./tools/ticker.js";
8
9
  import * as orderbook from "./tools/orderbook.js";
@@ -18,7 +19,7 @@ import * as cancelOrder from "./tools/cancel_order.js";
18
19
  const client = new BudaClient(undefined, process.env.BUDA_API_KEY, process.env.BUDA_API_SECRET);
19
20
  const server = new McpServer({
20
21
  name: "buda-mcp",
21
- version: "1.1.2",
22
+ version: VERSION,
22
23
  });
23
24
  // Public tools
24
25
  markets.register(server, client, cache);
@@ -1,4 +1,12 @@
1
1
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
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
+ };
10
+ };
3
11
  export declare function register(server: McpServer, client: BudaClient): void;
4
12
  //# sourceMappingURL=balances.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"balances.d.ts","sourceRoot":"","sources":["../../src/tools/balances.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,UAAU,EAAgB,MAAM,cAAc,CAAC;AAGxD,wBAAgB,QAAQ,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,GAAG,IAAI,CAyBpE"}
1
+ {"version":3,"file":"balances.d.ts","sourceRoot":"","sources":["../../src/tools/balances.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,UAAU,EAAgB,MAAM,cAAc,CAAC;AAGxD,eAAO,MAAM,UAAU;;;;;;;CAUtB,CAAC;AAEF,wBAAgB,QAAQ,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,GAAG,IAAI,CAuBpE"}
@@ -1,8 +1,16 @@
1
1
  import { BudaApiError } from "../client.js";
2
- export function register(server, client) {
3
- server.tool("get_balances", "Get all currency balances for the authenticated Buda.com account. " +
2
+ export const toolSchema = {
3
+ name: "get_balances",
4
+ description: "Get all currency balances for the authenticated Buda.com account. " +
4
5
  "Returns total, available, frozen, and pending withdrawal amounts per currency. " +
5
- "Requires BUDA_API_KEY and BUDA_API_SECRET environment variables.", {}, async () => {
6
+ "Requires BUDA_API_KEY and BUDA_API_SECRET environment variables.",
7
+ inputSchema: {
8
+ type: "object",
9
+ properties: {},
10
+ },
11
+ };
12
+ export function register(server, client) {
13
+ server.tool(toolSchema.name, toolSchema.description, {}, async () => {
6
14
  try {
7
15
  const data = await client.get("/balances");
8
16
  return {
@@ -1,4 +1,34 @@
1
1
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
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
+ order_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 CancelOrderArgs = {
22
+ order_id: number;
23
+ confirmation_token: string;
24
+ };
25
+ export declare function handleCancelOrder(args: CancelOrderArgs, client: BudaClient): Promise<{
26
+ content: Array<{
27
+ type: "text";
28
+ text: string;
29
+ }>;
30
+ isError?: boolean;
31
+ }>;
3
32
  export declare function register(server: McpServer, client: BudaClient): void;
33
+ export {};
4
34
  //# sourceMappingURL=cancel_order.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"cancel_order.d.ts","sourceRoot":"","sources":["../../src/tools/cancel_order.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEpE,OAAO,EAAE,UAAU,EAAgB,MAAM,cAAc,CAAC;AAGxD,wBAAgB,QAAQ,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,GAAG,IAAI,CA2DpE"}
1
+ {"version":3,"file":"cancel_order.d.ts","sourceRoot":"","sources":["../../src/tools/cancel_order.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEpE,OAAO,EAAE,UAAU,EAAgB,MAAM,cAAc,CAAC;AAGxD,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;CAuBtB,CAAC;AAEF,KAAK,eAAe,GAAG;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,kBAAkB,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF,wBAAsB,iBAAiB,CACrC,IAAI,EAAE,eAAe,EACrB,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,CAuChF;AAED,wBAAgB,QAAQ,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,GAAG,IAAI,CAmBpE"}
@@ -1,10 +1,65 @@
1
1
  import { z } from "zod";
2
2
  import { BudaApiError } from "../client.js";
3
- export function register(server, client) {
4
- server.tool("cancel_order", "Cancel an open order by ID on Buda.com. " +
3
+ export const toolSchema = {
4
+ name: "cancel_order",
5
+ description: "Cancel an open order by ID on Buda.com. " +
5
6
  "IMPORTANT: To prevent accidental cancellation from ambiguous prompts, you must pass " +
6
7
  "confirmation_token='CONFIRM' to execute. " +
7
- "Requires BUDA_API_KEY and BUDA_API_SECRET environment variables.", {
8
+ "Requires BUDA_API_KEY and BUDA_API_SECRET environment variables.",
9
+ inputSchema: {
10
+ type: "object",
11
+ properties: {
12
+ order_id: {
13
+ type: "number",
14
+ description: "The numeric ID of the order to cancel.",
15
+ },
16
+ confirmation_token: {
17
+ type: "string",
18
+ description: "Safety confirmation. Must equal exactly 'CONFIRM' (case-sensitive) to cancel the order. " +
19
+ "Any other value will reject the request without canceling.",
20
+ },
21
+ },
22
+ required: ["order_id", "confirmation_token"],
23
+ },
24
+ };
25
+ export async function handleCancelOrder(args, client) {
26
+ const { order_id, confirmation_token } = args;
27
+ if (confirmation_token !== "CONFIRM") {
28
+ return {
29
+ content: [
30
+ {
31
+ type: "text",
32
+ text: JSON.stringify({
33
+ error: "Order not canceled. confirmation_token must equal 'CONFIRM' to execute. " +
34
+ "Verify the order ID and set confirmation_token='CONFIRM' to proceed.",
35
+ code: "CONFIRMATION_REQUIRED",
36
+ order_id,
37
+ }),
38
+ },
39
+ ],
40
+ isError: true,
41
+ };
42
+ }
43
+ try {
44
+ const data = await client.put(`/orders/${order_id}`, {
45
+ state: "canceling",
46
+ });
47
+ return {
48
+ content: [{ type: "text", text: JSON.stringify(data.order, null, 2) }],
49
+ };
50
+ }
51
+ catch (err) {
52
+ const msg = err instanceof BudaApiError
53
+ ? { error: err.message, code: err.status, path: err.path }
54
+ : { error: String(err), code: "UNKNOWN" };
55
+ return {
56
+ content: [{ type: "text", text: JSON.stringify(msg) }],
57
+ isError: true,
58
+ };
59
+ }
60
+ }
61
+ export function register(server, client) {
62
+ server.tool(toolSchema.name, toolSchema.description, {
8
63
  order_id: z
9
64
  .number()
10
65
  .int()
@@ -14,40 +69,6 @@ export function register(server, client) {
14
69
  .string()
15
70
  .describe("Safety confirmation. Must equal exactly 'CONFIRM' (case-sensitive) to cancel the order. " +
16
71
  "Any other value will reject the request without canceling."),
17
- }, async ({ order_id, confirmation_token }) => {
18
- if (confirmation_token !== "CONFIRM") {
19
- return {
20
- content: [
21
- {
22
- type: "text",
23
- text: JSON.stringify({
24
- error: "Order not canceled. confirmation_token must equal 'CONFIRM' to execute. " +
25
- "Verify the order ID and set confirmation_token='CONFIRM' to proceed.",
26
- code: "CONFIRMATION_REQUIRED",
27
- order_id,
28
- }),
29
- },
30
- ],
31
- isError: true,
32
- };
33
- }
34
- try {
35
- const data = await client.put(`/orders/${order_id}`, {
36
- state: "canceling",
37
- });
38
- return {
39
- content: [{ type: "text", text: JSON.stringify(data.order, null, 2) }],
40
- };
41
- }
42
- catch (err) {
43
- const msg = err instanceof BudaApiError
44
- ? { error: err.message, code: err.status, path: err.path }
45
- : { error: String(err), code: "UNKNOWN" };
46
- return {
47
- content: [{ type: "text", text: JSON.stringify(msg) }],
48
- isError: true,
49
- };
50
- }
51
- });
72
+ }, (args) => handleCancelOrder(args, client));
52
73
  }
53
74
  //# sourceMappingURL=cancel_order.js.map
@@ -1,5 +1,19 @@
1
1
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
2
  import { BudaClient } from "../client.js";
3
3
  import { MemoryCache } from "../cache.js";
4
+ export declare const toolSchema: {
5
+ name: string;
6
+ description: string;
7
+ inputSchema: {
8
+ type: "object";
9
+ properties: {
10
+ base_currency: {
11
+ type: string;
12
+ description: string;
13
+ };
14
+ };
15
+ required: string[];
16
+ };
17
+ };
4
18
  export declare function register(server: McpServer, client: BudaClient, cache: MemoryCache): void;
5
19
  //# sourceMappingURL=compare_markets.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"compare_markets.d.ts","sourceRoot":"","sources":["../../src/tools/compare_markets.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEpE,OAAO,EAAE,UAAU,EAAgB,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,WAAW,EAAa,MAAM,aAAa,CAAC;AAGrD,wBAAgB,QAAQ,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,WAAW,GAAG,IAAI,CA2ExF"}
1
+ {"version":3,"file":"compare_markets.d.ts","sourceRoot":"","sources":["../../src/tools/compare_markets.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEpE,OAAO,EAAE,UAAU,EAAgB,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,WAAW,EAAa,MAAM,aAAa,CAAC;AAGrD,eAAO,MAAM,UAAU;;;;;;;;;;;;;CAiBtB,CAAC;AAEF,wBAAgB,QAAQ,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,WAAW,GAAG,IAAI,CAyExF"}
@@ -1,10 +1,24 @@
1
1
  import { z } from "zod";
2
2
  import { BudaApiError } from "../client.js";
3
3
  import { CACHE_TTL } from "../cache.js";
4
- export function register(server, client, cache) {
5
- server.tool("compare_markets", "Compare ticker data for all trading pairs of a given base currency across Buda.com's " +
4
+ export const toolSchema = {
5
+ name: "compare_markets",
6
+ description: "Compare ticker data for all trading pairs of a given base currency across Buda.com's " +
6
7
  "supported quote currencies (CLP, COP, PEN, BTC, USDC, ETH). " +
7
- "For example, passing 'BTC' returns side-by-side data for BTC-CLP, BTC-COP, BTC-PEN, etc.", {
8
+ "For example, passing 'BTC' returns side-by-side data for BTC-CLP, BTC-COP, BTC-PEN, etc.",
9
+ inputSchema: {
10
+ type: "object",
11
+ properties: {
12
+ base_currency: {
13
+ type: "string",
14
+ description: "Base currency to compare across all available markets (e.g. 'BTC', 'ETH', 'XRP').",
15
+ },
16
+ },
17
+ required: ["base_currency"],
18
+ },
19
+ };
20
+ export function register(server, client, cache) {
21
+ server.tool(toolSchema.name, toolSchema.description, {
8
22
  base_currency: z
9
23
  .string()
10
24
  .describe("Base currency to compare across all available markets (e.g. 'BTC', 'ETH', 'XRP')."),
@@ -1,5 +1,18 @@
1
1
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
2
  import { BudaClient } from "../client.js";
3
3
  import { MemoryCache } from "../cache.js";
4
+ export declare const toolSchema: {
5
+ name: string;
6
+ description: string;
7
+ inputSchema: {
8
+ type: "object";
9
+ properties: {
10
+ market_id: {
11
+ type: string;
12
+ description: string;
13
+ };
14
+ };
15
+ };
16
+ };
4
17
  export declare function register(server: McpServer, client: BudaClient, cache: MemoryCache): void;
5
18
  //# sourceMappingURL=markets.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"markets.d.ts","sourceRoot":"","sources":["../../src/tools/markets.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEpE,OAAO,EAAE,UAAU,EAAgB,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,WAAW,EAAa,MAAM,aAAa,CAAC;AAGrD,wBAAgB,QAAQ,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,WAAW,GAAG,IAAI,CA+CxF"}
1
+ {"version":3,"file":"markets.d.ts","sourceRoot":"","sources":["../../src/tools/markets.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEpE,OAAO,EAAE,UAAU,EAAgB,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,WAAW,EAAa,MAAM,aAAa,CAAC;AAIrD,eAAO,MAAM,UAAU;;;;;;;;;;;;CActB,CAAC;AAEF,wBAAgB,QAAQ,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,WAAW,GAAG,IAAI,CAsDxF"}
@@ -1,9 +1,23 @@
1
1
  import { z } from "zod";
2
2
  import { BudaApiError } from "../client.js";
3
3
  import { CACHE_TTL } from "../cache.js";
4
+ import { validateMarketId } from "../validation.js";
5
+ export const toolSchema = {
6
+ name: "get_markets",
7
+ description: "List all available trading pairs on Buda.com, or get details for a specific market. " +
8
+ "Returns base/quote currencies, fees, and minimum order sizes.",
9
+ inputSchema: {
10
+ type: "object",
11
+ properties: {
12
+ market_id: {
13
+ type: "string",
14
+ description: "Optional market ID (e.g. 'BTC-CLP', 'ETH-BTC'). Omit to list all markets.",
15
+ },
16
+ },
17
+ },
18
+ };
4
19
  export function register(server, client, cache) {
5
- server.tool("get_markets", "List all available trading pairs on Buda.com, or get details for a specific market. " +
6
- "Returns base/quote currencies, fees, and minimum order sizes.", {
20
+ server.tool(toolSchema.name, toolSchema.description, {
7
21
  market_id: z
8
22
  .string()
9
23
  .optional()
@@ -11,6 +25,13 @@ export function register(server, client, cache) {
11
25
  }, async ({ market_id }) => {
12
26
  try {
13
27
  if (market_id) {
28
+ const validationError = validateMarketId(market_id);
29
+ if (validationError) {
30
+ return {
31
+ content: [{ type: "text", text: JSON.stringify({ error: validationError, code: "INVALID_MARKET_ID" }) }],
32
+ isError: true,
33
+ };
34
+ }
14
35
  const id = market_id.toLowerCase();
15
36
  const data = await cache.getOrFetch(`market:${id}`, CACHE_TTL.MARKETS, () => client.get(`/markets/${id}`));
16
37
  return {
@@ -1,5 +1,23 @@
1
1
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
2
  import { BudaClient } from "../client.js";
3
3
  import { MemoryCache } from "../cache.js";
4
+ export declare const toolSchema: {
5
+ name: string;
6
+ description: string;
7
+ inputSchema: {
8
+ type: "object";
9
+ properties: {
10
+ market_id: {
11
+ type: string;
12
+ description: string;
13
+ };
14
+ limit: {
15
+ type: string;
16
+ description: string;
17
+ };
18
+ };
19
+ required: string[];
20
+ };
21
+ };
4
22
  export declare function register(server: McpServer, client: BudaClient, cache: MemoryCache): void;
5
23
  //# sourceMappingURL=orderbook.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"orderbook.d.ts","sourceRoot":"","sources":["../../src/tools/orderbook.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEpE,OAAO,EAAE,UAAU,EAAgB,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,WAAW,EAAa,MAAM,aAAa,CAAC;AAGrD,wBAAgB,QAAQ,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,WAAW,GAAG,IAAI,CAgDxF"}
1
+ {"version":3,"file":"orderbook.d.ts","sourceRoot":"","sources":["../../src/tools/orderbook.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEpE,OAAO,EAAE,UAAU,EAAgB,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,WAAW,EAAa,MAAM,aAAa,CAAC;AAIrD,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;CAmBtB,CAAC;AAEF,wBAAgB,QAAQ,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,WAAW,GAAG,IAAI,CAuDxF"}
@@ -1,9 +1,28 @@
1
1
  import { z } from "zod";
2
2
  import { BudaApiError } from "../client.js";
3
3
  import { CACHE_TTL } from "../cache.js";
4
+ import { validateMarketId } from "../validation.js";
5
+ export const toolSchema = {
6
+ name: "get_orderbook",
7
+ description: "Get the current order book (bids and asks) for a Buda.com market. Returns sorted arrays of " +
8
+ "bids (buy orders) and asks (sell orders), each as [price, amount] pairs.",
9
+ inputSchema: {
10
+ type: "object",
11
+ properties: {
12
+ market_id: {
13
+ type: "string",
14
+ description: "Market ID (e.g. 'BTC-CLP', 'ETH-BTC').",
15
+ },
16
+ limit: {
17
+ type: "number",
18
+ description: "Maximum number of levels to return per side (default: all).",
19
+ },
20
+ },
21
+ required: ["market_id"],
22
+ },
23
+ };
4
24
  export function register(server, client, cache) {
5
- server.tool("get_orderbook", "Get the current order book (bids and asks) for a Buda.com market. Returns sorted arrays of " +
6
- "bids (buy orders) and asks (sell orders), each as [price, amount] pairs.", {
25
+ server.tool(toolSchema.name, toolSchema.description, {
7
26
  market_id: z
8
27
  .string()
9
28
  .describe("Market ID (e.g. 'BTC-CLP', 'ETH-BTC')."),
@@ -15,6 +34,13 @@ export function register(server, client, cache) {
15
34
  .describe("Maximum number of levels to return per side (default: all)."),
16
35
  }, async ({ market_id, limit }) => {
17
36
  try {
37
+ const validationError = validateMarketId(market_id);
38
+ if (validationError) {
39
+ return {
40
+ content: [{ type: "text", text: JSON.stringify({ error: validationError, code: "INVALID_MARKET_ID" }) }],
41
+ isError: true,
42
+ };
43
+ }
18
44
  const id = market_id.toLowerCase();
19
45
  const data = await cache.getOrFetch(`orderbook:${id}`, CACHE_TTL.ORDERBOOK, () => client.get(`/markets/${id}/order_book`));
20
46
  const book = data.order_book;
@@ -1,4 +1,30 @@
1
1
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
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
+ 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
+ };
3
29
  export declare function register(server: McpServer, client: BudaClient): void;
4
30
  //# sourceMappingURL=orders.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"orders.d.ts","sourceRoot":"","sources":["../../src/tools/orders.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEpE,OAAO,EAAE,UAAU,EAAgB,MAAM,cAAc,CAAC;AAGxD,wBAAgB,QAAQ,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,GAAG,IAAI,CA8DpE"}
1
+ {"version":3,"file":"orders.d.ts","sourceRoot":"","sources":["../../src/tools/orders.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEpE,OAAO,EAAE,UAAU,EAAgB,MAAM,cAAc,CAAC;AAIxD,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;CA4BtB,CAAC;AAEF,wBAAgB,QAAQ,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,GAAG,IAAI,CAqEpE"}