@dizzlkheinz/ynab-mcpb 0.16.0 → 0.17.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.
Files changed (114) hide show
  1. package/.code/agents/0098661e-0fa3-4990-beb9-c0cbf3f123aa/status.txt +1 -0
  2. package/.code/agents/1324/exec-call_tIpx9uV1TpARbAMZonRQm8AO.txt +757 -0
  3. package/.code/agents/1572/exec-call_GjVFBFOWcY7lE0idc5nWlLNh.txt +781 -0
  4. package/.code/agents/1846/exec-call_1YNAVD18RjrMN7JnfkkQhUP3.txt +766 -0
  5. package/.code/agents/1846/exec-call_lh3lDzE4WJAh1lFiomiiZ73D.txt +766 -0
  6. package/.code/agents/2038/exec-call_DYwOukaYsL8VCONWmV2rUW5u.txt +766 -0
  7. package/.code/agents/2038/exec-call_c7fOQ7UrpVcTtvdfGBRM146V.txt +652 -0
  8. package/.code/agents/2038/exec-call_ySNyq9Mm55jWE480s54r5QcA.txt +766 -0
  9. package/.code/agents/2256/exec-call_AtPcRWPmFPMcmX6qOFm1fCEY.txt +766 -0
  10. package/.code/agents/2454/exec-call_aFJpupwjfZeOBm7ixI5Vc8z2.txt +766 -0
  11. package/.code/agents/2454/exec-call_wogZ4HfXTodTEXvdgXlVUBpv.txt +766 -0
  12. package/.code/agents/2e905864-aa07-4314-bcf9-c5b32277e4ac/result.txt +36 -0
  13. package/.code/agents/3073/exec-call_Peeagc9DxGYLgE6pNdMZhqIE.txt +766 -0
  14. package/.code/agents/3073/exec-call_d2YSE3hXF08KRSoUM3qd8Z3x.txt +766 -0
  15. package/.code/agents/335aa031-466d-4fb7-925f-3cd864e264d0/result.txt +191 -0
  16. package/.code/agents/3364/exec-call_NbhIrsM5HhyDZDmJZG5CuCYL.txt +766 -0
  17. package/.code/agents/3364/exec-call_cKtJg0NrXiwXEFwlsE3uPZRA.txt +766 -0
  18. package/.code/agents/36d98414-5cde-4d9d-9a67-a240a18c1f07/result.txt +189 -0
  19. package/.code/agents/4604e866-b7b8-44f5-992f-2f683b0a523b/status.txt +1 -0
  20. package/.code/agents/5f8dc01c-47b3-4163-b0b3-aa31be89fcdc/status.txt +1 -0
  21. package/.code/agents/7/exec-call_HltHpkDox0Zm1vGEjdksUgpE.txt +1120 -0
  22. package/.code/agents/7/exec-call_LCATrOPPAgbxW9Q1z0XaVi2E.txt +2646 -0
  23. package/.code/agents/7/exec-call_W8DeRfNG9hvbgVFvf0clBf6R.txt +2646 -0
  24. package/.code/agents/94a0ddf3-a304-4ec3-913e-3cceef509948/error.txt +1 -0
  25. package/.code/agents/e2c752b7-711d-423a-af57-f53c809deb84/result.txt +160 -0
  26. package/.code/agents/e6601719-c31f-4a0e-8c71-d70787d0ab71/status.txt +1 -0
  27. package/.code/agents/f250b7ed-5bd5-4036-aa8c-ce63caee7d61/result.txt +20 -0
  28. package/AGENTS.md +1 -36
  29. package/CLAUDE.md +131 -51
  30. package/NUL +0 -1
  31. package/README.md +27 -14
  32. package/dist/bundle/index.cjs +41 -41
  33. package/dist/server/YNABMCPServer.js +28 -381
  34. package/dist/server/config.d.ts +2 -0
  35. package/dist/server/config.js +1 -0
  36. package/dist/tools/accountTools.d.ts +2 -0
  37. package/dist/tools/accountTools.js +45 -0
  38. package/dist/tools/adapters.d.ts +12 -0
  39. package/dist/tools/adapters.js +25 -0
  40. package/dist/tools/budgetTools.d.ts +2 -0
  41. package/dist/tools/budgetTools.js +30 -0
  42. package/dist/tools/categoryTools.d.ts +2 -0
  43. package/dist/tools/categoryTools.js +45 -0
  44. package/dist/tools/monthTools.d.ts +2 -0
  45. package/dist/tools/monthTools.js +32 -0
  46. package/dist/tools/payeeTools.d.ts +2 -0
  47. package/dist/tools/payeeTools.js +32 -0
  48. package/dist/tools/reconciliation/index.d.ts +2 -0
  49. package/dist/tools/reconciliation/index.js +33 -0
  50. package/dist/tools/schemas/common.d.ts +3 -0
  51. package/dist/tools/schemas/common.js +3 -0
  52. package/dist/tools/schemas/outputs/comparisonOutputs.d.ts +1 -1
  53. package/dist/tools/transactionTools.d.ts +2 -0
  54. package/dist/tools/transactionTools.js +129 -0
  55. package/dist/tools/utilityTools.d.ts +3 -1
  56. package/dist/tools/utilityTools.js +32 -2
  57. package/dist/types/index.d.ts +1 -0
  58. package/dist/types/toolRegistration.d.ts +27 -0
  59. package/dist/types/toolRegistration.js +1 -0
  60. package/package.json +2 -2
  61. package/scripts/run-domain-integration-tests.js +4 -1
  62. package/src/__tests__/workflows.e2e.test.ts +1 -7
  63. package/src/server/YNABMCPServer.ts +33 -519
  64. package/src/server/__tests__/toolRegistration.test.ts +236 -0
  65. package/src/server/config.ts +1 -0
  66. package/src/tools/__tests__/adapters.test.ts +113 -0
  67. package/src/tools/__tests__/transactionTools.test.ts +90 -17
  68. package/src/tools/__tests__/utilityTools.test.ts +7 -7
  69. package/src/tools/accountTools.ts +53 -0
  70. package/src/tools/adapters.ts +74 -0
  71. package/src/tools/budgetTools.ts +37 -0
  72. package/src/tools/categoryTools.ts +53 -0
  73. package/src/tools/monthTools.ts +39 -0
  74. package/src/tools/payeeTools.ts +39 -0
  75. package/src/tools/reconciliation/index.ts +45 -0
  76. package/src/tools/schemas/common.ts +18 -0
  77. package/src/tools/transactionTools.ts +150 -0
  78. package/src/tools/utilityTools.ts +42 -2
  79. package/src/types/index.ts +3 -0
  80. package/src/types/toolRegistration.ts +88 -0
  81. package/.dxtignore +0 -57
  82. package/.github/workflows/pr-description-check.yml +0 -88
  83. package/CODEREVIEW_RESPONSE.md +0 -128
  84. package/SCHEMA_IMPROVEMENT_SUMMARY.md +0 -120
  85. package/TESTING_NOTES.md +0 -217
  86. package/accountactivity-merged.csv +0 -149
  87. package/bundle-analysis.html +0 -13110
  88. package/docs/README.md +0 -72
  89. package/docs/getting-started/CONFIGURATION.md +0 -175
  90. package/docs/getting-started/INSTALLATION.md +0 -333
  91. package/docs/getting-started/QUICKSTART.md +0 -282
  92. package/docs/guides/ARCHITECTURE.md +0 -533
  93. package/docs/guides/DEPLOYMENT.md +0 -189
  94. package/docs/guides/INTEGRATION_TESTING.md +0 -730
  95. package/docs/guides/TESTING.md +0 -591
  96. package/docs/plans/2025-11-20-reloadable-config-token-validation.md +0 -93
  97. package/docs/plans/2025-11-21-fix-transaction-cached-property.md +0 -362
  98. package/docs/plans/2025-11-21-reconciliation-error-handling.md +0 -90
  99. package/docs/plans/2025-11-21-v014-hardening.md +0 -153
  100. package/docs/plans/reconciliation-v2-redesign.md +0 -1571
  101. package/docs/reconciliation-flow.md +0 -83
  102. package/docs/reference/EXAMPLES.md +0 -946
  103. package/docs/reference/TOOLS.md +0 -348
  104. package/docs/reference/TROUBLESHOOTING.md +0 -481
  105. package/fix-types.sh +0 -17
  106. package/test-csv-sample.csv +0 -28
  107. package/test-exports/sample_bank_statement.csv +0 -7
  108. package/test-reconcile-autodetect.js +0 -40
  109. package/test-reconcile-tool.js +0 -152
  110. package/test-reconcile-with-csv.cjs +0 -89
  111. package/test-statement.csv +0 -8
  112. package/test_debug.js +0 -47
  113. package/test_mcp_tools.mjs +0 -75
  114. package/test_simple.mjs +0 -16
