lunchmoney-mcp
CLAUDE.md109 starsChanged 4 months agoMITView on GitHub
MCP (Model Context Protocol) server for the LunchMoney personal finance API (v2). Provides 59 tools across 10 domains (transactions, categories, budgets, manual accounts, tags, recurring items, user, Plaid accounts, crypto, balance history). Uses stdio transport and is published to npm as @akutishevsky/lunchmoney-mcp. Tests live in test/*.test.mjs and are plain ESM JavaScript, not TypeScript: tsconfig.json sets rootDir: ./src, so tests can't be compiled by the main build. They import the compiled output from build/, which is why npm test builds first…
The file
We split this CLAUDE.md into the rules it gives an agent
9 rules. About 0 are common, 2 are distinctive, and 7 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
7
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 44
Every tool uses server.registerTool() with a config object containing description, optional inputSchema, and annotations:
- Very specific: line 79
All responses use formatData() (TOON encoding) — never raw JSON or markdown
- Very specific: line 86
Every tool must include an annotations object with exactly one of these hints:
- Very specific: line 98
Add or edit the tool file in src/tools/
- Very specific: line 99
If new file: export register[Domain]Tools(server) and call it from src/index.ts
- Very specific: line 100
Add any new response types to src/types.ts
- Very specific: line 101
Add the tool entry to manifest.json (for DXT packaging)
- Distinctive: line 106
Always execute tasks in parallel when possible.
- Distinctive: line 108
When unsure about something — an API, a library, a protocol, a format, or any technical concept — use web search to look it up before …
≈ “Common” is an estimate: at least 1 in 5 of the 12,729 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Project Overview
MCP (Model Context Protocol) server for the LunchMoney personal finance API (v2). Provides 59 tools across 10 domains (transactions, categories, budgets, manual accounts, tags, recurring items, user, Plaid accounts, crypto, balance history). Uses stdio transport and is published to npm as @akutishevsky/lunchmoney-mcp.
Commands
npm run build— compile TypeScript and chmod the entry pointnpm run build:mcpb— build + package as.mcpbfor Claude Desktopnpm run dev— run with MCP Inspector (setLUNCHMONEY_API_TOKENin the script first)npm run format— run Prettier on the entire codebasenpm test— build, then run the test suite with Node's built-in runner
Tests live in test/*.test.mjs and are plain ESM JavaScript, not TypeScript: tsconfig.json sets rootDir: ./src, so tests can't be compiled by the main build. They import the compiled output from build/, which is why npm test builds first — that also makes the run a typecheck. Shared fixtures (sandbox directories, magic-byte samples, env-var juggling) live in test/helpers.mjs; use them rather than rolling new ones.
Coverage is currently limited to src/attachments.ts, the security-sensitive path from issue #16. The tool handlers themselves are still exercised manually via npm run dev with the MCP Inspector against a real LunchMoney account.
npm run lint is currently broken — typescript-eslint does not yet support TypeScript 7. This predates the test suite.
A husky pre-commit hook runs npm run format automatically before every commit.
Architecture
Entry point: src/index.ts — creates McpServer, registers all tool modules, initializes config, connects via StdioServerTransport.
Config: src/config.ts — singleton initialized at startup via initializeConfig(). Requires LUNCHMONEY_API_TOKEN env var. Base URL (https://api.lunchmoney.dev/v2) is hardcoded. Access via getConfig().
Debug logging: Set LUNCHMONEY_DEBUG=true to log API requests and responses (method, path, status, duration, body) to stderr. Controlled via isDebug() in src/api.ts.
Types: src/types.ts — TypeScript interfaces matching LunchMoney API response shapes (snake_case field names).
Attachments: src/attachments.ts — reads local files for attach_file_to_transaction. Treats file_path as hostile input, since it reaches the server from a model that may be acting on untrusted content. The MIME type is decided by sniffing the file's leading bytes, never by its extension or the caller's content_type; the optional LUNCHMONEY_ATTACHMENTS_DIR confines reads to one directory, enforced after realpath. Kept as its own module so it can be unit-tested without standing up an McpServer. Changes here need a matching test in test/.
Tools: src/tools/ — one file per domain. Each exports a register[Domain]Tools(server: McpServer) function called from index.ts.
Response format: src/format.ts — uses TOON encoding instead of JSON for tool responses. TOON is a compact text format that reduces token count by stripping quotes and braces. Before encoding, compact() drops object keys that are blank (null/undefined/empty array) in every element of an array, while keeping keys that are partially present as explicit nulls. This preserves key uniformity across rows so TOON emits its compact tabular form (header once, rows as CSV) instead of a verbose repeated-key list. Primitive arrays (e.g. tag_ids) are joined into a single |-delimited scalar so they don't disqualify a row from the tabular form; arrays of objects (e.g. children, files) are left intact and compacted recursively.
Tool Implementation Pattern
Every tool uses server.registerTool() with a config object containing description, optional inputSchema, and annotations:
import { formatData } from "../format.js";
server.registerTool(
"snake_case_name",
{
description: "Description for AI",
inputSchema: {
/* Zod fields with .describe() — no z.object() wrapper */
field: z.string().describe("Field description"),
},
annotations: {
readOnlyHint: true, // see annotation guide below
},
},
async ({ field }) => {
const response = await api.get(`/endpoint`);
if (!response.ok) {
return handleApiError(response, "Failed to do something");
}
return dataResponse(await response.json());
},
);In practice, prefer the shared helpers from src/api.ts:
api.{get,post,put,delete,upload} (which include retry, debug
logging, and auth), plus dataResponse, successResponse,
handleApiError, and catchError.
Key conventions:
- Tool names are
snake_case; Zod.describe()is required on all parameters for AI discoverability - All responses use
formatData()(TOON encoding) — never raw JSON or markdown - Error responses use
errorResponse()andgetErrorMessage()fromsrc/errors.ts - GET requests with optional filters use
URLSearchParams, only appending defined values - Tools with no parameters omit
inputSchema
Tool Annotations
Every tool must include an annotations object with exactly one of these hints:
| Annotation | When to use | Examples |
readOnlyHint: true | GET requests that only read data | get_transactions, get_user |
destructiveHint: true | DELETE requests or irreversible operations | delete_category, force_delete_category |
idempotentHint: true | PUT/upsert requests (same args → same result) | update_transaction, upsert_budget |
idempotentHint: false | POST requests that create new resources | create_transactions, create_asset |
openWorldHint: true | Triggers external systems beyond LunchMoney | trigger_plaid_fetch |
Adding a New Tool
- Add or edit the tool file in
src/tools/ - If new file: export
register[Domain]Tools(server)and call it fromsrc/index.ts - Add any new response types to
src/types.ts - Add the tool entry to
manifest.json(for DXT packaging) - Include the appropriate
annotations(see table above)
Workflow Preferences
Always execute tasks in parallel when possible. If multiple independent operations need to be performed (e.g., reading files, running searches, editing unrelated files, running builds), do them simultaneously rather than sequentially. Only run tasks sequentially when there is a dependency between them.
When unsure about something — an API, a library, a protocol, a format, or any technical concept — use web search to look it up before responding. Do not guess or speculate; verify first.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

