@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.
- package/CHANGELOG.md +35 -0
- package/PUBLISH.md +5 -5
- package/PUBLISH_CHECKLIST.md +59 -62
- package/README.md +3 -3
- 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.js +2 -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/marketplace/README.md +1 -1
- package/marketplace/claude-listing.md +2 -2
- package/marketplace/gemini-tools.json +3 -3
- package/marketplace/openapi.yaml +7 -6
- package/package.json +5 -2
- package/scripts/sync-version.mjs +19 -0
- package/server.json +2 -2
- package/src/client.ts +77 -53
- package/src/http.ts +32 -150
- package/src/index.ts +2 -1
- package/src/tools/balances.ts +14 -4
- package/src/tools/cancel_order.ts +77 -43
- package/src/tools/compare_markets.ts +21 -4
- package/src/tools/markets.ts +27 -3
- package/src/tools/orderbook.ts +32 -3
- package/src/tools/orders.ts +41 -3
- package/src/tools/place_order.ts +134 -69
- package/src/tools/price_history.ts +50 -8
- package/src/tools/spread.ts +28 -3
- package/src/tools/ticker.ts +28 -3
- package/src/tools/trades.ts +37 -3
- package/src/tools/volume.ts +28 -3
- package/src/validation.ts +16 -0
- package/src/version.ts +8 -0
- package/test/run-all.ts +13 -1
- package/test/unit.ts +414 -0
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"}
|
package/dist/tools/spread.js
CHANGED
|
@@ -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_spread",
|
|
7
|
+
description: "Calculate the bid/ask spread for a Buda.com market. " +
|
|
8
|
+
"Returns the best bid, best ask, absolute spread, and spread as a percentage of the ask price.",
|
|
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(
|
|
6
|
-
"Returns the best bid, best ask, absolute spread, and spread as a percentage of the ask price.", {
|
|
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
|
const ticker = data.ticker;
|
package/dist/tools/ticker.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=ticker.d.ts.map
|
|
@@ -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;
|
|
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"}
|
package/dist/tools/ticker.js
CHANGED
|
@@ -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(
|
|
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 {
|
package/dist/tools/trades.d.ts
CHANGED
|
@@ -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;
|
|
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"}
|
package/dist/tools/trades.js
CHANGED
|
@@ -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(
|
|
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;
|
package/dist/tools/volume.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=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;
|
|
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"}
|