@@ -0,0 +1 @@
1
+ Failed to spawn sandboxed agent: batch file arguments are invalid
@@ -0,0 +1,160 @@
1
+ Here’s a concise blueprint for Phase 1 that matches the factory pattern doc and repo conventions.
2
+
3
+ **Module layout (production-ready, minimal)**
4
+ - `src/types/toolRegistration.ts`: canonical types/interfaces for tool definitions and adapters.
5
+ - `src/tools/adapters/index.ts`: adapter factory functions for the five categories (adapt, adaptNoInput, adaptWithDelta, adaptWrite, inline); export typed helpers.
6
+ - `src/tools/schemas/common.ts`: shared zod schemas for inputs/outputs/memo/delta, reusable across tools.
7
+ - `src/tools/index.ts`: re-export adapters and shared schemas (and future tool registrations).
8
+ - Tests: `src/__tests__/tools/adapters.test.ts` (unit, Vitest).
9
+
10
+ **Core types (toolRegistration.ts)**
11
+ ```ts
12
+ import { z } from 'zod';
13
+
14
+ export type ToolKind =
15
+ | 'adapt' // input schema -> handler(args) -> output
16
+ | 'adaptNoInput' // no input -> handler() -> output
17
+ | 'adaptWithDelta' // input + delta/metadata -> output + delta?
18
+ | 'adaptWrite' // input triggers mutation; output includes status
19
+ | 'inline'; // small inline tools (no registration factory)
20
+
21
+ export interface ToolContext {
22
+ logger?: { debug?: (...args: any[]) => void; info?: (...args: any[]) => void; error?: (...args: any[]) => void };
23
+ now?: () => Date;
24
+ // extend later with cache, env, config
25
+ }
26
+
27
+ export type ToolHandler<Input, Output> = (args: {
28
+ input: Input;
29
+ context?: ToolContext;
30
+ }) => Promise<Output> | Output;
31
+
32
+ export type ToolHandlerNoInput<Output> = (args?: { context?: ToolContext }) => Promise<Output> | Output;
33
+
34
+ export interface ToolRegistration<Input, Output> {
35
+ id: string; // kebab-case tool id
36
+ description: string;
37
+ inputSchema: z.ZodType<Input>;
38
+ outputSchema?: z.ZodType<Output>;
39
+ handler: ToolHandler<Input, Output>;
40
+ kind?: ToolKind; // optional hint for tooling/metrics
41
+ }
42
+
43
+ export interface ToolRegistrationNoInput<Output>
44
+ extends Omit<ToolRegistration<undefined, Output>, 'inputSchema' | 'handler'> {
45
+ handler: ToolHandlerNoInput<Output>;
46
+ }
47
+ ```
48
+
49
+ **Shared schemas (schemas/common.ts)**
50
+ ```ts
51
+ import { z } from 'zod';
52
+
53
+ export const memoSchema = z.string().max(500).optional();
54
+ export const baseInputSchema = z.object({ memo: memoSchema }).strip();
55
+ export const deltaSchema = z.object({
56
+ deltaToken: z.string(),
57
+ revision: z.number().int().nonnegative(),
58
+ });
59
+ export const statusSchema = z.object({
60
+ ok: z.boolean(),
61
+ message: z.string().optional(),
62
+ });
63
+ ```
64
+
65
+ **Adapters (tools/adapters/index.ts)**
66
+ ```ts
67
+ import { z } from 'zod';
68
+ import {
69
+ ToolRegistration,
70
+ ToolRegistrationNoInput,
71
+ ToolHandler,
72
+ ToolHandlerNoInput,
73
+ } from '../../types/toolRegistration';
74
+
75
+ type AdapterResult<Input, Output> = ToolRegistration<Input, Output>;
76
+
77
+ export function adapt<Input, Output>(
78
+ config: Omit<ToolRegistration<Input, Output>, 'kind'>,
79
+ ): AdapterResult<Input, Output> {
80
+ return { ...config, kind: 'adapt' };
81
+ }
82
+
83
+ export function adaptNoInput<Output>(
84
+ config: Omit<ToolRegistrationNoInput<Output>, 'kind' | 'inputSchema'>,
85
+ ): AdapterResult<undefined, Output> {
86
+ return {
87
+ ...config,
88
+ inputSchema: z.void(),
89
+ kind: 'adaptNoInput',
90
+ };
91
+ }
92
+
93
+ export function adaptWithDelta<Input, Output>(
94
+ config: Omit<ToolRegistration<Input, Output>, 'kind'>,
95
+ ): AdapterResult<Input, Output> {
96
+ return { ...config, kind: 'adaptWithDelta' };
97
+ }
98
+
99
+ export function adaptWrite<Input, Output>(
100
+ config: Omit<ToolRegistration<Input, Output>, 'kind'>,
101
+ ): AdapterResult<Input, Output> {
102
+ return { ...config, kind: 'adaptWrite' };
103
+ }
104
+
105
+ // inline: kept simple; bypasses factory if needed, but helper for consistency
106
+ export function inline<Input, Output>(
107
+ config: ToolRegistration<Input, Output>,
108
+ ): AdapterResult<Input, Output> {
109
+ return { ...config, kind: 'inline' };
110
+ }
111
+
112
+ export type {
113
+ ToolRegistration,
114
+ ToolRegistrationNoInput,
115
+ ToolHandler,
116
+ ToolHandlerNoInput,
117
+ };
118
+ ```
119
+
120
+ **Exports (src/tools/index.ts)**
121
+ ```ts
122
+ export * from './adapters';
123
+ export * as commonSchemas from './schemas/common';
124
+ ```
125
+
126
+ **Unit test plan (src/__tests__/tools/adapters.test.ts)**
127
+ - `adapt`: returns config with `kind: 'adapt'`, preserves handler and schema identity, and is type-safe for input/output.
128
+ - `adaptNoInput`: sets `inputSchema` to `z.void()`, `kind: 'adaptNoInput'`, handler invoked without input, rejects passing unexpected input at runtime (zod parse).
129
+ - `adaptWithDelta`: attaches `kind: 'adaptWithDelta'`, works with a schema that includes delta fields (e.g., merged input + `deltaSchema`).
130
+ - `adaptWrite`: sets `kind: 'adaptWrite'`, supports output schema with status; ensure no mutation to original config.
131
+ - `inline`: passes through config and sets `kind: 'inline'`.
132
+ - Shared behaviors: returned objects are new instances (no mutation), required fields (`id`, `description`, `handler`) are preserved.
133
+ - Validation snapshots: optional quick zod parse test per adapter (when schema is provided) to prove wiring.
134
+
135
+ **Test scaffolding snippet**
136
+ ```ts
137
+ import { describe, it, expect } from 'vitest';
138
+ import { z } from 'zod';
139
+ import {
140
+ adapt,
141
+ adaptNoInput,
142
+ adaptWithDelta,
143
+ adaptWrite,
144
+ inline,
145
+ } from '../../tools/adapters';
146
+ import { deltaSchema, statusSchema } from '../../tools/schemas/common';
147
+
148
+ describe('tool adapters', () => {
149
+ it('adapt sets kind and preserves config', async () => { /* ... */ });
150
+ it('adaptNoInput sets z.void and kind', async () => { /* ... */ });
151
+ it('adaptWithDelta supports delta schema', async () => { /* ... */ });
152
+ it('adaptWrite marks kind adaptWrite', async () => { /* ... */ });
153
+ it('inline marks kind inline', async () => { /* ... */ });
154
+ });
155
+ ```
156
+
157
+ **Notes**
158
+ - Keep adapters thin; no side effects. `kind` supports metrics/routing; callers can branch on it.
159
+ - Shared schemas stay minimal; expand as new tools land.
160
+ - Maintain kebab-case `id` per repo guidance; single export surface via `src/tools/index.ts`.
@@ -0,0 +1,20 @@
1
+ **MCP Tool Catalogue**
2
+ - **Budgets** (`src/server/YNABMCPServer.ts:467-540`): `list_budgets` (delta adapter; input inline `emptyObjectSchema`; output `ListBudgetsOutputSchema`), `get_budget` (read adapter; input `GetBudgetSchema` from `src/tools/budgetTools.ts`; output `GetBudgetOutputSchema`), `set_default_budget` (inline server write; input inline `setDefaultBudgetSchema`; output `SetDefaultBudgetOutputSchema`), `get_default_budget` (inline server read; input inline `emptyObjectSchema`; output `GetDefaultBudgetOutputSchema`).
3
+ - **Accounts** (`src/server/YNABMCPServer.ts:573-615`): `list_accounts` (delta; input `ListAccountsSchema`; output `ListAccountsOutputSchema`), `get_account` (read; input `GetAccountSchema`; output `GetAccountOutputSchema`), `create_account` (write; input `CreateAccountSchema`; output inline `LooseObjectSchema`).
4
+ - **Transactions – read/delta** (`src/server/YNABMCPServer.ts:618-692`): `list_transactions` (delta; input `ListTransactionsSchema`; output `LooseObjectSchema`), `export_transactions` (read; input `ExportTransactionsSchema`; output `ExportTransactionsOutputSchema`), `compare_transactions` (read; input `CompareTransactionsSchema`; output `CompareTransactionsOutputSchema`), `reconcile_account` (delta; input `ReconcileAccountSchema`; output `LooseObjectSchema`), `get_transaction` (read; input `GetTransactionSchema`; output `GetTransactionOutputSchema`).
5
+ - **Transactions – write** (`src/server/YNABMCPServer.ts:694-785`): `create_transaction`, `create_transactions`, `create_receipt_split_transaction` (all write adapters; inputs `CreateTransactionSchema`/`CreateTransactionsSchema`/`CreateReceiptSplitTransactionSchema`; outputs `LooseObjectSchema`), `update_transaction`, `update_transactions` (write; inputs `UpdateTransactionSchema`/`UpdateTransactionsSchema`; outputs `LooseObjectSchema`), `delete_transaction` (write; input `DeleteTransactionSchema`; output `LooseObjectSchema`).
6
+ - **Categories** (`src/server/YNABMCPServer.ts:787-830`): `list_categories` (delta; input `ListCategoriesSchema`; output `ListCategoriesOutputSchema`), `get_category` (read; input `GetCategorySchema`; output `GetCategoryOutputSchema`), `update_category` (write; input `UpdateCategorySchema`; output `LooseObjectSchema`).
7
+ - **Payees** (`src/server/YNABMCPServer.ts:832-860`): `list_payees` (delta; input `ListPayeesSchema`; output `ListPayeesOutputSchema`), `get_payee` (read; input `GetPayeeSchema`; output `GetPayeeOutputSchema`).
8
+ - **Months** (`src/server/YNABMCPServer.ts:862-889`): `get_month` (read; input `GetMonthSchema`; output `GetMonthOutputSchema`), `list_months` (delta; input `ListMonthsSchema`; output `ListMonthsOutputSchema`).
9
+ - **Utilities/Local** (`src/server/YNABMCPServer.ts:892-998`): `get_user` (no-input adapter; input inline `emptyObjectSchema`; output `GetUserOutputSchema`), `convert_amount` (inline local handler; input `ConvertAmountSchema` from `src/tools/utilityTools.ts`; output `ConvertAmountOutputSchema`), `diagnostic_info` (inline server; input inline `diagnosticInfoSchema`; output `DiagnosticInfoOutputSchema`), `clear_cache` (inline server; input inline `emptyObjectSchema`; output `ClearCacheOutputSchema`), `set_output_format` (inline server; input inline `setOutputFormatSchema`; output `SetOutputFormatOutputSchema`).
10
+
11
+ **Inline Schema Observations**
12
+ - Inline definitions in `src/server/YNABMCPServer.ts:446-465` (`emptyObjectSchema`, `LooseObjectSchema`, `setDefaultBudgetSchema`, `diagnosticInfoSchema`, `setOutputFormatSchema`) are reused across tools and could move to a shared schema module (e.g., `src/tools/schemas/common.ts`) to reduce duplication and keep registrations declarative.
13
+ - Most tools already pull input/output schemas from feature modules (`src/tools/*` and `src/tools/schemas/outputs/index.ts`); only the inline schemas above break that pattern.
14
+
15
+ **Server-Owned Inline Tools to Keep Inline**
16
+ - `set_default_budget`, `get_default_budget`, `diagnostic_info`, `clear_cache`, and `set_output_format` rely on server state (default budget cache warming, diagnostic manager, cache manager, response formatter) and likely stay in `YNABMCPServer` even if their schemas are centralized.
17
+
18
+ **Notes for Migration**
19
+ - Budget-aware tools share `defaultArgumentResolver` to inject `budget_id`; keep this resolver available wherever registrations move.
20
+ - `LooseObjectSchema` is the permissive output for many write/delta tools—consider replacing with explicit output schemas in `src/tools/schemas/outputs` if stability is desired.
package/AGENTS.md CHANGED
@@ -1,36 +1 @@
1
- # Repository Guidelines
2
-
3
- ## Project Structure & Module Organization
4
-
5
- `src/` hosts all TypeScript modules: `server/` wires the MCP host, `tools/` defines tool handlers, `utils/` shares primitives, and `index.ts` is the entry point.
6
- Tests live in `src/__tests__` (unit, integration, e2e, performance) with sanitized fixtures in `test-exports/` and artifacts in `test-results/`.
7
- Documentation stays in `docs/`, automation in `scripts/`, and compiled output in `dist/` plus `dist/bundle/`; never edit generated files directly.
8
-
9
- ## Build, Test, and Development Commands
10
-
11
- - `npm run dev` - incremental TypeScript build while coding.
12
- - `npm run build` - clean `dist/`, compile, then esbuild-bundle.
13
- - `npm run build:prod` / `npm run package:mcpb` - production bundle with verification and MCPB packing.
14
- - `npm start` or `npm run start:mcp` - launch compiled server with `.env`.
15
- - `npm run validate-env` - confirm required secrets before tool runs.
16
-
17
- ## Coding Style & Naming Conventions
18
-
19
- Prettier enforces 2-space indent, 100-char width, single quotes, and semicolons; verify with `npm run format:check`.
20
- ESLint (`npm run lint`) must pass before commits; prefer `npm run lint:fix` for safe rewrites.
21
- Name files after their capability (`budgetService.ts`, `create-account.tool.ts`) and keep MCP tool identifiers kebab-case with ES modules and explicit dependency injection.
22
-
23
- ## Testing Guidelines
24
-
25
- Vitest powers the suite: `npm test` runs everything then filters failures into `test-results.json`, while `test:unit`, `test:integration`, `test:e2e`, `test:performance`, and `test:coverage` target specific goals.
26
- Use `test:comprehensive` (tsx runner) for orchestration flows, mirror test filenames to the feature, and update fixtures only with scrubbed data.
27
-
28
- ## Commit & Pull Request Guidelines
29
-
30
- History follows Conventional Commits (`docs:`, `fix:`, `refactor:`); keep patches focused and note verification commands in every PR.
31
- Run `npm run pr:description` to refresh `.pr-description.md` before `gh pr create`, link issues, and attach screenshots or sample JSON for user-facing changes.
32
-
33
- ## Environment & Security Tips
34
-
35
- Clone `.env` from `.env.example`, set `YNAB_ACCESS_TOKEN` plus cache settings, then rerun `npm run validate-env` after edits.
36
- Avoid logging secrets, prefer sample budgets when demonstrating behaviors, and delete stray exports from `test-exports/` before pushing.
1
+ CLAUDE.md
package/CLAUDE.md CHANGED
@@ -4,7 +4,9 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
4
4
 
