@oliverames/ynab-mcp-server 1.2.1 → 1.2.3
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/README.md +10 -0
- package/index.js +13 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -258,6 +258,16 @@ That's it. Your AI can now talk to YNAB.
|
|
|
258
258
|
| `YNAB_API_TOKEN` | Yes | [Personal access token](https://app.ynab.com/settings/developer) from YNAB Developer Settings |
|
|
259
259
|
| `YNAB_BUDGET_ID` | No | Default budget ID. If omitted, uses `"last-used"` (your most recently accessed budget). Run `list_budgets` to find IDs. |
|
|
260
260
|
|
|
261
|
+
### 1Password Integration
|
|
262
|
+
|
|
263
|
+
If `YNAB_API_TOKEN` is not set in the environment, the server automatically attempts to resolve it from [1Password CLI](https://developer.1password.com/docs/cli/):
|
|
264
|
+
|
|
265
|
+
```
|
|
266
|
+
op://Development/YNAB API Token/credential
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
This means you can skip setting the env var entirely if you have `op` installed and a service account or session active. The fallback adds ~1-2s to startup and is silently skipped if 1Password is unavailable.
|
|
270
|
+
|
|
261
271
|
---
|
|
262
272
|
|
|
263
273
|
## Amount Handling
|
package/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
+
import { execFileSync } from "node:child_process";
|
|
3
4
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
4
5
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
5
6
|
import { z } from "zod";
|
|
@@ -7,9 +8,19 @@ import * as ynab from "ynab";
|
|
|
7
8
|
|
|
8
9
|
// --- Init ---
|
|
9
10
|
|
|
10
|
-
|
|
11
|
+
let API_TOKEN = process.env.YNAB_API_TOKEN;
|
|
11
12
|
if (!API_TOKEN) {
|
|
12
|
-
|
|
13
|
+
try {
|
|
14
|
+
API_TOKEN = execFileSync(
|
|
15
|
+
"op", ["read", "op://Development/YNAB API Token/credential"],
|
|
16
|
+
{ encoding: "utf-8", timeout: 10000, stdio: ["pipe", "pipe", "pipe"] }
|
|
17
|
+
).trim();
|
|
18
|
+
} catch {
|
|
19
|
+
// 1Password CLI unavailable or item not found
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
if (!API_TOKEN) {
|
|
23
|
+
console.error("YNAB_API_TOKEN environment variable is required (1Password fallback also failed)");
|
|
13
24
|
process.exit(1);
|
|
14
25
|
}
|
|
15
26
|
|