@rustledger/mcp-server 0.1.0

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 ADDED
@@ -0,0 +1,79 @@
1
+ # @rustledger/mcp-server
2
+
3
+ MCP (Model Context Protocol) server for [rustledger](https://rustledger.github.io) - validate, query, and format Beancount ledgers directly from AI assistants.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install -g @rustledger/mcp-server
9
+ ```
10
+
11
+ Or use directly with npx:
12
+
13
+ ```bash
14
+ npx @rustledger/mcp-server
15
+ ```
16
+
17
+ ## Configuration
18
+
19
+ ### Claude Desktop
20
+
21
+ Add to your `claude_desktop_config.json`:
22
+
23
+ ```json
24
+ {
25
+ "mcpServers": {
26
+ "rustledger": {
27
+ "command": "npx",
28
+ "args": ["-y", "@rustledger/mcp-server"]
29
+ }
30
+ }
31
+ }
32
+ ```
33
+
34
+ ### Claude Code
35
+
36
+ Add to your Claude Code settings:
37
+
38
+ ```json
39
+ {
40
+ "mcpServers": {
41
+ "rustledger": {
42
+ "command": "npx",
43
+ "args": ["-y", "@rustledger/mcp-server"]
44
+ }
45
+ }
46
+ }
47
+ ```
48
+
49
+ ## Available Tools
50
+
51
+ | Tool | Description |
52
+ |------|-------------|
53
+ | `validate` | Validate a Beancount ledger for errors |
54
+ | `query` | Run BQL queries on a ledger |
55
+ | `balances` | Get account balances (shorthand for BALANCES query) |
56
+ | `format` | Format a ledger with consistent alignment |
57
+ | `parse` | Parse a ledger and return structured data |
58
+ | `completions` | Get BQL query completions |
59
+ | `list_plugins` | List available native plugins |
60
+ | `run_plugin` | Run a native plugin on a ledger |
61
+
62
+ ## Example Usage
63
+
64
+ Once configured, you can ask your AI assistant:
65
+
66
+ - "Validate this beancount file for errors"
67
+ - "What's my current balance in Assets:Checking?"
68
+ - "Show me all restaurant expenses this month"
69
+ - "Format this beancount ledger"
70
+
71
+ ## Resources
72
+
73
+ The server also exposes documentation:
74
+
75
+ - `rustledger://docs/bql` - BQL Query Language Reference
76
+
77
+ ## License
78
+
79
+ GPL-3.0
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
package/dist/index.js ADDED
@@ -0,0 +1,475 @@
1
+ #!/usr/bin/env node
2
+ import { Server } from "@modelcontextprotocol/sdk/server/index.js";
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
6
+ import * as rustledger from "@rustledger/wasm";
7
+ // Initialize WASM module
8
+ rustledger.init();
9
+ const server = new Server({
10
+ name: "rustledger",
11
+ version: rustledger.version(),
12
+ }, {
13
+ capabilities: {
14
+ tools: {},
15
+ resources: {},
16
+ },
17
+ });
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
+ // List available tools
141
+ server.setRequestHandler(ListToolsRequestSchema, async () => {
142
+ return { tools: TOOLS };
143
+ });
144
+ // Handle tool calls
145
+ server.setRequestHandler(CallToolRequestSchema, async (request) => {
146
+ const { name, arguments: args } = request.params;
147
+ try {
148
+ switch (name) {
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
+ }
314
+ }
315
+ catch (error) {
316
+ return {
317
+ isError: true,
318
+ content: [
319
+ {
320
+ type: "text",
321
+ text: `Error: ${error instanceof Error ? error.message : String(error)}`,
322
+ },
323
+ ],
324
+ };
325
+ }
326
+ });
327
+ // Resources
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
+ ];
336
+ server.setRequestHandler(ListResourcesRequestSchema, async () => {
337
+ return { resources: RESOURCES };
338
+ });
339
+ server.setRequestHandler(ReadResourceRequestSchema, async (request) => {
340
+ const { uri } = request.params;
341
+ if (uri === "rustledger://docs/bql") {
342
+ return {
343
+ contents: [
344
+ {
345
+ uri,
346
+ mimeType: "text/markdown",
347
+ text: BQL_DOCS,
348
+ },
349
+ ],
350
+ };
351
+ }
352
+ throw new Error(`Unknown resource: ${uri}`);
353
+ });
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
+ // Start the server
465
+ async function main() {
466
+ const transport = new StdioServerTransport();
467
+ await server.connect(transport);
468
+ // Log to stderr to avoid interfering with MCP protocol on stdout
469
+ console.error(`rustledger MCP server v${rustledger.version()} started`);
470
+ }
471
+ main().catch((error) => {
472
+ console.error("Fatal error:", error);
473
+ process.exit(1);
474
+ });
475
+ //# sourceMappingURL=index.js.map
@@ -0,0 +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,kBAAkB,CAAC;AAE/C,yBAAyB;AACzB,UAAU,CAAC,IAAI,EAAE,CAAC;AAElB,MAAM,MAAM,GAAG,IAAI,MAAM,CACvB;IACE,IAAI,EAAE,YAAY;IAClB,OAAO,EAAE,UAAU,CAAC,OAAO,EAAE;CAC9B,EACD;IACE,YAAY,EAAE;QACZ,KAAK,EAAE,EAAE;QACT,SAAS,EAAE,EAAE;KACd;CACF,CACF,CAAC;AAEF,mBAAmB;AACnB,MAAM,KAAK,GAAG;IACZ;QACE,IAAI,EAAE,UAAU;QAChB,WAAW,EACT,8FAA8F;QAChG,WAAW,EAAE;YACX,IAAI,EAAE,QAAiB;YACvB,UAAU,EAAE;g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,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;QAC/C,CAAC;QACD,wBAAwB;QACxB,IAAI,WAAW,IAAI,KAAK,EAAE,CAAC;YACzB,MAAM,GAAG,GAAG,KAA8E,CAAC;YAC3F,OAAO,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;AAED,oBAAoB;AACpB,MAAM,QAAQ,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8DhB,CAAC;AAEF,mBAAmB;AACnB,KAAK,UAAU,IAAI;IACjB,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAChC,iEAAiE;IACjE,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"}
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "@rustledger/mcp-server",
3
+ "version": "0.1.0",
4
+ "description": "MCP server for rustledger - validate, query, and format Beancount ledgers",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "bin": {
8
+ "rustledger-mcp": "dist/index.js"
9
+ },
10
+ "scripts": {
11
+ "build": "tsc",
12
+ "dev": "tsc --watch",
13
+ "start": "node dist/index.js",
14
+ "prepublishOnly": "npm run build"
15
+ },
16
+ "keywords": [
17
+ "mcp",
18
+ "beancount",
19
+ "accounting",
20
+ "ledger",
21
+ "finance",
22
+ "rustledger"
23
+ ],
24
+ "author": "Rustledger Contributors",
25
+ "license": "GPL-3.0",
26
+ "repository": {
27
+ "type": "git",
28
+ "url": "https://github.com/rustledger/rustledger"
29
+ },
30
+ "homepage": "https://rustledger.github.io",
31
+ "dependencies": {
32
+ "@modelcontextprotocol/sdk": "^1.0.0",
33
+ "@rustledger/wasm": "^0.1.0"
34
+ },
35
+ "devDependencies": {
36
+ "@types/node": "^22.0.0",
37
+ "typescript": "^5.7.0"
38
+ },
39
+ "engines": {
40
+ "node": ">=18"
41
+ },
42
+ "publishConfig": {
43
+ "access": "public"
44
+ },
45
+ "files": [
46
+ "dist",
47
+ "README.md"
48
+ ]
49
+ }