@dizzlkheinz/ynab-mcpb 0.15.1 → 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/CHANGELOG.md +36 -0
- package/CLAUDE.md +113 -18
- package/README.md +19 -4
- package/dist/bundle/index.cjs +53 -52
- package/dist/server/YNABMCPServer.d.ts +2 -6
- package/dist/server/YNABMCPServer.js +5 -1
- package/dist/server/resources.d.ts +17 -13
- package/dist/server/resources.js +237 -48
- package/dist/tools/reconcileAdapter.d.ts +1 -0
- package/dist/tools/reconcileAdapter.js +1 -0
- package/dist/tools/reconciliation/csvParser.d.ts +3 -0
- package/dist/tools/reconciliation/csvParser.js +58 -19
- package/dist/tools/reconciliation/executor.js +47 -1
- package/dist/tools/reconciliation/index.js +82 -42
- package/dist/tools/reconciliation/reportFormatter.d.ts +1 -0
- package/dist/tools/reconciliation/reportFormatter.js +49 -36
- package/dist/tools/transactionTools.js +5 -0
- package/docs/reference/API.md +144 -0
- package/docs/technical/reconciliation-system-architecture.md +2251 -0
- package/package.json +1 -1
- package/src/server/YNABMCPServer.ts +7 -0
- package/src/server/__tests__/resources.template.test.ts +198 -0
- package/src/server/__tests__/resources.test.ts +10 -2
- package/src/server/resources.ts +307 -62
- package/src/tools/__tests__/transactionTools.test.ts +90 -17
- package/src/tools/reconcileAdapter.ts +2 -0
- package/src/tools/reconciliation/__tests__/reportFormatter.test.ts +23 -23
- package/src/tools/reconciliation/csvParser.ts +84 -18
- package/src/tools/reconciliation/executor.ts +58 -1
- package/src/tools/reconciliation/index.ts +105 -55
- package/src/tools/reconciliation/reportFormatter.ts +55 -37
- package/src/tools/transactionTools.ts +10 -0
- package/.dxtignore +0 -57
- package/CODEREVIEW_RESPONSE.md +0 -128
- package/SCHEMA_IMPROVEMENT_SUMMARY.md +0 -120
- package/TESTING_NOTES.md +0 -217
- package/accountactivity-merged.csv +0 -149
- package/bundle-analysis.html +0 -13110
- package/docs/plans/2025-11-20-reloadable-config-token-validation.md +0 -93
- package/docs/plans/2025-11-21-fix-transaction-cached-property.md +0 -362
- package/docs/plans/2025-11-21-reconciliation-error-handling.md +0 -90
- package/docs/plans/2025-11-21-v014-hardening.md +0 -153
- package/docs/plans/reconciliation-v2-redesign.md +0 -1571
- package/fix-types.sh +0 -17
- package/test-csv-sample.csv +0 -28
- package/test-exports/sample_bank_statement.csv +0 -7
- package/test-reconcile-autodetect.js +0 -40
- package/test-reconcile-tool.js +0 -152
- package/test-reconcile-with-csv.cjs +0 -89
- package/test-statement.csv +0 -8
- package/test_debug.js +0 -47
- package/test_mcp_tools.mjs +0 -75
- package/test_simple.mjs +0 -16
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,42 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.16.0] - 2025-12-01
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- **MCP Resource Templates** - Implemented resource templates for budgets and accounts
|
|
15
|
+
- `ynab://budgets/{budget_id}` - Get detailed budget information
|
|
16
|
+
- `ynab://budgets/{budget_id}/accounts` - List accounts for a specific budget
|
|
17
|
+
- `ynab://budgets/{budget_id}/accounts/{account_id}` - Get detailed account information
|
|
18
|
+
- Enables AI assistants to discover and access YNAB resources dynamically
|
|
19
|
+
- Full caching support with configurable TTLs
|
|
20
|
+
|
|
21
|
+
- **Reconciliation System Architecture Documentation** - Comprehensive technical documentation (2,249 lines)
|
|
22
|
+
- Complete system architecture with Mermaid diagrams
|
|
23
|
+
- Detailed CSV parsing engine documentation
|
|
24
|
+
- Transaction matching algorithm specifications
|
|
25
|
+
- Execution engine patterns and bulk operation strategies
|
|
26
|
+
- Testing strategy and performance characteristics
|
|
27
|
+
- See `docs/technical/reconciliation-system-architecture.md`
|
|
28
|
+
|
|
29
|
+
- **CSV Delimiter Security** - Added validation for CSV delimiter override
|
|
30
|
+
- Whitelist-based delimiter validation (comma, semicolon, tab, pipe, space)
|
|
31
|
+
- Prevents injection attacks via malicious delimiter strings
|
|
32
|
+
- Clear error messages for unsupported delimiters
|
|
33
|
+
|
|
34
|
+
### Changed
|
|
35
|
+
|
|
36
|
+
- **CSV Parser** - Enhanced delimiter handling
|
|
37
|
+
- Honor explicit delimiter overrides from reconcile_account requests
|
|
38
|
+
- Improved error messages for unsupported delimiters
|
|
39
|
+
- Better auto-detection fallback when delimiter override fails
|
|
40
|
+
|
|
41
|
+
### Fixed
|
|
42
|
+
|
|
43
|
+
- **Build Process** - Resolved build errors and applied code formatting
|
|
44
|
+
- **Resource Templates** - Hardened template parameter validation and error handling
|
|
45
|
+
|
|
10
46
|
## [0.15.0] - 2025-11-30
|
|
11
47
|
|
|
12
48
|
### Changed
|
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
|
|
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
|
|
27
|
-
npm run test:unit
|
|
28
|
-
npm run test:integration
|
|
29
|
-
npm run test:
|
|
30
|
-
npm run test:
|
|
31
|
-
npm run test:
|
|
32
|
-
npm run test:
|
|
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
|
|
52
|
-
npm run bundle:prod
|
|
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
|
|
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
|
-
- **
|
|
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
|
-
- **
|
|
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
|
|
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
|
|
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
|
|
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"
|