5
5
  ## Project Overview
6
6
 
7
- This is a Model Context Protocol (MCP) server for YNAB (You Need A Budget) integration, enabling AI assistants to interact with YNAB budgets, accounts, transactions, and categories. The codebase uses TypeScript with a modular architecture introduced in v0.8.x.
7
+ This is a Model Context Protocol (MCP) server for YNAB (You Need A Budget) integration, enabling AI assistants to interact with YNAB budgets, accounts, transactions, and categories. The codebase uses TypeScript with a modular, service-oriented architecture.
8
+
9
+ **Current Version:** 0.17.0
8
10
 
9
11
  ## Essential Commands
10
12
 
@@ -18,22 +20,31 @@ npm run dev # TypeScript watch mode for development
18
20
  npm run type-check # Run TypeScript type checking without emitting files
19
21
  ```
20
22
 
21
- See [docs/development/BUILD.md](docs/development/BUILD.md) for detailed build information.
22
-
23
23
  ### Testing
24
24
 
25
25
  ```bash
26
- npm test # Run all unit tests + filter results
27
- npm run test:unit # Unit tests only (fast, mocked dependencies)
28
- npm run test:integration # Integration tests with mocked YNAB API
29
- npm run test:e2e # End-to-end tests (requires real YNAB token)
30
- npm run test:performance # Performance and load tests
31
- npm run test:coverage # Generate coverage report (requires 80% coverage)
32
- npm run test:watch # Watch mode for test development
26
+ npm test # Run all unit tests + filter results
27
+ npm run test:unit # Unit tests only (fast, mocked dependencies)
28
+ npm run test:integration # Integration tests (core only)
29
+ npm run test:integration:core # Core integration tests
30
+ npm run test:integration:domain # Domain-specific integration tests
31
+ npm run test:integration:full # Full integration test suite (throttled)
32
+ npm run test:integration:budgets # Budget-specific integration tests
33
+ npm run test:integration:accounts # Account-specific integration tests
34
+ npm run test:integration:transactions # Transaction-specific integration tests
35
+ npm run test:integration:categories # Category-specific integration tests
36
+ npm run test:integration:payees # Payee-specific integration tests
37
+ npm run test:integration:months # Month-specific integration tests
38
+ npm run test:integration:delta # Delta caching integration tests
39
+ npm run test:integration:reconciliation # Reconciliation integration tests
40
+ npm run test:e2e # End-to-end tests (requires real YNAB token)
41
+ npm run test:performance # Performance and load tests
42
+ npm run test:coverage # Generate coverage report (requires 80% coverage)
43
+ npm run test:watch # Watch mode for test development
44
+ npm run test:comprehensive # Run comprehensive test suite
45
+ npm run test:all # Run all tests (unit, integration, e2e, performance)
33
46
  ```
34
47
 
35
- See [docs/guides/TESTING.md](docs/guides/TESTING.md) for comprehensive testing documentation.
36
-
37
48
  ### Code Quality
38
49
 
39
50
  ```bash
