@dizzlkheinz/ynab-mcpb 0.16.0 → 0.16.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/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.16.0
8
10
 
9
11
  ## Essential Commands
10
12
 
@@ -23,13 +25,26 @@ See [docs/development/BUILD.md](docs/development/BUILD.md) for detailed build in
23
25
  ### Testing
24
26
 
25
27
  ```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
28
+ npm test # Run all unit tests + filter results
29
+ npm run test:unit # Unit tests only (fast, mocked dependencies)
30
+ npm run test:integration # Integration tests (core only)
31
+ npm run test:integration:core # Core integration tests
32
+ npm run test:integration:domain # Domain-specific integration tests
33
+ npm run test:integration:full # Full integration test suite (throttled)
34
+ npm run test:integration:budgets # Budget-specific integration tests
35
+ npm run test:integration:accounts # Account-specific integration tests
36
+ npm run test:integration:transactions # Transaction-specific integration tests
37
+ npm run test:integration:categories # Category-specific integration tests
38
+ npm run test:integration:payees # Payee-specific integration tests
39
+ npm run test:integration:months # Month-specific integration tests
40
+ npm run test:integration:delta # Delta caching integration tests
41
+ npm run test:integration:reconciliation # Reconciliation integration tests
42
+ npm run test:e2e # End-to-end tests (requires real YNAB token)
43
+ npm run test:performance # Performance and load tests
44
+ npm run test:coverage # Generate coverage report (requires 80% coverage)
45
+ npm run test:watch # Watch mode for test development
46
+ npm run test:comprehensive # Run comprehensive test suite
47
+ npm run test:all # Run all tests (unit, integration, e2e, performance)
33
48
  ```
34
49
 
35
50
  See [docs/guides/TESTING.md](docs/guides/TESTING.md) for comprehensive testing documentation.
@@ -48,31 +63,37 @@ npm run format:check # Check formatting without modifying files
48
63
  ```bash
49
64
  npm run package:mcpb # Build production MCPB package for Claude Desktop
50
65
  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)
66
+ npm run bundle # Bundle with esbuild (development)
67
+ npm run bundle:prod # Bundle with minification (production)
68
+ npm run prepare # Prepare package for publication (runs build:prod)
69
+ npm run prepublishOnly # Pre-publish checks (runs tests + build)
53
70
  ```
54
71
 
55
72
  See [docs/guides/DEPLOYMENT.md](docs/guides/DEPLOYMENT.md) for deployment instructions.
56
73
 
57
74
  ## Architecture Overview
58
75
 
59
- The v0.8.x architecture is modular and service-oriented:
76
+ The architecture is modular and service-oriented:
60
77
 
61
78
  ### Core Server Components (`src/server/`)
62
79
 
63
80
  - **YNABMCPServer.ts** - Main orchestration server, coordinates all services
64
81
  - **toolRegistry.ts** - Centralized tool metadata, validation, and execution
65
82
  - **cacheManager.ts** - Enhanced caching with LRU eviction, observability, and stale-while-revalidate
83
+ - **deltaCache.ts** - Delta request management with server knowledge tracking and merge operations
84
+ - **deltaCache.merge.ts** - Entity merging functions for delta responses (transactions, categories, accounts)
85
+ - **serverKnowledgeStore.ts** - Tracks last known server_knowledge values per cache key for delta requests
66
86
  - **budgetResolver.ts** - Consistent budget ID resolution across all tools
67
87
  - **errorHandler.ts** - Centralized error handling with dependency injection
68
88
  - **config.ts** - Environment validation and server configuration
69
- - **resources.ts** - MCP resource definitions and handlers
89
+ - **resources.ts** - MCP resource definitions and handlers (includes resource templates)
70
90
  - **prompts.ts** - MCP prompt definitions and handlers
71
91
  - **diagnostics.ts** - System diagnostics and health monitoring
72
92
  - **securityMiddleware.ts** - Security validation and wrapper functions
