@guiie/buda-mcp 1.2.0 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.cursor/rules/release-workflow.mdc +54 -0
- package/dist/client.d.ts +15 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +56 -52
- package/dist/http.js +30 -148
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -1
- package/dist/tools/balances.d.ts +8 -0
- package/dist/tools/balances.d.ts.map +1 -1
- package/dist/tools/balances.js +11 -3
- package/dist/tools/cancel_order.d.ts +30 -0
- package/dist/tools/cancel_order.d.ts.map +1 -1
- package/dist/tools/cancel_order.js +59 -38
- package/dist/tools/compare_markets.d.ts +14 -0
- package/dist/tools/compare_markets.d.ts.map +1 -1
- package/dist/tools/compare_markets.js +17 -3
- package/dist/tools/markets.d.ts +13 -0
- package/dist/tools/markets.d.ts.map +1 -1
- package/dist/tools/markets.js +23 -2
- package/dist/tools/orderbook.d.ts +18 -0
- package/dist/tools/orderbook.d.ts.map +1 -1
- package/dist/tools/orderbook.js +28 -2
- package/dist/tools/orders.d.ts +26 -0
- package/dist/tools/orders.d.ts.map +1 -1
- package/dist/tools/orders.js +36 -2
- package/dist/tools/place_order.d.ts +50 -0
- package/dist/tools/place_order.d.ts.map +1 -1
- package/dist/tools/place_order.js +104 -58
- package/dist/tools/price_history.d.ts +22 -0
- package/dist/tools/price_history.d.ts.map +1 -1
- package/dist/tools/price_history.js +42 -7
- package/dist/tools/spread.d.ts +14 -0
- package/dist/tools/spread.d.ts.map +1 -1
- package/dist/tools/spread.js +24 -2
- package/dist/tools/ticker.d.ts +14 -0
- package/dist/tools/ticker.d.ts.map +1 -1
- package/dist/tools/ticker.js +24 -2
- package/dist/tools/trades.d.ts +22 -0
- package/dist/tools/trades.d.ts.map +1 -1
- package/dist/tools/trades.js +32 -2
- package/dist/tools/volume.d.ts +14 -0
- package/dist/tools/volume.d.ts.map +1 -1
- package/dist/tools/volume.js +24 -2
- package/dist/validation.d.ts +6 -0
- package/dist/validation.d.ts.map +1 -0
- package/dist/validation.js +14 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +6 -0
- package/package.json +1 -1
- package/server.json +2 -2
- package/src/index.ts +1 -0
|
@@ -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,
|
|
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
|
|
5
|
-
|
|
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')."),
|
package/dist/tools/markets.d.ts
CHANGED
|
@@ -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;
|
|
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"}
|
package/dist/tools/markets.js
CHANGED
|
@@ -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(
|
|
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;
|
|
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"}
|
package/dist/tools/orderbook.js
CHANGED
|
@@ -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(
|
|
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;
|
package/dist/tools/orders.d.ts
CHANGED
|
@@ -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;
|
|
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"}
|
package/dist/tools/orders.js
CHANGED
|
@@ -1,8 +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_orders",
|
|
6
|
+
description: "Get orders for a given Buda.com market. Filter by state (pending, active, traded, canceled). " +
|
|
7
|
+
"Requires BUDA_API_KEY and BUDA_API_SECRET environment variables.",
|
|
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
|
+
state: {
|
|
16
|
+
type: "string",
|
|
17
|
+
description: "Filter by order state: 'pending', 'active', 'traded', 'canceled', 'canceled_and_traded'.",
|
|
18
|
+
},
|
|
19
|
+
per: {
|
|
20
|
+
type: "number",
|
|
21
|
+
description: "Results per page (default: 20, max: 300).",
|
|
22
|
+
},
|
|
23
|
+
page: {
|
|
24
|
+
type: "number",
|
|
25
|
+
description: "Page number (default: 1).",
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
required: ["market_id"],
|
|
29
|
+
},
|
|
30
|
+
};
|
|
3
31
|
export function register(server, client) {
|
|
4
|
-
server.tool(
|
|
5
|
-
"Requires BUDA_API_KEY and BUDA_API_SECRET environment variables.", {
|
|
32
|
+
server.tool(toolSchema.name, toolSchema.description, {
|
|
6
33
|
market_id: z
|
|
7
34
|
.string()
|
|
8
35
|
.describe("Market ID (e.g. 'BTC-CLP', 'ETH-BTC')."),
|
|
@@ -26,6 +53,13 @@ export function register(server, client) {
|
|
|
26
53
|
.describe("Page number (default: 1)."),
|
|
27
54
|
}, async ({ market_id, state, per, page }) => {
|
|
28
55
|
try {
|
|
56
|
+
const validationError = validateMarketId(market_id);
|
|
57
|
+
if (validationError) {
|
|
58
|
+
return {
|
|
59
|
+
content: [{ type: "text", text: JSON.stringify({ error: validationError, code: "INVALID_MARKET_ID" }) }],
|
|
60
|
+
isError: true,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
29
63
|
const params = {};
|
|
30
64
|
if (state)
|
|
31
65
|
params.state = state;
|
|
@@ -1,4 +1,54 @@
|
|
|
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
|
+
type: {
|
|
14
|
+
type: string;
|
|
15
|
+
description: string;
|
|
16
|
+
};
|
|
17
|
+
price_type: {
|
|
18
|
+
type: string;
|
|
19
|
+
description: string;
|
|
20
|
+
};
|
|
21
|
+
amount: {
|
|
22
|
+
type: string;
|
|
23
|
+
description: string;
|
|
24
|
+
};
|
|
25
|
+
limit_price: {
|
|
26
|
+
type: string;
|
|
27
|
+
description: string;
|
|
28
|
+
};
|
|
29
|
+
confirmation_token: {
|
|
30
|
+
type: string;
|
|
31
|
+
description: string;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
required: string[];
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
type PlaceOrderArgs = {
|
|
38
|
+
market_id: string;
|
|
39
|
+
type: "Bid" | "Ask";
|
|
40
|
+
price_type: "limit" | "market";
|
|
41
|
+
amount: number;
|
|
42
|
+
limit_price?: number;
|
|
43
|
+
confirmation_token: string;
|
|
44
|
+
};
|
|
45
|
+
export declare function handlePlaceOrder(args: PlaceOrderArgs, client: BudaClient): Promise<{
|
|
46
|
+
content: Array<{
|
|
47
|
+
type: "text";
|
|
48
|
+
text: string;
|
|
49
|
+
}>;
|
|
50
|
+
isError?: boolean;
|
|
51
|
+
}>;
|
|
3
52
|
export declare function register(server: McpServer, client: BudaClient): void;
|
|
53
|
+
export {};
|
|
4
54
|
//# sourceMappingURL=place_order.d.ts.map
|
|
@@ -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;
|
|
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0CtB,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,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,CAwEhF;AAED,wBAAgB,QAAQ,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,GAAG,IAAI,CAmCpE"}
|
|
@@ -1,11 +1,111 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { BudaApiError } from "../client.js";
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
import { validateMarketId } from "../validation.js";
|
|
4
|
+
export const toolSchema = {
|
|
5
|
+
name: "place_order",
|
|
6
|
+
description: "Place a limit or market order on Buda.com. " +
|
|
5
7
|
"IMPORTANT: To prevent accidental execution from ambiguous prompts, you must pass " +
|
|
6
8
|
"confirmation_token='CONFIRM' to execute the order. " +
|
|
7
9
|
"Requires BUDA_API_KEY and BUDA_API_SECRET environment variables. " +
|
|
8
|
-
"WARNING: Only use this tool on a locally-run instance — never on a publicly exposed server.",
|
|
10
|
+
"WARNING: Only use this tool on a locally-run instance — never on a publicly exposed server.",
|
|
11
|
+
inputSchema: {
|
|
12
|
+
type: "object",
|
|
13
|
+
properties: {
|
|
14
|
+
market_id: {
|
|
15
|
+
type: "string",
|
|
16
|
+
description: "Market ID (e.g. 'BTC-CLP', 'ETH-BTC').",
|
|
17
|
+
},
|
|
18
|
+
type: {
|
|
19
|
+
type: "string",
|
|
20
|
+
description: "Order side: 'Bid' to buy, 'Ask' to sell.",
|
|
21
|
+
},
|
|
22
|
+
price_type: {
|
|
23
|
+
type: "string",
|
|
24
|
+
description: "Order type: 'limit' places at a specific price, 'market' executes immediately.",
|
|
25
|
+
},
|
|
26
|
+
amount: {
|
|
27
|
+
type: "number",
|
|
28
|
+
description: "Order size in the market's base currency (e.g. BTC amount for BTC-CLP).",
|
|
29
|
+
},
|
|
30
|
+
limit_price: {
|
|
31
|
+
type: "number",
|
|
32
|
+
description: "Limit price in quote currency. Required when price_type is 'limit'. " +
|
|
33
|
+
"For Bid orders: highest price you will pay. For Ask orders: lowest price you will accept.",
|
|
34
|
+
},
|
|
35
|
+
confirmation_token: {
|
|
36
|
+
type: "string",
|
|
37
|
+
description: "Safety confirmation. Must equal exactly 'CONFIRM' (case-sensitive) to execute the order. " +
|
|
38
|
+
"Any other value will reject the request without placing an order.",
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
required: ["market_id", "type", "price_type", "amount", "confirmation_token"],
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
export async function handlePlaceOrder(args, client) {
|
|
45
|
+
const { market_id, type, price_type, amount, limit_price, confirmation_token } = args;
|
|
46
|
+
if (confirmation_token !== "CONFIRM") {
|
|
47
|
+
return {
|
|
48
|
+
content: [
|
|
49
|
+
{
|
|
50
|
+
type: "text",
|
|
51
|
+
text: JSON.stringify({
|
|
52
|
+
error: "Order not placed. confirmation_token must equal 'CONFIRM' to execute. " +
|
|
53
|
+
"Review the order details and set confirmation_token='CONFIRM' to proceed.",
|
|
54
|
+
code: "CONFIRMATION_REQUIRED",
|
|
55
|
+
order_preview: { market_id, type, price_type, amount, limit_price },
|
|
56
|
+
}),
|
|
57
|
+
},
|
|
58
|
+
],
|
|
59
|
+
isError: true,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
const validationError = validateMarketId(market_id);
|
|
63
|
+
if (validationError) {
|
|
64
|
+
return {
|
|
65
|
+
content: [{ type: "text", text: JSON.stringify({ error: validationError, code: "INVALID_MARKET_ID" }) }],
|
|
66
|
+
isError: true,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
try {
|
|
70
|
+
const payload = {
|
|
71
|
+
type,
|
|
72
|
+
price_type,
|
|
73
|
+
amount,
|
|
74
|
+
};
|
|
75
|
+
if (price_type === "limit") {
|
|
76
|
+
if (limit_price === undefined) {
|
|
77
|
+
return {
|
|
78
|
+
content: [
|
|
79
|
+
{
|
|
80
|
+
type: "text",
|
|
81
|
+
text: JSON.stringify({
|
|
82
|
+
error: "limit_price is required when price_type is 'limit'.",
|
|
83
|
+
code: "VALIDATION_ERROR",
|
|
84
|
+
}),
|
|
85
|
+
},
|
|
86
|
+
],
|
|
87
|
+
isError: true,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
payload.limit = { price: limit_price, type: "gtc" };
|
|
91
|
+
}
|
|
92
|
+
const data = await client.post(`/markets/${market_id.toLowerCase()}/orders`, payload);
|
|
93
|
+
return {
|
|
94
|
+
content: [{ type: "text", text: JSON.stringify(data.order, null, 2) }],
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
catch (err) {
|
|
98
|
+
const msg = err instanceof BudaApiError
|
|
99
|
+
? { error: err.message, code: err.status, path: err.path }
|
|
100
|
+
: { error: String(err), code: "UNKNOWN" };
|
|
101
|
+
return {
|
|
102
|
+
content: [{ type: "text", text: JSON.stringify(msg) }],
|
|
103
|
+
isError: true,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
export function register(server, client) {
|
|
108
|
+
server.tool(toolSchema.name, toolSchema.description, {
|
|
9
109
|
market_id: z
|
|
10
110
|
.string()
|
|
11
111
|
.describe("Market ID (e.g. 'BTC-CLP', 'ETH-BTC')."),
|
|
@@ -29,60 +129,6 @@ export function register(server, client) {
|
|
|
29
129
|
.string()
|
|
30
130
|
.describe("Safety confirmation. Must equal exactly 'CONFIRM' (case-sensitive) to execute the order. " +
|
|
31
131
|
"Any other value will reject the request without placing an order."),
|
|
32
|
-
},
|
|
33
|
-
if (confirmation_token !== "CONFIRM") {
|
|
34
|
-
return {
|
|
35
|
-
content: [
|
|
36
|
-
{
|
|
37
|
-
type: "text",
|
|
38
|
-
text: JSON.stringify({
|
|
39
|
-
error: "Order not placed. confirmation_token must equal 'CONFIRM' to execute. " +
|
|
40
|
-
"Review the order details and set confirmation_token='CONFIRM' to proceed.",
|
|
41
|
-
code: "CONFIRMATION_REQUIRED",
|
|
42
|
-
order_preview: { market_id, type, price_type, amount, limit_price },
|
|
43
|
-
}),
|
|
44
|
-
},
|
|
45
|
-
],
|
|
46
|
-
isError: true,
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
try {
|
|
50
|
-
const payload = {
|
|
51
|
-
type,
|
|
52
|
-
price_type,
|
|
53
|
-
amount,
|
|
54
|
-
};
|
|
55
|
-
if (price_type === "limit") {
|
|
56
|
-
if (limit_price === undefined) {
|
|
57
|
-
return {
|
|
58
|
-
content: [
|
|
59
|
-
{
|
|
60
|
-
type: "text",
|
|
61
|
-
text: JSON.stringify({
|
|
62
|
-
error: "limit_price is required when price_type is 'limit'.",
|
|
63
|
-
code: "VALIDATION_ERROR",
|
|
64
|
-
}),
|
|
65
|
-
},
|
|
66
|
-
],
|
|
67
|
-
isError: true,
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
payload.limit = { price: limit_price, type: "gtc" };
|
|
71
|
-
}
|
|
72
|
-
const data = await client.post(`/markets/${market_id.toLowerCase()}/orders`, payload);
|
|
73
|
-
return {
|
|
74
|
-
content: [{ type: "text", text: JSON.stringify(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
|
-
});
|
|
132
|
+
}, (args) => handlePlaceOrder(args, client));
|
|
87
133
|
}
|
|
88
134
|
//# sourceMappingURL=place_order.js.map
|
|
@@ -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
|
+
period: {
|
|
15
|
+
type: string;
|
|
16
|
+
description: string;
|
|
17
|
+
};
|
|
18
|
+
limit: {
|
|
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=price_history.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"price_history.d.ts","sourceRoot":"","sources":["../../src/tools/price_history.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;
|
|
1
|
+
{"version":3,"file":"price_history.d.ts","sourceRoot":"","sources":["../../src/tools/price_history.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;AAoB1C,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;CA4BtB,CAAC;AAEF,wBAAgB,QAAQ,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,WAAW,GAAG,IAAI,CAsHzF"}
|
|
@@ -1,15 +1,40 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { BudaApiError } from "../client.js";
|
|
3
|
+
import { validateMarketId } from "../validation.js";
|
|
3
4
|
const PERIOD_MS = {
|
|
4
5
|
"1h": 60 * 60 * 1000,
|
|
5
6
|
"4h": 4 * 60 * 60 * 1000,
|
|
6
7
|
"1d": 24 * 60 * 60 * 1000,
|
|
7
8
|
};
|
|
9
|
+
export const toolSchema = {
|
|
10
|
+
name: "get_price_history",
|
|
11
|
+
description: "IMPORTANT: Candles are aggregated client-side from raw trades (Buda has no native candlestick " +
|
|
12
|
+
"endpoint) — fetching more trades via the 'limit' parameter gives deeper history but slower " +
|
|
13
|
+
"responses. Returns OHLCV (open/high/low/close/volume) price history for a Buda.com market. " +
|
|
14
|
+
"Candle timestamps are UTC bucket boundaries (e.g. '2026-04-10T12:00:00.000Z' for 1h). " +
|
|
15
|
+
"Supports 1h, 4h, and 1d candle periods.",
|
|
16
|
+
inputSchema: {
|
|
17
|
+
type: "object",
|
|
18
|
+
properties: {
|
|
19
|
+
market_id: {
|
|
20
|
+
type: "string",
|
|
21
|
+
description: "Market ID (e.g. 'BTC-CLP', 'ETH-BTC').",
|
|
22
|
+
},
|
|
23
|
+
period: {
|
|
24
|
+
type: "string",
|
|
25
|
+
description: "Candle period: '1h' (1 hour), '4h' (4 hours), or '1d' (1 day). Default: '1h'.",
|
|
26
|
+
},
|
|
27
|
+
limit: {
|
|
28
|
+
type: "number",
|
|
29
|
+
description: "Raw trades to fetch before aggregation (default: 100, max: 1000). " +
|
|
30
|
+
"More trades = deeper history but slower response.",
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
required: ["market_id"],
|
|
34
|
+
},
|
|
35
|
+
};
|
|
8
36
|
export function register(server, client, _cache) {
|
|
9
|
-
server.tool(
|
|
10
|
-
"recent trade history (up to 100 trades). Buda does not provide a native candlestick endpoint; " +
|
|
11
|
-
"candles are aggregated client-side from raw trades. Use the 'period' parameter to control " +
|
|
12
|
-
"candle size (1h, 4h, or 1d).", {
|
|
37
|
+
server.tool(toolSchema.name, toolSchema.description, {
|
|
13
38
|
market_id: z
|
|
14
39
|
.string()
|
|
15
40
|
.describe("Market ID (e.g. 'BTC-CLP', 'ETH-BTC')."),
|
|
@@ -21,11 +46,19 @@ export function register(server, client, _cache) {
|
|
|
21
46
|
.number()
|
|
22
47
|
.int()
|
|
23
48
|
.min(1)
|
|
24
|
-
.max(
|
|
49
|
+
.max(1000)
|
|
25
50
|
.optional()
|
|
26
|
-
.describe("
|
|
51
|
+
.describe("Raw trades to fetch before aggregation (default: 100, max: 1000). " +
|
|
52
|
+
"More trades = deeper history but slower response."),
|
|
27
53
|
}, async ({ market_id, period, limit }) => {
|
|
28
54
|
try {
|
|
55
|
+
const validationError = validateMarketId(market_id);
|
|
56
|
+
if (validationError) {
|
|
57
|
+
return {
|
|
58
|
+
content: [{ type: "text", text: JSON.stringify({ error: validationError, code: "INVALID_MARKET_ID" }) }],
|
|
59
|
+
isError: true,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
29
62
|
const id = market_id.toLowerCase();
|
|
30
63
|
const tradesLimit = limit ?? 100;
|
|
31
64
|
const data = await client.get(`/markets/${id}/trades`, { limit: tradesLimit });
|
|
@@ -79,7 +112,9 @@ export function register(server, client, _cache) {
|
|
|
79
112
|
market_id: market_id.toUpperCase(),
|
|
80
113
|
period,
|
|
81
114
|
candle_count: candles.length,
|
|
82
|
-
|
|
115
|
+
trades_fetched: entries.length,
|
|
116
|
+
note: "Candles derived from raw trade history. Candle timestamps are UTC bucket boundaries. " +
|
|
117
|
+
"Increase 'limit' (max 1000) for deeper history.",
|
|
83
118
|
candles,
|
|
84
119
|
};
|
|
85
120
|
return {
|
package/dist/tools/spread.d.ts
CHANGED
|
@@ -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=spread.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spread.d.ts","sourceRoot":"","sources":["../../src/tools/spread.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;
|
|
1
|
+
{"version":3,"file":"spread.d.ts","sourceRoot":"","sources":["../../src/tools/spread.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,CAuExF"}
|