@guiie/buda-mcp 1.2.0 → 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 (48) hide show
  1. package/dist/client.d.ts +15 -1
  2. package/dist/client.d.ts.map +1 -1
  3. package/dist/client.js +56 -52
  4. package/dist/http.js +30 -148
  5. package/dist/index.js +2 -1
  6. package/dist/tools/balances.d.ts +8 -0
  7. package/dist/tools/balances.d.ts.map +1 -1
  8. package/dist/tools/balances.js +11 -3
  9. package/dist/tools/cancel_order.d.ts +30 -0
  10. package/dist/tools/cancel_order.d.ts.map +1 -1
  11. package/dist/tools/cancel_order.js +59 -38
  12. package/dist/tools/compare_markets.d.ts +14 -0
  13. package/dist/tools/compare_markets.d.ts.map +1 -1
  14. package/dist/tools/compare_markets.js +17 -3
  15. package/dist/tools/markets.d.ts +13 -0
  16. package/dist/tools/markets.d.ts.map +1 -1
  17. package/dist/tools/markets.js +23 -2
  18. package/dist/tools/orderbook.d.ts +18 -0
  19. package/dist/tools/orderbook.d.ts.map +1 -1
  20. package/dist/tools/orderbook.js +28 -2
  21. package/dist/tools/orders.d.ts +26 -0
  22. package/dist/tools/orders.d.ts.map +1 -1
  23. package/dist/tools/orders.js +36 -2
  24. package/dist/tools/place_order.d.ts +50 -0
  25. package/dist/tools/place_order.d.ts.map +1 -1
  26. package/dist/tools/place_order.js +104 -58
  27. package/dist/tools/price_history.d.ts +22 -0
  28. package/dist/tools/price_history.d.ts.map +1 -1
  29. package/dist/tools/price_history.js +42 -7
  30. package/dist/tools/spread.d.ts +14 -0
  31. package/dist/tools/spread.d.ts.map +1 -1
  32. package/dist/tools/spread.js +24 -2
  33. package/dist/tools/ticker.d.ts +14 -0
  34. package/dist/tools/ticker.d.ts.map +1 -1
  35. package/dist/tools/ticker.js +24 -2
  36. package/dist/tools/trades.d.ts +22 -0
  37. package/dist/tools/trades.d.ts.map +1 -1
  38. package/dist/tools/trades.js +32 -2
  39. package/dist/tools/volume.d.ts +14 -0
  40. package/dist/tools/volume.d.ts.map +1 -1
  41. package/dist/tools/volume.js +24 -2
  42. package/dist/validation.d.ts +6 -0
  43. package/dist/validation.d.ts.map +1 -0
  44. package/dist/validation.js +14 -0
  45. package/dist/version.d.ts +2 -0
  46. package/dist/version.d.ts.map +1 -0
  47. package/dist/version.js +6 -0
  48. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"ticker.d.ts","sourceRoot":"","sources":["../../src/tools/ticker.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,CAiCxF"}