@@ -48,31 +59,43 @@ npm run format:check # Check formatting without modifying files
48
59
  ```bash
49
60
  npm run package:mcpb # Build production MCPB package for Claude Desktop
50
61
  npm run generate:mcpb # Generate MCPB file from built bundle
51
- npm run bundle # Bundle with esbuild (development)
52
- npm run bundle:prod # Bundle with minification (production)
62
+ npm run bundle # Bundle with esbuild (development)
63
+ npm run bundle:prod # Bundle with minification (production)
64
+ npm run prepare # Prepare package for publication (runs build:prod)
65
+ npm run prepublishOnly # Pre-publish checks (runs tests + build)
53
66
  ```
54
67
 
55
- See [docs/guides/DEPLOYMENT.md](docs/guides/DEPLOYMENT.md) for deployment instructions.
56
-
57
68
  ## Architecture Overview
58
69
 
59
- The v0.8.x architecture is modular and service-oriented:
70
+ The architecture is modular and service-oriented:
60
71
 
61
72
  ### Core Server Components (`src/server/`)
62
73
 
63
74
  - **YNABMCPServer.ts** - Main orchestration server, coordinates all services
64
75
  - **toolRegistry.ts** - Centralized tool metadata, validation, and execution
65
76
  - **cacheManager.ts** - Enhanced caching with LRU eviction, observability, and stale-while-revalidate
