@dizzlkheinz/ynab-mcpb 0.16.1 → 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.
- package/.code/agents/0098661e-0fa3-4990-beb9-c0cbf3f123aa/status.txt +1 -0
- package/.code/agents/1324/exec-call_tIpx9uV1TpARbAMZonRQm8AO.txt +757 -0
- package/.code/agents/1572/exec-call_GjVFBFOWcY7lE0idc5nWlLNh.txt +781 -0
- package/.code/agents/1846/exec-call_1YNAVD18RjrMN7JnfkkQhUP3.txt +766 -0
- package/.code/agents/1846/exec-call_lh3lDzE4WJAh1lFiomiiZ73D.txt +766 -0
- package/.code/agents/2038/exec-call_DYwOukaYsL8VCONWmV2rUW5u.txt +766 -0
- package/.code/agents/2038/exec-call_c7fOQ7UrpVcTtvdfGBRM146V.txt +652 -0
- package/.code/agents/2038/exec-call_ySNyq9Mm55jWE480s54r5QcA.txt +766 -0
- package/.code/agents/2256/exec-call_AtPcRWPmFPMcmX6qOFm1fCEY.txt +766 -0
- package/.code/agents/2454/exec-call_aFJpupwjfZeOBm7ixI5Vc8z2.txt +766 -0
- package/.code/agents/2454/exec-call_wogZ4HfXTodTEXvdgXlVUBpv.txt +766 -0
- package/.code/agents/2e905864-aa07-4314-bcf9-c5b32277e4ac/result.txt +36 -0
- package/.code/agents/3073/exec-call_Peeagc9DxGYLgE6pNdMZhqIE.txt +766 -0
- package/.code/agents/3073/exec-call_d2YSE3hXF08KRSoUM3qd8Z3x.txt +766 -0
- package/.code/agents/335aa031-466d-4fb7-925f-3cd864e264d0/result.txt +191 -0
- package/.code/agents/3364/exec-call_NbhIrsM5HhyDZDmJZG5CuCYL.txt +766 -0
- package/.code/agents/3364/exec-call_cKtJg0NrXiwXEFwlsE3uPZRA.txt +766 -0
- package/.code/agents/36d98414-5cde-4d9d-9a67-a240a18c1f07/result.txt +189 -0
- package/.code/agents/4604e866-b7b8-44f5-992f-2f683b0a523b/status.txt +1 -0
- package/.code/agents/5f8dc01c-47b3-4163-b0b3-aa31be89fcdc/status.txt +1 -0
- package/.code/agents/7/exec-call_HltHpkDox0Zm1vGEjdksUgpE.txt +1120 -0
- package/.code/agents/7/exec-call_LCATrOPPAgbxW9Q1z0XaVi2E.txt +2646 -0
- package/.code/agents/7/exec-call_W8DeRfNG9hvbgVFvf0clBf6R.txt +2646 -0
- package/.code/agents/94a0ddf3-a304-4ec3-913e-3cceef509948/error.txt +1 -0
- package/.code/agents/e2c752b7-711d-423a-af57-f53c809deb84/result.txt +160 -0
- package/.code/agents/e6601719-c31f-4a0e-8c71-d70787d0ab71/status.txt +1 -0
- package/.code/agents/f250b7ed-5bd5-4036-aa8c-ce63caee7d61/result.txt +20 -0
- package/AGENTS.md +1 -36
- package/CLAUDE.md +28 -43
- package/NUL +0 -1
- package/README.md +8 -10
- package/dist/bundle/index.cjs +41 -41
- package/dist/server/YNABMCPServer.js +28 -381
- package/dist/server/config.d.ts +2 -0
- package/dist/server/config.js +1 -0
- package/dist/tools/accountTools.d.ts +2 -0
- package/dist/tools/accountTools.js +45 -0
- package/dist/tools/adapters.d.ts +12 -0
- package/dist/tools/adapters.js +25 -0
- package/dist/tools/budgetTools.d.ts +2 -0
- package/dist/tools/budgetTools.js +30 -0
- package/dist/tools/categoryTools.d.ts +2 -0
- package/dist/tools/categoryTools.js +45 -0
- package/dist/tools/monthTools.d.ts +2 -0
- package/dist/tools/monthTools.js +32 -0
- package/dist/tools/payeeTools.d.ts +2 -0
- package/dist/tools/payeeTools.js +32 -0
- package/dist/tools/reconciliation/index.d.ts +2 -0
- package/dist/tools/reconciliation/index.js +33 -0
- package/dist/tools/schemas/common.d.ts +3 -0
- package/dist/tools/schemas/common.js +3 -0
- package/dist/tools/schemas/outputs/comparisonOutputs.d.ts +1 -1
- package/dist/tools/transactionTools.d.ts +2 -0
- package/dist/tools/transactionTools.js +124 -0
- package/dist/tools/utilityTools.d.ts +3 -1
- package/dist/tools/utilityTools.js +32 -2
- package/dist/types/index.d.ts +1 -0
- package/dist/types/toolRegistration.d.ts +27 -0
- package/dist/types/toolRegistration.js +1 -0
- package/package.json +2 -2
- package/scripts/run-domain-integration-tests.js +4 -1
- package/src/__tests__/workflows.e2e.test.ts +1 -7
- package/src/server/YNABMCPServer.ts +33 -519
- package/src/server/__tests__/toolRegistration.test.ts +236 -0
- package/src/server/config.ts +1 -0
- package/src/tools/__tests__/adapters.test.ts +113 -0
- package/src/tools/__tests__/utilityTools.test.ts +7 -7
- package/src/tools/accountTools.ts +53 -0
- package/src/tools/adapters.ts +74 -0
- package/src/tools/budgetTools.ts +37 -0
- package/src/tools/categoryTools.ts +53 -0
- package/src/tools/monthTools.ts +39 -0
- package/src/tools/payeeTools.ts +39 -0
- package/src/tools/reconciliation/index.ts +45 -0
- package/src/tools/schemas/common.ts +18 -0
- package/src/tools/transactionTools.ts +140 -0
- package/src/tools/utilityTools.ts +42 -2
- package/src/types/index.ts +3 -0
- package/src/types/toolRegistration.ts +88 -0
- package/.github/workflows/pr-description-check.yml +0 -88
- package/docs/README.md +0 -72
- package/docs/getting-started/CONFIGURATION.md +0 -175
- package/docs/getting-started/INSTALLATION.md +0 -333
- package/docs/getting-started/QUICKSTART.md +0 -282
- package/docs/guides/ARCHITECTURE.md +0 -533
- package/docs/guides/DEPLOYMENT.md +0 -189
- package/docs/guides/INTEGRATION_TESTING.md +0 -730
- package/docs/guides/TESTING.md +0 -591
- package/docs/reconciliation-flow.md +0 -83
- package/docs/reference/EXAMPLES.md +0 -946
- package/docs/reference/TOOLS.md +0 -348
- package/docs/reference/TROUBLESHOOTING.md +0 -481
|
@@ -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 @@
|
|
|
1
|
+
Agent cancelled
|
|
@@ -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
|
-
|
|
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
|
@@ -6,7 +6,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
|
|
|
6
6
|
|
|
7
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
8
|
|
|
9
|
-
**Current Version:** 0.
|
|
9
|
+
**Current Version:** 0.17.0
|
|
10
10
|
|
|
11
11
|
## Essential Commands
|
|
12
12
|
|
|
@@ -20,8 +20,6 @@ npm run dev # TypeScript watch mode for development
|
|
|
20
20
|
npm run type-check # Run TypeScript type checking without emitting files
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
-
See [docs/development/BUILD.md](docs/development/BUILD.md) for detailed build information.
|
|
24
|
-
|
|
25
23
|
### Testing
|
|
26
24
|
|
|
27
25
|
```bash
|
|
@@ -47,8 +45,6 @@ npm run test:comprehensive # Run comprehensive test suite
|
|
|
47
45
|
npm run test:all # Run all tests (unit, integration, e2e, performance)
|
|
48
46
|
```
|
|
49
47
|
|
|
50
|
-
See [docs/guides/TESTING.md](docs/guides/TESTING.md) for comprehensive testing documentation.
|
|
51
|
-
|
|
52
48
|
### Code Quality
|
|
53
49
|
|
|
54
50
|
```bash
|
|
@@ -69,8 +65,6 @@ npm run prepare # Prepare package for publication (runs build:prod)
|
|
|
69
65
|
npm run prepublishOnly # Pre-publish checks (runs tests + build)
|
|
70
66
|
```
|
|
71
67
|
|
|
72
|
-
See [docs/guides/DEPLOYMENT.md](docs/guides/DEPLOYMENT.md) for deployment instructions.
|
|
73
|
-
|
|
74
68
|
## Architecture Overview
|
|
75
69
|
|
|
76
70
|
The architecture is modular and service-oriented:
|
|
@@ -95,6 +89,14 @@ The architecture is modular and service-oriented:
|
|
|
95
89
|
- **requestLogger.ts** - Request/response logging middleware
|
|
96
90
|
- **cacheKeys.ts** - Centralized cache key generation utilities
|
|
97
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).
|
|
99
|
+
|
|
98
100
|
### Tool Implementation (`src/tools/`)
|
|
99
101
|
|
|
100
102
|
Tools are organized by domain with some using modular sub-directories:
|
|
@@ -106,6 +108,9 @@ Tools are organized by domain with some using modular sub-directories:
|
|
|
106
108
|
- **payeeTools.ts** - Payee listing and retrieval
|
|
107
109
|
- **monthTools.ts** - Monthly budget data
|
|
108
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
|
|
109
114
|
- **exportTransactions.ts** - Transaction export to JSON files
|
|
110
115
|
- **reconcileAdapter.ts** - Legacy adapter for reconciliation tool
|
|
111
116
|
- **deltaFetcher.ts** - Delta request utilities for efficient API updates
|
|
@@ -286,7 +291,7 @@ The system defines 5 preset annotation patterns in `src/tools/toolCategories.ts`
|
|
|
286
291
|
|
|
287
292
|
### Complete Tool Classification
|
|
288
293
|
|
|
289
|
-
All tools are classified into the following categories:
|
|
294
|
+
All 30 tools are classified into the following categories:
|
|
290
295
|
|
|
291
296
|
**Read-Only External (15 tools):**
|
|
292
297
|
|
|
@@ -308,17 +313,6 @@ All tools are classified into the following categories:
|
|
|
308
313
|
|
|
309
314
|
- `get_default_budget`, `convert_amount`, `diagnostic_info`, `clear_cache`, `set_output_format`
|
|
310
315
|
|
|
311
|
-
### Expected Benefits
|
|
312
|
-
|
|
313
|
-
The tool annotation system provides several advantages:
|
|
314
|
-
|
|
315
|
-
- **Enhanced AI Client UX** - AI assistants like Claude can show warnings/confirmations for destructive tools
|
|
316
|
-
- **Safer Workflows** - AI understands which tools are dangerous and can prompt for confirmation before execution
|
|
317
|
-
- **Better Tool Discovery** - Annotations help AI clients understand tool capabilities and constraints
|
|
318
|
-
- **Future-Proof Integration** - As more MCP clients emerge, they'll respect these standard annotations
|
|
319
|
-
- **Self-Documenting API** - Metadata provides clear documentation of tool behavior without reading implementation
|
|
320
|
-
- **Zero Breaking Changes** - Fully backward compatible, annotations are advisory only and don't affect tool execution
|
|
321
|
-
|
|
322
316
|
### Usage Example
|
|
323
317
|
|
|
324
318
|
Tool annotations are applied during tool registration using preset patterns:
|
|
@@ -438,7 +432,7 @@ Strict mode enabled with extensive safety checks:
|
|
|
438
432
|
3. Register tool in `YNABMCPServer.ts` using `ToolRegistry`
|
|
439
433
|
4. Add unit tests in `src/tools/__tests__/myTools.test.ts`
|
|
440
434
|
5. Add integration tests in `src/tools/__tests__/myTools.integration.test.ts`
|
|
441
|
-
6. Update API documentation in `docs/API.md`
|
|
435
|
+
6. Update API documentation in `docs/reference/API.md`
|
|
442
436
|
|
|
443
437
|
### Modifying Cache Behavior
|
|
444
438
|
|
|
@@ -453,27 +447,12 @@ Service modules (like diagnostics, resources, prompts) follow a pattern:
|
|
|
453
447
|
3. Register in `YNABMCPServer` constructor
|
|
454
448
|
4. Add tests in `src/server/__tests__/`
|
|
455
449
|
|
|
456
|
-
##
|
|
457
|
-
|
|
458
|
-
The project builds a `.mcpb` file (MCP extension for Claude Desktop):
|
|
459
|
-
|
|
460
|
-
```bash
|
|
461
|
-
npm run package:mcpb
|
|
462
|
-
```
|
|
463
|
-
|
|
464
|
-
Output: `dist/ynab-mcp-server-<version>.mcpb`
|
|
465
|
-
|
|
466
|
-
The MCPB includes:
|
|
467
|
-
|
|
468
|
-
- Bundled Node.js code (single file, no node_modules)
|
|
469
|
-
- Manifest with extension metadata
|
|
470
|
-
- Environment variable configuration schema
|
|
471
|
-
|
|
472
|
-
## Git & Version Control
|
|
450
|
+
## Git Workflow
|
|
473
451
|
|
|
474
452
|
- **Main branch**: `master`
|
|
475
|
-
- **
|
|
476
|
-
-
|
|
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`)
|
|
477
456
|
|
|
478
457
|
## Reconciliation System
|
|
479
458
|
|
|
@@ -497,13 +476,19 @@ The reconciliation tool (`reconcile_account`) is a comprehensive account reconci
|
|
|
497
476
|
|
|
498
477
|
See `docs/technical/reconciliation-system-architecture.md` for detailed documentation.
|
|
499
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
|
|
486
|
+
|
|
500
487
|
## Important Notes
|
|
501
488
|
|
|
502
|
-
- **
|
|
489
|
+
- **Amount Handling**: YNAB uses milliunits (1 dollar = 1000 milliunits) - always convert
|
|
503
490
|
- **Date Format**: Always use ISO format `YYYY-MM-DD` for dates
|
|
504
491
|
- **Budget ID Resolution**: Most tools auto-resolve budget_id from default budget if not provided
|
|
505
492
|
- **Error Responses**: All errors return consistent JSON format via `ErrorHandler`
|
|
506
|
-
- **
|
|
493
|
+
- **Cache Invalidation**: Write operations (create, update, delete) should invalidate related caches
|
|
507
494
|
- **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/NUL
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
dir: cannot access '/B': No such file or directory
|
package/README.md
CHANGED
|
@@ -158,7 +158,7 @@ Example:
|
|
|
158
158
|
}
|
|
159
159
|
```
|
|
160
160
|
|
|
161
|
-
For advanced configuration options (caching, output formatting), see the
|
|
161
|
+
For advanced configuration options (caching, output formatting), see the `.env.example` file in the repository.
|
|
162
162
|
|
|
163
163
|
## What's Available
|
|
164
164
|
|
|
@@ -183,12 +183,16 @@ The server gives Claude access to 30 tools organized by function. You don't need
|
|
|
183
183
|
- Find missing transactions
|
|
184
184
|
- Track budget performance
|
|
185
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
|
+
|
|
186
191
|
For the complete list with technical details, see the [API Reference](docs/reference/API.md).
|
|
187
192
|
|
|
188
193
|
## Need Help?
|
|
189
194
|
|
|
190
|
-
- **[
|
|
191
|
-
- **[Full Documentation](docs/README.md)** - Complete guides and API reference
|
|
195
|
+
- **[API Reference](docs/reference/API.md)** - Complete tool documentation
|
|
192
196
|
- **[GitHub Issues](https://github.com/dizzlkheinz/ynab-mcpb/issues)** - Report bugs or request features
|
|
193
197
|
|
|
194
198
|
## For Developers
|
|
@@ -229,12 +233,6 @@ Want to contribute or build from source?
|
|
|
229
233
|
npm test
|
|
230
234
|
```
|
|
231
235
|
|
|
232
|
-
### Additional Resources
|
|
233
|
-
|
|
234
|
-
- **[Development Guide](docs/guides/DEVELOPMENT.md)** - Setup and best practices
|
|
235
|
-
- **[Architecture Overview](docs/guides/ARCHITECTURE.md)** - How the code is organized
|
|
236
|
-
- **[Testing Guide](docs/guides/TESTING.md)** - Running and writing tests
|
|
237
|
-
|
|
238
236
|
## Security & Privacy
|
|
239
237
|
|
|
240
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.
|
|
@@ -248,7 +246,7 @@ Contributions welcome! Please:
|
|
|
248
246
|
3. Add tests for new features
|
|
249
247
|
4. Submit a pull request
|
|
250
248
|
|
|
251
|
-
See
|
|
249
|
+
See `CLAUDE.md` for development details and architecture overview.
|
|
252
250
|
|
|
253
251
|
## License
|
|
254
252
|
|