1
+ {"version":3,"file":"ticker.d.ts","sourceRoot":"","sources":["../../src/tools/ticker.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;;;;;;;;;;;;;CAetB,CAAC;AAEF,wBAAgB,QAAQ,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,WAAW,GAAG,IAAI,CAwCxF"}
@@ -1,14 +1,36 @@
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_ticker",
7
+ description: "Get the current ticker for a Buda.com market: last traded price, best bid/ask, " +
8
+ "24h volume, and price change over 24h and 7d.",
9
+ inputSchema: {
10
+ type: "object",
11
+ properties: {
12
+ market_id: {
13
+ type: "string",
14
+ description: "Market ID (e.g. 'BTC-CLP', 'ETH-BTC', 'BTC-COP').",
15
+ },
16
+ },
17
+ required: ["market_id"],
18
+ },
19
+ };
4
20
  export function register(server, client, cache) {
5
- server.tool("get_ticker", "Get the current ticker for a Buda.com market: last traded price, best bid/ask, " +
6
- "24h volume, and price change over 24h and 7d.", {
21
+ server.tool(toolSchema.name, toolSchema.description, {
7
22
  market_id: z
8
23
  .string()
9
24
  .describe("Market ID (e.g. 'BTC-CLP', 'ETH-BTC', 'BTC-COP')."),
10
25
  }, async ({ market_id }) => {
11
26
  try {
27
+ const validationError = validateMarketId(market_id);
28
+ if (validationError) {
29
+ return {
30
+ content: [{ type: "text", text: JSON.stringify({ error: validationError, code: "INVALID_MARKET_ID" }) }],
31
+ isError: true,
32
+ };
33
+ }
12
34
  const id = market_id.toLowerCase();
13
35
  const data = await cache.getOrFetch(`ticker:${id}`, CACHE_TTL.TICKER, () => client.get(`/markets/${id}/ticker`));
14
36
  return {
@@ -1,5 +1,27 @@
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
+ timestamp: {
19
+ type: string;
20
+ description: string;
21
+ };
22
+ };
23
+ required: string[];
24
+ };
25
+ };
4
26
  export declare function register(server: McpServer, client: BudaClient, _cache: MemoryCache): void;
5
27
  //# sourceMappingURL=trades.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"trades.d.ts","sourceRoot":"","sources":["../../src/tools/trades.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEpE,OAAO,EAAE,UAAU,EAAgB,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG1C,wBAAgB,QAAQ,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,WAAW,GAAG,IAAI,CAkDzF"}
1
+ {"version":3,"file":"trades.d.ts","sourceRoot":"","sources":["../../src/tools/trades.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEpE,OAAO,EAAE,UAAU,EAAgB,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAI1C,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;CAwBtB,CAAC;AAEF,wBAAgB,QAAQ,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,WAAW,GAAG,IAAI,CAyDzF"}
@@ -1,8 +1,31 @@
1
1
  import { z } from "zod";
2
2
  import { BudaApiError } from "../client.js";
3
+ import { validateMarketId } from "../validation.js";
4
+ export const toolSchema = {
5
+ name: "get_trades",
6
+ description: "Get recent trade history for a Buda.com market. Each entry contains " +
7
+ "[timestamp_ms, amount, price, direction]. Direction is 'buy' or 'sell'.",
8
+ inputSchema: {
9
+ type: "object",
10
+ properties: {
11
+ market_id: {
12
+ type: "string",
13
+ description: "Market ID (e.g. 'BTC-CLP', 'ETH-BTC').",
14
+ },
15
+ limit: {
16
+ type: "number",
17
+ description: "Number of trades to return (default: 50, max: 100).",
18
+ },
19
+ timestamp: {
20
+ type: "number",
21
+ description: "Unix timestamp (seconds) to paginate from. Returns trades older than this timestamp.",
22
+ },
23
+ },
24
+ required: ["market_id"],
25
+ },
26
+ };
3
27
  export function register(server, client, _cache) {
4
- server.tool("get_trades", "Get recent trade history for a Buda.com market. Each entry contains " +
5
- "[timestamp_ms, amount, price, direction]. Direction is 'buy' or 'sell'.", {
28
+ server.tool(toolSchema.name, toolSchema.description, {
6
29
  market_id: z
7
30
  .string()
8
31
  .describe("Market ID (e.g. 'BTC-CLP', 'ETH-BTC')."),
@@ -20,6 +43,13 @@ export function register(server, client, _cache) {
20
43
  .describe("Unix timestamp (seconds) to paginate from. Returns trades older than this timestamp."),
21
44
  }, async ({ market_id, limit, timestamp }) => {
22
45
  try {
46
+ const validationError = validateMarketId(market_id);
47
+ if (validationError) {
48
+ return {
49
+ content: [{ type: "text", text: JSON.stringify({ error: validationError, code: "INVALID_MARKET_ID" }) }],
50
+ isError: true,
51
+ };
52
+ }
23
53
  const params = {};
24
54
  if (limit !== undefined)
25
55
  params.limit = limit;
@@ -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
+ market_id: {
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=volume.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"volume.d.ts","sourceRoot":"","sources":["../../src/tools/volume.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEpE,OAAO,EAAE,UAAU,EAAgB,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG1C,wBAAgB,QAAQ,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,WAAW,GAAG,IAAI,CA8BzF"}
1
+ {"version":3,"file":"volume.d.ts","sourceRoot":"","sources":["../../src/tools/volume.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEpE,OAAO,EAAE,UAAU,EAAgB,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAI1C,eAAO,MAAM,UAAU;;;;;;;;;;;;;CAetB,CAAC;AAEF,wBAAgB,QAAQ,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,WAAW,GAAG,IAAI,CAqCzF"}
@@ -1,13 +1,35 @@
1
1
  import { z } from "zod";
2
2
  import { BudaApiError } from "../client.js";
3
+ import { validateMarketId } from "../validation.js";
4
+ export const toolSchema = {
5
+ name: "get_market_volume",
6
+ description: "Get 24h and 7-day transacted volume for a Buda.com market. " +
7
+ "Returns ask (sell) and bid (buy) volumes in the market's base currency.",
8
+ inputSchema: {
9
+ type: "object",
10
+ properties: {
11
+ market_id: {
12
+ type: "string",
13
+ description: "Market ID (e.g. 'BTC-CLP', 'ETH-BTC').",
14
+ },
15
+ },
16
+ required: ["market_id"],
17
+ },
18
+ };
3
19
  export function register(server, client, _cache) {
4
- server.tool("get_market_volume", "Get 24h and 7-day transacted volume for a Buda.com market. " +
5
- "Returns ask (sell) and bid (buy) volumes in the market's base currency.", {
20
+ server.tool(toolSchema.name, toolSchema.description, {
6
21
  market_id: z
7
22
  .string()
8
23
  .describe("Market ID (e.g. 'BTC-CLP', 'ETH-BTC')."),
9
24
  }, async ({ market_id }) => {
10
25
  try {
26
+ const validationError = validateMarketId(market_id);
27
+ if (validationError) {
28
+ return {
29
+ content: [{ type: "text", text: JSON.stringify({ error: validationError, code: "INVALID_MARKET_ID" }) }],
30
+ isError: true,
31
+ };
32
+ }
11
33
  const data = await client.get(`/markets/${market_id.toLowerCase()}/volume`);
12
34
  return {
13
35
  content: [{ type: "text", text: JSON.stringify(data.volume, null, 2) }],
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Validates a market ID against the expected BASE-QUOTE format.
3
+ * Returns an error message string if invalid, or null if valid.
4
+ */
5
+ export declare function validateMarketId(id: string): string | null;
6
+ //# sourceMappingURL=validation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../src/validation.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAS1D"}
@@ -0,0 +1,14 @@
1
+ const MARKET_ID_RE = /^[A-Z0-9]{2,10}-[A-Z0-9]{2,10}$/i;
2
+ /**
3
+ * Validates a market ID against the expected BASE-QUOTE format.
4
+ * Returns an error message string if invalid, or null if valid.
5
+ */
6
+ export function validateMarketId(id) {
7
+ if (!MARKET_ID_RE.test(id)) {
8
+ return (`Invalid market ID "${id}". ` +
9
+ `Expected format: BASE-QUOTE with 2–10 alphanumeric characters per part ` +
10
+ `(e.g. "BTC-CLP", "ETH-BTC").`);
11
+ }
12
+ return null;
13
+ }
14
+ //# sourceMappingURL=validation.js.map
@@ -0,0 +1,2 @@
1
+ export declare const VERSION: string;
2
+ //# sourceMappingURL=version.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,OAAO,EAAE,MAEb,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { readFileSync } from "fs";
2
+ import { fileURLToPath } from "url";
3
+ import { dirname, join } from "path";
4
+ const _dir = dirname(fileURLToPath(import.meta.url));
5
+ export const VERSION = JSON.parse(readFileSync(join(_dir, "../package.json"), "utf8")).version;
6
+ //# sourceMappingURL=version.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@guiie/buda-mcp",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "mcpName": "io.github.gtorreal/buda-mcp",
5
5
  "description": "MCP server for Buda.com's public cryptocurrency exchange API (Chile, Colombia, Peru)",
6
6
  "type": "module",