77
+ - **deltaCache.ts** - Delta request management with server knowledge tracking and merge operations
78
+ - **deltaCache.merge.ts** - Entity merging functions for delta responses (transactions, categories, accounts)
79
+ - **serverKnowledgeStore.ts** - Tracks last known server_knowledge values per cache key for delta requests
66
80
  - **budgetResolver.ts** - Consistent budget ID resolution across all tools
67
81
  - **errorHandler.ts** - Centralized error handling with dependency injection
68
82
  - **config.ts** - Environment validation and server configuration
69
- - **resources.ts** - MCP resource definitions and handlers
83
+ - **resources.ts** - MCP resource definitions and handlers (includes resource templates)
70
84
  - **prompts.ts** - MCP prompt definitions and handlers
71
85
  - **diagnostics.ts** - System diagnostics and health monitoring
72
86
  - **securityMiddleware.ts** - Security validation and wrapper functions
73
87
  - **responseFormatter.ts** - JSON response formatting (minification/pretty-print)
74
88
  - **rateLimiter.ts** - Rate limiting for YNAB API compliance
75
89
  - **requestLogger.ts** - Request/response logging middleware
90
+ - **cacheKeys.ts** - Centralized cache key generation utilities
91
+
92
+ ### Tool Registration Pattern (2025-12)
93
+
94
+ - `ToolContext` (`src/types/toolRegistration.ts`) centralizes shared deps (ynabAPI, deltaFetcher/cache, knowledge store, default budget accessors, cache/diagnostic managers).
95
+ - Adapter helpers (`src/tools/adapters.ts`): `adapt`, `adaptNoInput`, `adaptWithDelta`, `adaptWrite`, and `createBudgetResolver` to inject default budget IDs; covered by unit tests in `src/tools/__tests__/adapters.test.ts`.
96
+ - Domain factories (`register*Tools`) live in each tool file: budget, account, transaction, category, payee, month, utility, reconciliation. `setupToolRegistry` now delegates to these factories.
97
+ - Shared schemas: `emptyObjectSchema`, `looseObjectSchema` in `src/tools/schemas/common.ts`.
98
+ - Server-owned inline tools that stay in `YNABMCPServer`: `set_default_budget`, `get_default_budget`, `diagnostic_info`, `clear_cache`, `set_output_format` (they depend on server internals).
76
99
 
