@oliverames/ynab-mcp-server 1.2.1 → 1.2.2
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/index.js +13 -2
- package/package.json +1 -1
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
|
|