73
93
  - **responseFormatter.ts** - JSON response formatting (minification/pretty-print)
74
94
  - **rateLimiter.ts** - Rate limiting for YNAB API compliance
75
95
  - **requestLogger.ts** - Request/response logging middleware
96
+ - **cacheKeys.ts** - Centralized cache key generation utilities
76
97
 
77
98
  ### Tool Implementation (`src/tools/`)
78
99
 
@@ -86,12 +107,25 @@ Tools are organized by domain with some using modular sub-directories:
86
107
  - **monthTools.ts** - Monthly budget data
87
108
  - **utilityTools.ts** - User info and amount conversion
88
109
  - **exportTransactions.ts** - Transaction export to JSON files
89
- - **reconcileAccount.ts** - Comprehensive account reconciliation
110
+ - **reconcileAdapter.ts** - Legacy adapter for reconciliation tool
111
+ - **deltaFetcher.ts** - Delta request utilities for efficient API updates
112
+ - **deltaSupport.ts** - Delta request support utilities and helpers
90
113
 
91
114
  **Modular Tool Directories:**
92
115
 
93
116
  - **compareTransactions/** - CSV comparison tools split into parser, matcher, formatter
94
- - **financialOverview/** - Financial analysis split into schemas, handlers, insights, trends, formatter
117
+ - **reconciliation/** - Comprehensive account reconciliation system (v2 architecture)
118
+ - csvParser.ts - CSV parsing with bank presets (TD, RBC, Scotiabank, etc.)
119
+ - matcher.ts - Fuzzy matching engine with configurable scoring
120
+ - analyzer.ts - Transaction analysis and discrepancy detection
121
+ - executor.ts - Bulk transaction operations (create/update/unclear)
122
+ - recommendationEngine.ts - Smart reconciliation recommendations
123
+ - reportFormatter.ts - Human-readable reconciliation reports
124
+ - signDetector.ts - Auto-detection of debit/credit sign conventions
125
+ - payeeNormalizer.ts - Payee name normalization for matching
126
+ - ynabAdapter.ts - YNAB API integration layer
127
+ - **schemas/** - Zod schemas for input/output validation
128
+ - outputs/ - Output schema definitions for all tools
95
129
 
96
130
  ### Type Definitions (`src/types/`)
97
131
 
@@ -119,7 +153,7 @@ registry.register({
119
153
  });
120
154
  ```
121
155
 
122
- ### Enhanced Caching (v0.8.x)
156
+ ### Enhanced Caching with Delta Support
123
157
 
124
158
  Use `cacheManager.wrap()` for automatic caching with observability:
125
159
 
@@ -139,6 +173,30 @@ Cache TTL constants are defined in `cacheManager.ts`:
139
173
  - `CACHE_TTLS.SHORT` - 5 minutes (transactions)
140
174
  - `CACHE_TTLS.LONG` - 1 hour
141
175
 
176
+ ### Delta Caching Pattern
177
+
178
+ The server supports YNAB delta requests to fetch only changed data since the last request:
179
+
180
+ ```typescript
181
+ import { DeltaCache } from './server/deltaCache.js';
182
+ import { ServerKnowledgeStore } from './server/serverKnowledgeStore.js';
183
+
184
+ // Delta cache automatically manages server_knowledge tracking
185
+ const result = await deltaCache.fetchWithDelta({
186
+ cacheKey: 'transactions:budget123',
187
+ fetchFn: (lastKnowledge) => api.getTransactions(budgetId, lastKnowledge),
188
+ mergeFn: DeltaCache.mergeTransactions, // Built-in merge functions available
189
+ });
190
+ ```
191
+
192
+ The delta cache system:
193
+
194
+ - Tracks `server_knowledge` values per cache key via `ServerKnowledgeStore`
195
+ - Automatically merges delta responses with cached snapshots
196
+ - Provides built-in merge functions for transactions, categories, and accounts
197
+ - Resets knowledge on server restart to ensure consistency
198
+ - Handles large knowledge gaps and edge cases
199
+
142
200
  ### Budget Resolution Pattern
143
201
 
144
202
  Use `BudgetResolver` for consistent budget ID handling:
@@ -174,6 +232,20 @@ constructor(
174
232
  ) {}
175
233
  ```
176
234
 
235
+ ## MCP Resources
236
+
237
+ The server provides MCP resources for dynamic data access:
238
+
239
+ ### Resource Templates
240
+
241
+ Resource templates allow AI assistants to discover and access YNAB data using URI patterns:
242
+
243
+ - `ynab://budgets/{budget_id}` - Get detailed budget information
244
+ - `ynab://budgets/{budget_id}/accounts` - List accounts for a specific budget
245
+ - `ynab://budgets/{budget_id}/accounts/{account_id}` - Get detailed account information
246
+
247
+ Resources support full caching with configurable TTLs and return structured data that AI assistants can use for analysis and recommendations.
248
+
177
249
  ## Tool Annotations
178
250
 
179
251
  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.
@@ -214,7 +286,7 @@ The system defines 5 preset annotation patterns in `src/tools/toolCategories.ts`
214
286
 
215
287
  ### Complete Tool Classification
216
288
 
217
- All 30 tools are classified into the following categories:
289
+ All tools are classified into the following categories:
218
290
 
219
291
  **Read-Only External (15 tools):**
220
292
 
@@ -403,12 +475,35 @@ The MCPB includes:
403
475
  - **Versioning**: Semantic versioning (currently 0.x.y - pre-1.0 API)
404
476
  - **Commit style**: Conventional commits encouraged (feat:, fix:, chore:, etc.)
405
477
 
478
+ ## Reconciliation System
479
+
480
+ The reconciliation tool (`reconcile_account`) is a comprehensive account reconciliation system with advanced features:
481
+
482
+ ### Key Components
483
+
484
+ - **CSV Parser** - Supports multiple bank formats with presets for Canadian banks (TD, RBC, Scotiabank, Wealthsimple, Tangerine)
485
+ - **Fuzzy Matcher** - Uses token-set-ratio matching for merchant name variations
486
+ - **Analyzer** - Detects discrepancies, duplicates, and missing transactions
487
+ - **Executor** - Handles bulk create/update/unclear operations with comprehensive error handling
488
+ - **Recommendation Engine** - Provides smart reconciliation suggestions
489
+ - **Sign Detector** - Auto-detects debit/credit sign conventions from CSV data
490
+
491
+ ### Configuration
492
+
493
+ - Amount tolerance: 1 cent (10 milliunits) by default
494
+ - Date tolerance: 7 days (accommodates bank posting delays)
495
+ - Scoring weights: amount 50%, payee 35%, date 15%
496
+ - Auto-match threshold: 85%
497
+
498
+ See `docs/technical/reconciliation-system-architecture.md` for detailed documentation.
499
+
406
500
  ## Important Notes
407
501
 
408
- - **Backward Compatibility**: v0.8.x maintains 100% API compatibility with v0.7.x
409
502
  - **Cache Invalidation**: Write operations (create, update, delete) should invalidate related caches
410
503
  - **Date Format**: Always use ISO format `YYYY-MM-DD` for dates
411
504
  - **Budget ID Resolution**: Most tools auto-resolve budget_id from default budget if not provided
412
505
  - **Error Responses**: All errors return consistent JSON format via `ErrorHandler`
413
506
  - **Security**: Input validation via Zod schemas, security middleware wraps all tool executions
414
- - **Rate Limiting**: YNAB API has rate limits - use caching aggressively
507
+ - **Rate Limiting**: YNAB API has rate limits - use delta caching and aggressive caching strategies
508
+ - **Delta Requests**: Delta cache automatically manages server_knowledge tracking for efficient updates
509
+ - **Resource Templates**: Use `ynab://` URI patterns for dynamic resource access
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"