77
100
  ### Tool Implementation (`src/tools/`)
78
101
 
@@ -85,13 +108,29 @@ Tools are organized by domain with some using modular sub-directories:
85
108
  - **payeeTools.ts** - Payee listing and retrieval
86
109
  - **monthTools.ts** - Monthly budget data
87
110
  - **utilityTools.ts** - User info and amount conversion
111
+ - **adapters.ts** - Tool adapter implementations
112
+ - **toolCategories.ts** - Tool categorization utilities
113
+ - **compareTransactions.ts** - Transaction comparison tool entry point
88
114
  - **exportTransactions.ts** - Transaction export to JSON files
89
- - **reconcileAccount.ts** - Comprehensive account reconciliation
115
+ - **reconcileAdapter.ts** - Legacy adapter for reconciliation tool
116
+ - **deltaFetcher.ts** - Delta request utilities for efficient API updates
117
+ - **deltaSupport.ts** - Delta request support utilities and helpers
90
118
 
91
119
  **Modular Tool Directories:**
92
120
 
93
121
  - **compareTransactions/** - CSV comparison tools split into parser, matcher, formatter
94
- - **financialOverview/** - Financial analysis split into schemas, handlers, insights, trends, formatter
122
+ - **reconciliation/** - Comprehensive account reconciliation system (v2 architecture)
123
+ - csvParser.ts - CSV parsing with bank presets (TD, RBC, Scotiabank, etc.)
124
+ - matcher.ts - Fuzzy matching engine with configurable scoring
125
+ - analyzer.ts - Transaction analysis and discrepancy detection
126
+ - executor.ts - Bulk transaction operations (create/update/unclear)
127
+ - recommendationEngine.ts - Smart reconciliation recommendations
128
+ - reportFormatter.ts - Human-readable reconciliation reports
129
+ - signDetector.ts - Auto-detection of debit/credit sign conventions
130
+ - payeeNormalizer.ts - Payee name normalization for matching
131
+ - ynabAdapter.ts - YNAB API integration layer
132
+ - **schemas/** - Zod schemas for input/output validation
133
+ - outputs/ - Output schema definitions for all tools
95
134
 
96
135
  ### Type Definitions (`src/types/`)
97
136
 
@@ -119,7 +158,7 @@ registry.register({
119
158
  });
120
159
  ```
121
160
 
122
- ### Enhanced Caching (v0.8.x)
161
+ ### Enhanced Caching with Delta Support
123
162
 
124
163
  Use `cacheManager.wrap()` for automatic caching with observability:
125
164
 
@@ -139,6 +178,30 @@ Cache TTL constants are defined in `cacheManager.ts`:
139
178
  - `CACHE_TTLS.SHORT` - 5 minutes (transactions)
140
179
  - `CACHE_TTLS.LONG` - 1 hour
141
180
 
181
+ ### Delta Caching Pattern
182
+
183
+ The server supports YNAB delta requests to fetch only changed data since the last request:
184
+
185
+ ```typescript
186
+ import { DeltaCache } from './server/deltaCache.js';
187
+ import { ServerKnowledgeStore } from './server/serverKnowledgeStore.js';
188
+
189
+ // Delta cache automatically manages server_knowledge tracking
190
+ const result = await deltaCache.fetchWithDelta({
191
+ cacheKey: 'transactions:budget123',
192
+ fetchFn: (lastKnowledge) => api.getTransactions(budgetId, lastKnowledge),
193
+ mergeFn: DeltaCache.mergeTransactions, // Built-in merge functions available
194
+ });
195
+ ```
196
+
197
+ The delta cache system:
198
+
199
+ - Tracks `server_knowledge` values per cache key via `ServerKnowledgeStore`
200
+ - Automatically merges delta responses with cached snapshots
201
+ - Provides built-in merge functions for transactions, categories, and accounts
202
+ - Resets knowledge on server restart to ensure consistency
203
+ - Handles large knowledge gaps and edge cases
204
+
142
205
  ### Budget Resolution Pattern
143
206
 
144
207
  Use `BudgetResolver` for consistent budget ID handling:
@@ -174,6 +237,20 @@ constructor(
174
237
  ) {}
175
238
  ```
176
239
 
240
+ ## MCP Resources
241
+
242
+ The server provides MCP resources for dynamic data access:
243
+
244
+ ### Resource Templates
245
+
246
+ Resource templates allow AI assistants to discover and access YNAB data using URI patterns:
247
+
248
+ - `ynab://budgets/{budget_id}` - Get detailed budget information
249
+ - `ynab://budgets/{budget_id}/accounts` - List accounts for a specific budget
250
+ - `ynab://budgets/{budget_id}/accounts/{account_id}` - Get detailed account information
251
+
252
+ Resources support full caching with configurable TTLs and return structured data that AI assistants can use for analysis and recommendations.
253
+
177
254
  ## Tool Annotations
178
255
 
179
256
  All tools include MCP-compliant annotations as advisory hints for AI clients. These annotations follow the Model Context Protocol specification and help AI assistants understand tool capabilities, safety characteristics, and expected behavior. The annotation system uses type-safe presets defined in `src/tools/toolCategories.ts` via the `ToolAnnotationPresets` constant.
@@ -236,17 +313,6 @@ All 30 tools are classified into the following categories:
236
313
 
237
314
  - `get_default_budget`, `convert_amount`, `diagnostic_info`, `clear_cache`, `set_output_format`
238
315
 
239
- ### Expected Benefits
240
-
241
- The tool annotation system provides several advantages:
242
-
243
- - **Enhanced AI Client UX** - AI assistants like Claude can show warnings/confirmations for destructive tools
244
- - **Safer Workflows** - AI understands which tools are dangerous and can prompt for confirmation before execution
245
- - **Better Tool Discovery** - Annotations help AI clients understand tool capabilities and constraints
246
- - **Future-Proof Integration** - As more MCP clients emerge, they'll respect these standard annotations
247
- - **Self-Documenting API** - Metadata provides clear documentation of tool behavior without reading implementation
248
- - **Zero Breaking Changes** - Fully backward compatible, annotations are advisory only and don't affect tool execution
249
-
250
316
  ### Usage Example
251
317
 
252
318
  Tool annotations are applied during tool registration using preset patterns:
@@ -366,7 +432,7 @@ Strict mode enabled with extensive safety checks:
366
432
  3. Register tool in `YNABMCPServer.ts` using `ToolRegistry`
367
433
  4. Add unit tests in `src/tools/__tests__/myTools.test.ts`
368
434
  5. Add integration tests in `src/tools/__tests__/myTools.integration.test.ts`
369
- 6. Update API documentation in `docs/API.md`
435
+ 6. Update API documentation in `docs/reference/API.md`
370
436
 
371
437
  ### Modifying Cache Behavior
372
438
 
@@ -381,34 +447,48 @@ Service modules (like diagnostics, resources, prompts) follow a pattern:
381
447
  3. Register in `YNABMCPServer` constructor
382
448
  4. Add tests in `src/server/__tests__/`
383
449
 
384
- ## MCPB Packaging for Claude Desktop
450
+ ## Git Workflow
451
+
452
+ - **Main branch**: `master`
453
+ - **Commit style**: Conventional commits (feat:, fix:, chore:, refactor:, test:, docs:)
454
+ - Run `npm test` and `npm run lint` before committing
455
+ - PR titles should follow: `type: description` (e.g., `feat: add bulk transaction import`)
385
456
 
386
- The project builds a `.mcpb` file (MCP extension for Claude Desktop):
457
+ ## Reconciliation System
387
458
 
388
- ```bash
389
- npm run package:mcpb
390
- ```
459
+ The reconciliation tool (`reconcile_account`) is a comprehensive account reconciliation system with advanced features:
391
460
 
392
- Output: `dist/ynab-mcp-server-<version>.mcpb`
461
+ ### Key Components
393
462
 
394
- The MCPB includes:
463
+ - **CSV Parser** - Supports multiple bank formats with presets for Canadian banks (TD, RBC, Scotiabank, Wealthsimple, Tangerine)
464
+ - **Fuzzy Matcher** - Uses token-set-ratio matching for merchant name variations
465
+ - **Analyzer** - Detects discrepancies, duplicates, and missing transactions
466
+ - **Executor** - Handles bulk create/update/unclear operations with comprehensive error handling
467
+ - **Recommendation Engine** - Provides smart reconciliation suggestions
468
+ - **Sign Detector** - Auto-detects debit/credit sign conventions from CSV data
395
469
 
396
- - Bundled Node.js code (single file, no node_modules)
397
- - Manifest with extension metadata
398
- - Environment variable configuration schema
470
+ ### Configuration
399
471
 
400
- ## Git & Version Control
472
+ - Amount tolerance: 1 cent (10 milliunits) by default
473
+ - Date tolerance: 7 days (accommodates bank posting delays)
474
+ - Scoring weights: amount 50%, payee 35%, date 15%
475
+ - Auto-match threshold: 85%
401
476
 
402
- - **Main branch**: `master`
403
- - **Versioning**: Semantic versioning (currently 0.x.y - pre-1.0 API)
404
- - **Commit style**: Conventional commits encouraged (feat:, fix:, chore:, etc.)
477
+ See `docs/technical/reconciliation-system-architecture.md` for detailed documentation.
478
+
479
+ ## Boundaries
480
+
481
+ - ✅ **Always do**: Run `npm test` before commits, use milliunits for YNAB amounts, follow existing patterns
482
+ - ✅ **Always do**: Use `.js` extensions in imports, validate inputs with Zod schemas
483
+ - ⚠️ **Ask first**: Adding new dependencies, changing API response formats, modifying cache TTLs
484
+ - 🚫 **Never do**: Commit `.env` or secrets, edit `dist/` or `node_modules/`, skip type checking
485
+ - 🚫 **Never do**: Remove failing tests without fixing, use `any` type without justification
405
486
 
406
487
  ## Important Notes
407
488
 
408
- - **Backward Compatibility**: v0.8.x maintains 100% API compatibility with v0.7.x
409
- - **Cache Invalidation**: Write operations (create, update, delete) should invalidate related caches
489
+ - **Amount Handling**: YNAB uses milliunits (1 dollar = 1000 milliunits) - always convert
410
490
  - **Date Format**: Always use ISO format `YYYY-MM-DD` for dates
411
491
  - **Budget ID Resolution**: Most tools auto-resolve budget_id from default budget if not provided
412
492
  - **Error Responses**: All errors return consistent JSON format via `ErrorHandler`
413
- - **Security**: Input validation via Zod schemas, security middleware wraps all tool executions
414
- - **Rate Limiting**: YNAB API has rate limits - use caching aggressively
493
+ - **Cache Invalidation**: Write operations (create, update, delete) should invalidate related caches
494
+ - **Rate Limiting**: YNAB API has rate limits - use delta caching and aggressive caching strategies
package/NUL CHANGED
@@ -1 +0,0 @@
1
- dir: cannot access '/B': No such file or directory
package/README.md CHANGED
@@ -60,7 +60,7 @@ Add this to your Claude Desktop MCP settings file:
60
60
  "mcpServers": {
61
61
  "ynab": {
62
62
  "command": "npx",
63
- "args": ["-y", "@dizzlkheinz/ynab-mcpb"],
63
+ "args": ["-y", "@dizzlkheinz/ynab-mcpb@latest"],
64
64
  "env": {
65
65
  "YNAB_ACCESS_TOKEN": "your-token-here"
66
66
  }
@@ -81,7 +81,7 @@ Add this to your Cline MCP settings:
81
81
  "mcpServers": {
82
82
  "ynab": {
83
83
  "command": "npx",
84
- "args": ["-y", "@dizzlkheinz/ynab-mcpb"],
84
+ "args": ["-y", "@dizzlkheinz/ynab-mcpb@latest"],
85
85
  "env": {
86
86
  "YNAB_ACCESS_TOKEN": "your-token-here"
87
87
  }
@@ -92,13 +92,28 @@ Add this to your Cline MCP settings:
92
92
 
93
93
  </details>
94
94
 
95
+ <details>
96
+ <summary><b>Codex</b></summary>
97
+
98
+ Add this to your configuration file:
99
+
100
+ ```toml
101
+ [mcp_servers.ynab-mcpb]
102
+ command = "npx"
103
+ args = ["-y", "@dizzlkheinz/ynab-mcpb@latest"]
104
+ env = {"YNAB_ACCESS_TOKEN" = "your-token-here"}
105
+ startup_timeout_sec = 120
106
+ ```
107
+
108
+ </details>
109
+
95
110
  <details>
96
111
  <summary><b>Other MCP Clients</b></summary>
97
112
 
98
113
  For any MCP-compatible client, configure the server with:
99
114
 
100
115
  **Command:** `npx`
101
- **Arguments:** `["-y", "@dizzlkheinz/ynab-mcpb"]`
116
+ **Arguments:** `["-y", "@dizzlkheinz/ynab-mcpb@latest"]`
102
117
  **Environment Variables:**
103
118
 
104
119
  - `YNAB_ACCESS_TOKEN`: Your YNAB Personal Access Token
@@ -133,7 +148,7 @@ Example:
133
148
  "mcpServers": {
134
149
  "ynab": {
135
150
  "command": "npx",
136
- "args": ["-y", "@dizzlkheinz/ynab-mcpb"],
151
+ "args": ["-y", "@dizzlkheinz/ynab-mcpb@latest"],
137
152
  "env": {
138
153
  "YNAB_ACCESS_TOKEN": "your-token-here",
139
154
  "YNAB_EXPORT_PATH": "C:\\Users\\YourName\\Documents"
@@ -143,7 +158,7 @@ Example:
143
158
  }
144
159
  ```
145
160
 
146
- For advanced configuration options (caching, output formatting), see the [Configuration Guide](docs/getting-started/CONFIGURATION.md).
161
+ For advanced configuration options (caching, output formatting), see the `.env.example` file in the repository.
147
162
 
148
163
  ## What's Available
149
164
 
@@ -168,12 +183,16 @@ The server gives Claude access to 30 tools organized by function. You don't need
168
183
  - Find missing transactions
169
184
  - Track budget performance
170
185
 
186
+ ## MCP Resources
187
+
188
+ - Access budget and account data via URI patterns (e.g., `ynab://budgets/{id}`)
189
+ - Static resources: `ynab://budgets`, `ynab://user`
190
+
171
191
  For the complete list with technical details, see the [API Reference](docs/reference/API.md).
172
192
 
173
193
  ## Need Help?
174
194
 
175
- - **[Troubleshooting Guide](docs/reference/TROUBLESHOOTING.md)** - Common issues and solutions
176
- - **[Full Documentation](docs/README.md)** - Complete guides and API reference
195
+ - **[API Reference](docs/reference/API.md)** - Complete tool documentation
177
196
  - **[GitHub Issues](https://github.com/dizzlkheinz/ynab-mcpb/issues)** - Report bugs or request features
178
197
 
179
198
  ## For Developers
@@ -214,12 +233,6 @@ Want to contribute or build from source?
214
233
  npm test
215
234
  ```
216
235
 
217
- ### Additional Resources
218
-
219
- - **[Development Guide](docs/guides/DEVELOPMENT.md)** - Setup and best practices
220
- - **[Architecture Overview](docs/guides/ARCHITECTURE.md)** - How the code is organized
221
- - **[Testing Guide](docs/guides/TESTING.md)** - Running and writing tests
222
-
223
236
  ## Security & Privacy
224
237
 
225
238
  Your YNAB access token is stored securely and never logged. All communication with YNAB's API uses HTTPS, and the server validates all inputs to prevent errors and security issues.
@@ -233,7 +246,7 @@ Contributions welcome! Please:
233
246
  3. Add tests for new features
234
247
  4. Submit a pull request
235
248
 
236
- See the [Development Guide](docs/guides/DEVELOPMENT.md) for details.
249
+ See `CLAUDE.md` for development details and architecture overview.
237
250
 
238
251
  ## License
239
252