@rustledger/mcp-server 0.2.0 → 0.5.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/README.md +94 -3
- package/dist/__tests__/index.test.d.ts +2 -0
- package/dist/__tests__/index.test.d.ts.map +1 -0
- package/dist/__tests__/index.test.js +585 -0
- package/dist/__tests__/index.test.js.map +1 -0
- package/dist/docs/bql-functions.md +41 -0
- package/dist/docs/bql-tables.md +26 -0
- package/dist/docs/bql.md +62 -0
- package/dist/docs/directives.md +67 -0
- package/dist/docs/validation-errors.md +40 -0
- package/dist/handlers.d.ts +6 -0
- package/dist/handlers.d.ts.map +1 -0
- package/dist/handlers.js +558 -0
- package/dist/handlers.js.map +1 -0
- package/dist/helpers.d.ts +31 -0
- package/dist/helpers.d.ts.map +1 -0
- package/dist/helpers.js +109 -0
- package/dist/helpers.js.map +1 -0
- package/dist/index.js +24 -421
- package/dist/index.js.map +1 -1
- package/dist/prompts.d.ts +24 -0
- package/dist/prompts.d.ts.map +1 -0
- package/dist/prompts.js +122 -0
- package/dist/prompts.js.map +1 -0
- package/dist/resources.d.ts +19 -0
- package/dist/resources.d.ts.map +1 -0
- package/dist/resources.js +94 -0
- package/dist/resources.js.map +1 -0
- package/dist/tools.d.ts +36 -0
- package/dist/tools.d.ts.map +1 -0
- package/dist/tools.js +475 -0
- package/dist/tools.js.map +1 -0
- package/dist/types.d.ts +140 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/package.json +7 -4
package/dist/helpers.js
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
// Helper functions for the MCP server
|
|
2
|
+
/**
|
|
3
|
+
* Validate that required arguments are present.
|
|
4
|
+
* Returns a ToolResponse with error if validation fails, null otherwise.
|
|
5
|
+
*/
|
|
6
|
+
export function validateArgs(args, required) {
|
|
7
|
+
const missing = [];
|
|
8
|
+
for (const key of required) {
|
|
9
|
+
const value = args?.[key];
|
|
10
|
+
// Check for undefined, null, or empty string for string types
|
|
11
|
+
if (value === undefined || value === null) {
|
|
12
|
+
missing.push(key);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
if (missing.length > 0) {
|
|
16
|
+
const argList = missing.join(", ");
|
|
17
|
+
return {
|
|
18
|
+
isError: true,
|
|
19
|
+
content: [
|
|
20
|
+
{
|
|
21
|
+
type: "text",
|
|
22
|
+
text: `Missing required argument${missing.length > 1 ? "s" : ""}: ${argList}`,
|
|
23
|
+
},
|
|
24
|
+
],
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Create an error response.
|
|
31
|
+
*/
|
|
32
|
+
export function errorResponse(message) {
|
|
33
|
+
return {
|
|
34
|
+
isError: true,
|
|
35
|
+
content: [{ type: "text", text: message }],
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Create a success response with text content.
|
|
40
|
+
*/
|
|
41
|
+
export function textResponse(text) {
|
|
42
|
+
return {
|
|
43
|
+
content: [{ type: "text", text }],
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Create a success response with JSON content.
|
|
48
|
+
*/
|
|
49
|
+
export function jsonResponse(data) {
|
|
50
|
+
return {
|
|
51
|
+
content: [{ type: "text", text: JSON.stringify(data, null, 2) }],
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Format validation/parse errors for display.
|
|
56
|
+
*/
|
|
57
|
+
export function formatErrors(errors) {
|
|
58
|
+
return errors
|
|
59
|
+
.map((e) => {
|
|
60
|
+
const loc = e.line ? `:${e.line}${e.column ? `:${e.column}` : ""}` : "";
|
|
61
|
+
return `[${e.severity}]${loc} ${e.message}`;
|
|
62
|
+
})
|
|
63
|
+
.join("\n");
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Format a query result as a table.
|
|
67
|
+
*/
|
|
68
|
+
export function formatQueryResult(result) {
|
|
69
|
+
if (!result.columns || result.columns.length === 0) {
|
|
70
|
+
return "No results.";
|
|
71
|
+
}
|
|
72
|
+
const { columns, rows } = result;
|
|
73
|
+
// Calculate column widths
|
|
74
|
+
const widths = columns.map((col, i) => {
|
|
75
|
+
const maxRowWidth = Math.max(...rows.map((row) => formatCell(row[i]).length));
|
|
76
|
+
return Math.max(col.length, maxRowWidth);
|
|
77
|
+
});
|
|
78
|
+
// Format header
|
|
79
|
+
const header = columns.map((col, i) => col.padEnd(widths[i])).join(" | ");
|
|
80
|
+
const separator = widths.map((w) => "-".repeat(w)).join("-+-");
|
|
81
|
+
// Format rows
|
|
82
|
+
const formattedRows = rows.map((row) => row.map((cell, i) => formatCell(cell).padEnd(widths[i])).join(" | "));
|
|
83
|
+
return [header, separator, ...formattedRows].join("\n");
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Format a single cell value for display.
|
|
87
|
+
*/
|
|
88
|
+
export function formatCell(value) {
|
|
89
|
+
if (value === null || value === undefined) {
|
|
90
|
+
return "";
|
|
91
|
+
}
|
|
92
|
+
if (typeof value === "object") {
|
|
93
|
+
// Handle Amount type
|
|
94
|
+
if ("number" in value && "currency" in value) {
|
|
95
|
+
const amount = value;
|
|
96
|
+
return `${amount.number} ${amount.currency}`;
|
|
97
|
+
}
|
|
98
|
+
// Handle Inventory type
|
|
99
|
+
if ("positions" in value) {
|
|
100
|
+
const inv = value;
|
|
101
|
+
return inv.positions
|
|
102
|
+
.map((p) => `${p.units.number} ${p.units.currency}`)
|
|
103
|
+
.join(", ");
|
|
104
|
+
}
|
|
105
|
+
return JSON.stringify(value);
|
|
106
|
+
}
|
|
107
|
+
return String(value);
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AAAA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GAAG,CAAC,SAAS;iBACjB,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,MAAM,IAAI,CAAC,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;iBACnD,IAAI,CAAC,IAAI,CAAC,CAAC;QAChB,CAAC;QACD,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IAC/B,CAAC;IACD,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
3
3
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
4
|
-
import { CallToolRequestSchema, ListToolsRequestSchema, ListResourcesRequestSchema, ReadResourceRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
|
|
5
|
-
// Import rustledger WASM bindings
|
|
4
|
+
import { CallToolRequestSchema, ListToolsRequestSchema, ListResourcesRequestSchema, ReadResourceRequestSchema, ListPromptsRequestSchema, GetPromptRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
|
|
6
5
|
import * as rustledger from "@rustledger/wasm";
|
|
6
|
+
// Import modular components
|
|
7
|
+
import { TOOLS } from "./tools.js";
|
|
8
|
+
import { handleToolCall } from "./handlers.js";
|
|
9
|
+
import { RESOURCES, getResourceContents } from "./resources.js";
|
|
10
|
+
import { PROMPTS, getPrompt } from "./prompts.js";
|
|
7
11
|
// Initialize WASM module
|
|
8
12
|
rustledger.init();
|
|
13
|
+
// Create server instance
|
|
9
14
|
const server = new Server({
|
|
10
15
|
name: "rustledger",
|
|
11
16
|
version: rustledger.version(),
|
|
@@ -13,130 +18,9 @@ const server = new Server({
|
|
|
13
18
|
capabilities: {
|
|
14
19
|
tools: {},
|
|
15
20
|
resources: {},
|
|
21
|
+
prompts: {},
|
|
16
22
|
},
|
|
17
23
|
});
|
|
18
|
-
// Tool definitions
|
|
19
|
-
const TOOLS = [
|
|
20
|
-
{
|
|
21
|
-
name: "validate",
|
|
22
|
-
description: "Validate a Beancount ledger. Returns validation errors and warnings if any issues are found.",
|
|
23
|
-
inputSchema: {
|
|
24
|
-
type: "object",
|
|
25
|
-
properties: {
|
|
26
|
-
source: {
|
|
27
|
-
type: "string",
|
|
28
|
-
description: "The Beancount ledger source text to validate",
|
|
29
|
-
},
|
|
30
|
-
},
|
|
31
|
-
required: ["source"],
|
|
32
|
-
},
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
name: "query",
|
|
36
|
-
description: "Run a BQL (Beancount Query Language) query on a ledger. Use this for account balances, filtering transactions, aggregations, etc.",
|
|
37
|
-
inputSchema: {
|
|
38
|
-
type: "object",
|
|
39
|
-
properties: {
|
|
40
|
-
source: {
|
|
41
|
-
type: "string",
|
|
42
|
-
description: "The Beancount ledger source text",
|
|
43
|
-
},
|
|
44
|
-
query: {
|
|
45
|
-
type: "string",
|
|
46
|
-
description: 'The BQL query to execute (e.g., "SELECT account, sum(position) GROUP BY account")',
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
required: ["source", "query"],
|
|
50
|
-
},
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
name: "balances",
|
|
54
|
-
description: "Get account balances from a ledger. This is a shorthand for running a BALANCES query.",
|
|
55
|
-
inputSchema: {
|
|
56
|
-
type: "object",
|
|
57
|
-
properties: {
|
|
58
|
-
source: {
|
|
59
|
-
type: "string",
|
|
60
|
-
description: "The Beancount ledger source text",
|
|
61
|
-
},
|
|
62
|
-
},
|
|
63
|
-
required: ["source"],
|
|
64
|
-
},
|
|
65
|
-
},
|
|
66
|
-
{
|
|
67
|
-
name: "format",
|
|
68
|
-
description: "Format a Beancount ledger with consistent alignment and spacing.",
|
|
69
|
-
inputSchema: {
|
|
70
|
-
type: "object",
|
|
71
|
-
properties: {
|
|
72
|
-
source: {
|
|
73
|
-
type: "string",
|
|
74
|
-
description: "The Beancount ledger source text to format",
|
|
75
|
-
},
|
|
76
|
-
},
|
|
77
|
-
required: ["source"],
|
|
78
|
-
},
|
|
79
|
-
},
|
|
80
|
-
{
|
|
81
|
-
name: "parse",
|
|
82
|
-
description: "Parse a Beancount ledger and return the directives as structured data.",
|
|
83
|
-
inputSchema: {
|
|
84
|
-
type: "object",
|
|
85
|
-
properties: {
|
|
86
|
-
source: {
|
|
87
|
-
type: "string",
|
|
88
|
-
description: "The Beancount ledger source text to parse",
|
|
89
|
-
},
|
|
90
|
-
},
|
|
91
|
-
required: ["source"],
|
|
92
|
-
},
|
|
93
|
-
},
|
|
94
|
-
{
|
|
95
|
-
name: "completions",
|
|
96
|
-
description: "Get BQL query completions at a cursor position. Useful for building query editors.",
|
|
97
|
-
inputSchema: {
|
|
98
|
-
type: "object",
|
|
99
|
-
properties: {
|
|
100
|
-
partial_query: {
|
|
101
|
-
type: "string",
|
|
102
|
-
description: "The partial BQL query text",
|
|
103
|
-
},
|
|
104
|
-
cursor_pos: {
|
|
105
|
-
type: "number",
|
|
106
|
-
description: "The cursor position (character offset) in the query",
|
|
107
|
-
},
|
|
108
|
-
},
|
|
109
|
-
required: ["partial_query", "cursor_pos"],
|
|
110
|
-
},
|
|
111
|
-
},
|
|
112
|
-
{
|
|
113
|
-
name: "list_plugins",
|
|
114
|
-
description: "List available native plugins that can process ledgers.",
|
|
115
|
-
inputSchema: {
|
|
116
|
-
type: "object",
|
|
117
|
-
properties: {},
|
|
118
|
-
required: [],
|
|
119
|
-
},
|
|
120
|
-
},
|
|
121
|
-
{
|
|
122
|
-
name: "run_plugin",
|
|
123
|
-
description: "Run a native plugin on a ledger.",
|
|
124
|
-
inputSchema: {
|
|
125
|
-
type: "object",
|
|
126
|
-
properties: {
|
|
127
|
-
source: {
|
|
128
|
-
type: "string",
|
|
129
|
-
description: "The Beancount ledger source text",
|
|
130
|
-
},
|
|
131
|
-
plugin_name: {
|
|
132
|
-
type: "string",
|
|
133
|
-
description: "The name of the plugin to run (use list_plugins to see available plugins)",
|
|
134
|
-
},
|
|
135
|
-
},
|
|
136
|
-
required: ["source", "plugin_name"],
|
|
137
|
-
},
|
|
138
|
-
},
|
|
139
|
-
];
|
|
140
24
|
// List available tools
|
|
141
25
|
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
142
26
|
return { tools: TOOLS };
|
|
@@ -145,172 +29,7 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
145
29
|
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
146
30
|
const { name, arguments: args } = request.params;
|
|
147
31
|
try {
|
|
148
|
-
|
|
149
|
-
case "validate": {
|
|
150
|
-
const source = args?.source;
|
|
151
|
-
if (!source) {
|
|
152
|
-
return {
|
|
153
|
-
isError: true,
|
|
154
|
-
content: [{ type: "text", text: "Missing required argument: source" }],
|
|
155
|
-
};
|
|
156
|
-
}
|
|
157
|
-
const result = rustledger.validateSource(source);
|
|
158
|
-
return {
|
|
159
|
-
content: [
|
|
160
|
-
{
|
|
161
|
-
type: "text",
|
|
162
|
-
text: result.valid
|
|
163
|
-
? "Ledger is valid."
|
|
164
|
-
: `Found ${result.errors.length} error(s):\n${formatErrors(result.errors)}`,
|
|
165
|
-
},
|
|
166
|
-
],
|
|
167
|
-
};
|
|
168
|
-
}
|
|
169
|
-
case "query": {
|
|
170
|
-
const source = args?.source;
|
|
171
|
-
const query = args?.query;
|
|
172
|
-
if (!source || !query) {
|
|
173
|
-
return {
|
|
174
|
-
isError: true,
|
|
175
|
-
content: [
|
|
176
|
-
{ type: "text", text: "Missing required arguments: source and query" },
|
|
177
|
-
],
|
|
178
|
-
};
|
|
179
|
-
}
|
|
180
|
-
const result = rustledger.query(source, query);
|
|
181
|
-
if (result.errors?.length > 0) {
|
|
182
|
-
return {
|
|
183
|
-
isError: true,
|
|
184
|
-
content: [{ type: "text", text: formatErrors(result.errors) }],
|
|
185
|
-
};
|
|
186
|
-
}
|
|
187
|
-
return {
|
|
188
|
-
content: [{ type: "text", text: formatQueryResult(result) }],
|
|
189
|
-
};
|
|
190
|
-
}
|
|
191
|
-
case "balances": {
|
|
192
|
-
const source = args?.source;
|
|
193
|
-
if (!source) {
|
|
194
|
-
return {
|
|
195
|
-
isError: true,
|
|
196
|
-
content: [{ type: "text", text: "Missing required argument: source" }],
|
|
197
|
-
};
|
|
198
|
-
}
|
|
199
|
-
const result = rustledger.balances(source);
|
|
200
|
-
if (result.errors?.length > 0) {
|
|
201
|
-
return {
|
|
202
|
-
isError: true,
|
|
203
|
-
content: [{ type: "text", text: formatErrors(result.errors) }],
|
|
204
|
-
};
|
|
205
|
-
}
|
|
206
|
-
return {
|
|
207
|
-
content: [{ type: "text", text: formatQueryResult(result) }],
|
|
208
|
-
};
|
|
209
|
-
}
|
|
210
|
-
case "format": {
|
|
211
|
-
const source = args?.source;
|
|
212
|
-
if (!source) {
|
|
213
|
-
return {
|
|
214
|
-
isError: true,
|
|
215
|
-
content: [{ type: "text", text: "Missing required argument: source" }],
|
|
216
|
-
};
|
|
217
|
-
}
|
|
218
|
-
const result = rustledger.format(source);
|
|
219
|
-
if (result.errors?.length > 0) {
|
|
220
|
-
return {
|
|
221
|
-
isError: true,
|
|
222
|
-
content: [{ type: "text", text: formatErrors(result.errors) }],
|
|
223
|
-
};
|
|
224
|
-
}
|
|
225
|
-
return {
|
|
226
|
-
content: [{ type: "text", text: result.formatted || "" }],
|
|
227
|
-
};
|
|
228
|
-
}
|
|
229
|
-
case "parse": {
|
|
230
|
-
const source = args?.source;
|
|
231
|
-
if (!source) {
|
|
232
|
-
return {
|
|
233
|
-
isError: true,
|
|
234
|
-
content: [{ type: "text", text: "Missing required argument: source" }],
|
|
235
|
-
};
|
|
236
|
-
}
|
|
237
|
-
const result = rustledger.parse(source);
|
|
238
|
-
if (result.errors?.length > 0) {
|
|
239
|
-
return {
|
|
240
|
-
isError: true,
|
|
241
|
-
content: [{ type: "text", text: formatErrors(result.errors) }],
|
|
242
|
-
};
|
|
243
|
-
}
|
|
244
|
-
return {
|
|
245
|
-
content: [
|
|
246
|
-
{
|
|
247
|
-
type: "text",
|
|
248
|
-
text: JSON.stringify(result.ledger, null, 2),
|
|
249
|
-
},
|
|
250
|
-
],
|
|
251
|
-
};
|
|
252
|
-
}
|
|
253
|
-
case "completions": {
|
|
254
|
-
const partialQuery = args?.partial_query;
|
|
255
|
-
const cursorPos = args?.cursor_pos;
|
|
256
|
-
if (partialQuery === undefined || cursorPos === undefined) {
|
|
257
|
-
return {
|
|
258
|
-
isError: true,
|
|
259
|
-
content: [
|
|
260
|
-
{
|
|
261
|
-
type: "text",
|
|
262
|
-
text: "Missing required arguments: partial_query and cursor_pos",
|
|
263
|
-
},
|
|
264
|
-
],
|
|
265
|
-
};
|
|
266
|
-
}
|
|
267
|
-
const result = rustledger.bqlCompletions(partialQuery, cursorPos);
|
|
268
|
-
return {
|
|
269
|
-
content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
|
|
270
|
-
};
|
|
271
|
-
}
|
|
272
|
-
case "list_plugins": {
|
|
273
|
-
const plugins = rustledger.listPlugins();
|
|
274
|
-
return {
|
|
275
|
-
content: [{ type: "text", text: JSON.stringify(plugins, null, 2) }],
|
|
276
|
-
};
|
|
277
|
-
}
|
|
278
|
-
case "run_plugin": {
|
|
279
|
-
const source = args?.source;
|
|
280
|
-
const pluginName = args?.plugin_name;
|
|
281
|
-
if (!source || !pluginName) {
|
|
282
|
-
return {
|
|
283
|
-
isError: true,
|
|
284
|
-
content: [
|
|
285
|
-
{
|
|
286
|
-
type: "text",
|
|
287
|
-
text: "Missing required arguments: source and plugin_name",
|
|
288
|
-
},
|
|
289
|
-
],
|
|
290
|
-
};
|
|
291
|
-
}
|
|
292
|
-
const result = rustledger.runPlugin(source, pluginName);
|
|
293
|
-
if (result.errors?.length > 0) {
|
|
294
|
-
return {
|
|
295
|
-
isError: true,
|
|
296
|
-
content: [{ type: "text", text: formatErrors(result.errors) }],
|
|
297
|
-
};
|
|
298
|
-
}
|
|
299
|
-
return {
|
|
300
|
-
content: [
|
|
301
|
-
{
|
|
302
|
-
type: "text",
|
|
303
|
-
text: `Plugin processed ${result.directives.length} directives.`,
|
|
304
|
-
},
|
|
305
|
-
],
|
|
306
|
-
};
|
|
307
|
-
}
|
|
308
|
-
default:
|
|
309
|
-
return {
|
|
310
|
-
isError: true,
|
|
311
|
-
content: [{ type: "text", text: `Unknown tool: ${name}` }],
|
|
312
|
-
};
|
|
313
|
-
}
|
|
32
|
+
return handleToolCall(name, args);
|
|
314
33
|
}
|
|
315
34
|
catch (error) {
|
|
316
35
|
return {
|
|
@@ -324,148 +43,32 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
324
43
|
};
|
|
325
44
|
}
|
|
326
45
|
});
|
|
327
|
-
//
|
|
328
|
-
const RESOURCES = [
|
|
329
|
-
{
|
|
330
|
-
uri: "rustledger://docs/bql",
|
|
331
|
-
name: "BQL Query Language Reference",
|
|
332
|
-
description: "Documentation for Beancount Query Language",
|
|
333
|
-
mimeType: "text/markdown",
|
|
334
|
-
},
|
|
335
|
-
];
|
|
46
|
+
// List available resources
|
|
336
47
|
server.setRequestHandler(ListResourcesRequestSchema, async () => {
|
|
337
48
|
return { resources: RESOURCES };
|
|
338
49
|
});
|
|
50
|
+
// Read resource contents
|
|
339
51
|
server.setRequestHandler(ReadResourceRequestSchema, async (request) => {
|
|
340
52
|
const { uri } = request.params;
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
{
|
|
345
|
-
uri,
|
|
346
|
-
mimeType: "text/markdown",
|
|
347
|
-
text: BQL_DOCS,
|
|
348
|
-
},
|
|
349
|
-
],
|
|
350
|
-
};
|
|
53
|
+
const contents = getResourceContents(uri);
|
|
54
|
+
if (!contents) {
|
|
55
|
+
throw new Error(`Unknown resource: ${uri}`);
|
|
351
56
|
}
|
|
352
|
-
|
|
57
|
+
return { contents: [contents] };
|
|
58
|
+
});
|
|
59
|
+
// List available prompts
|
|
60
|
+
server.setRequestHandler(ListPromptsRequestSchema, async () => {
|
|
61
|
+
return { prompts: PROMPTS };
|
|
62
|
+
});
|
|
63
|
+
// Get prompt content
|
|
64
|
+
server.setRequestHandler(GetPromptRequestSchema, async (request) => {
|
|
65
|
+
const { name, arguments: args } = request.params;
|
|
66
|
+
return getPrompt(name, args);
|
|
353
67
|
});
|
|
354
|
-
function formatErrors(errors) {
|
|
355
|
-
return errors
|
|
356
|
-
.map((e) => {
|
|
357
|
-
const loc = e.line ? `:${e.line}${e.column ? `:${e.column}` : ""}` : "";
|
|
358
|
-
return `[${e.severity}]${loc} ${e.message}`;
|
|
359
|
-
})
|
|
360
|
-
.join("\n");
|
|
361
|
-
}
|
|
362
|
-
function formatQueryResult(result) {
|
|
363
|
-
if (!result.columns || result.columns.length === 0) {
|
|
364
|
-
return "No results.";
|
|
365
|
-
}
|
|
366
|
-
const { columns, rows } = result;
|
|
367
|
-
// Calculate column widths
|
|
368
|
-
const widths = columns.map((col, i) => {
|
|
369
|
-
const maxRowWidth = Math.max(...rows.map((row) => formatCell(row[i]).length));
|
|
370
|
-
return Math.max(col.length, maxRowWidth);
|
|
371
|
-
});
|
|
372
|
-
// Format header
|
|
373
|
-
const header = columns.map((col, i) => col.padEnd(widths[i])).join(" | ");
|
|
374
|
-
const separator = widths.map((w) => "-".repeat(w)).join("-+-");
|
|
375
|
-
// Format rows
|
|
376
|
-
const formattedRows = rows.map((row) => row.map((cell, i) => formatCell(cell).padEnd(widths[i])).join(" | "));
|
|
377
|
-
return [header, separator, ...formattedRows].join("\n");
|
|
378
|
-
}
|
|
379
|
-
function formatCell(value) {
|
|
380
|
-
if (value === null || value === undefined) {
|
|
381
|
-
return "";
|
|
382
|
-
}
|
|
383
|
-
if (typeof value === "object") {
|
|
384
|
-
// Handle Amount type
|
|
385
|
-
if ("number" in value && "currency" in value) {
|
|
386
|
-
const amount = value;
|
|
387
|
-
return `${amount.number} ${amount.currency}`;
|
|
388
|
-
}
|
|
389
|
-
// Handle Inventory type
|
|
390
|
-
if ("positions" in value) {
|
|
391
|
-
const inv = value;
|
|
392
|
-
return inv.positions
|
|
393
|
-
.map((p) => `${p.units.number} ${p.units.currency}`)
|
|
394
|
-
.join(", ");
|
|
395
|
-
}
|
|
396
|
-
return JSON.stringify(value);
|
|
397
|
-
}
|
|
398
|
-
return String(value);
|
|
399
|
-
}
|
|
400
|
-
// BQL Documentation
|
|
401
|
-
const BQL_DOCS = `# BQL - Beancount Query Language
|
|
402
|
-
|
|
403
|
-
BQL is a SQL-like query language for querying Beancount ledgers.
|
|
404
|
-
|
|
405
|
-
## Basic Syntax
|
|
406
|
-
|
|
407
|
-
\`\`\`sql
|
|
408
|
-
SELECT [DISTINCT] <target-spec>, ...
|
|
409
|
-
[FROM <from-spec>]
|
|
410
|
-
[WHERE <where-expression>]
|
|
411
|
-
[GROUP BY <group-spec>, ...]
|
|
412
|
-
[ORDER BY <order-spec>, ...]
|
|
413
|
-
[LIMIT <limit>]
|
|
414
|
-
\`\`\`
|
|
415
|
-
|
|
416
|
-
## Common Queries
|
|
417
|
-
|
|
418
|
-
### Account Balances
|
|
419
|
-
\`\`\`sql
|
|
420
|
-
BALANCES
|
|
421
|
-
-- or equivalently:
|
|
422
|
-
SELECT account, sum(position) GROUP BY account
|
|
423
|
-
\`\`\`
|
|
424
|
-
|
|
425
|
-
### Filter by Account
|
|
426
|
-
\`\`\`sql
|
|
427
|
-
SELECT date, narration, position
|
|
428
|
-
WHERE account ~ "Expenses:Food"
|
|
429
|
-
\`\`\`
|
|
430
|
-
|
|
431
|
-
### Filter by Date Range
|
|
432
|
-
\`\`\`sql
|
|
433
|
-
SELECT date, account, position
|
|
434
|
-
WHERE date >= 2024-01-01 AND date < 2024-02-01
|
|
435
|
-
\`\`\`
|
|
436
|
-
|
|
437
|
-
### Monthly Summary
|
|
438
|
-
\`\`\`sql
|
|
439
|
-
SELECT year(date), month(date), sum(position)
|
|
440
|
-
WHERE account ~ "Expenses"
|
|
441
|
-
GROUP BY year(date), month(date)
|
|
442
|
-
ORDER BY year(date), month(date)
|
|
443
|
-
\`\`\`
|
|
444
|
-
|
|
445
|
-
### Journal Entries
|
|
446
|
-
\`\`\`sql
|
|
447
|
-
JOURNAL "Assets:Checking"
|
|
448
|
-
\`\`\`
|
|
449
|
-
|
|
450
|
-
## Available Functions
|
|
451
|
-
|
|
452
|
-
- \`year(date)\`, \`month(date)\`, \`day(date)\` - Extract date parts
|
|
453
|
-
- \`sum(position)\` - Sum positions
|
|
454
|
-
- \`count()\` - Count entries
|
|
455
|
-
- \`first(x)\`, \`last(x)\` - First/last values
|
|
456
|
-
- \`min(x)\`, \`max(x)\` - Min/max values
|
|
457
|
-
|
|
458
|
-
## Operators
|
|
459
|
-
|
|
460
|
-
- \`~\` - Regex match (e.g., \`account ~ "Expenses:.*"\`)
|
|
461
|
-
- \`=\`, \`!=\`, \`<\`, \`>\`, \`<=\`, \`>=\` - Comparisons
|
|
462
|
-
- \`AND\`, \`OR\`, \`NOT\` - Boolean operators
|
|
463
|
-
`;
|
|
464
68
|
// Start the server
|
|
465
69
|
async function main() {
|
|
466
70
|
const transport = new StdioServerTransport();
|
|
467
71
|
await server.connect(transport);
|
|
468
|
-
// Log to stderr to avoid interfering with MCP protocol on stdout
|
|
469
72
|
console.error(`rustledger MCP server v${rustledger.version()} started`);
|
|
470
73
|
}
|
|
471
74
|
main().catch((error) => {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACtB,0BAA0B,EAC1B,yBAAyB,GAC1B,MAAM,oCAAoC,CAAC;AAE5C,kCAAkC;AAClC,OAAO,KAAK,UAAU,MAAM,kBAAk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E,KAAK,IAAI,EAAE;IAC5D,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;AAC9B,CAAC,CAAC,CAAC;AAEH,qBAAqB;AACrB,MAAM,CAAC,iBAAiB,CAAC,sBAAsB,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;IACjE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC;IACjD,OAAO,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AAC/B,CAAC,CAAC,CAAC;AAEH,mBAAmB;AACnB,KAAK,UAAU,IAAI;IACjB,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAChC,OAAO,CAAC,KAAK,CAAC,0BAA0B,UAAU,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;AAC1E,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,OAAO,CAAC,KAAK,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;IACrC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export interface PromptArgument {
|
|
2
|
+
name: string;
|
|
3
|
+
description: string;
|
|
4
|
+
required: boolean;
|
|
5
|
+
}
|
|
6
|
+
export interface PromptDefinition {
|
|
7
|
+
name: string;
|
|
8
|
+
description: string;
|
|
9
|
+
arguments: PromptArgument[];
|
|
10
|
+
}
|
|
11
|
+
export interface PromptMessage {
|
|
12
|
+
role: "user" | "assistant";
|
|
13
|
+
content: {
|
|
14
|
+
type: "text";
|
|
15
|
+
text: string;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export interface PromptResult {
|
|
19
|
+
messages: PromptMessage[];
|
|
20
|
+
[key: string]: unknown;
|
|
21
|
+
}
|
|
22
|
+
export declare const PROMPTS: PromptDefinition[];
|
|
23
|
+
export declare function getPrompt(name: string, args?: Record<string, string>): PromptResult;
|
|
24
|
+
//# sourceMappingURL=prompts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../src/prompts.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,cAAc,EAAE,CAAC;CAC7B;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,GAAG,WAAW,CAAC;IAC3B,OAAO,EAAE;QACP,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;CACH;AAED,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,aAAa,EAAE,CAAC;IAC1B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,eAAO,MAAM,OAAO,EAAE,gBAAgB,EAkCrC,CAAC;AAEF,wBAAgB,SAAS,CACvB,IAAI,EAAE,MAAM,EACZ,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC5B,YAAY,CAuFd"}
|