financy 0.3.0 → 0.4.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/README.md +165 -1
- package/dist/bin.js +219 -7
- package/dist/{chunk-VE5WZRGU.js → chunk-LZSZIBYL.js} +239 -5
- package/dist/lib.d.ts +1 -0
- package/dist/lib.js +20 -5
- package/dist/server-WGN36UXM.js +459 -0
- package/package.json +2 -2
- package/skills/financy-setup/SKILL.md +33 -4
- package/dist/server-RM4BAVES.js +0 -207
package/dist/server-RM4BAVES.js
DELETED
|
@@ -1,207 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
CliError,
|
|
4
|
-
EXIT,
|
|
5
|
-
VERSION,
|
|
6
|
-
fetchAccount,
|
|
7
|
-
fetchAccounts,
|
|
8
|
-
fetchBranches,
|
|
9
|
-
fetchCategories,
|
|
10
|
-
fetchConnection,
|
|
11
|
-
fetchConnections,
|
|
12
|
-
fetchProviders,
|
|
13
|
-
fetchRefresh,
|
|
14
|
-
fetchStatus,
|
|
15
|
-
fetchTransaction,
|
|
16
|
-
fetchTransactions,
|
|
17
|
-
loadConfig,
|
|
18
|
-
notConfigured
|
|
19
|
-
} from "./chunk-VE5WZRGU.js";
|
|
20
|
-
|
|
21
|
-
// src/mcp/server.ts
|
|
22
|
-
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
23
|
-
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
24
|
-
import {
|
|
25
|
-
ListToolsRequestSchema,
|
|
26
|
-
CallToolRequestSchema
|
|
27
|
-
} from "@modelcontextprotocol/sdk/types.js";
|
|
28
|
-
|
|
29
|
-
// src/mcp/tools.ts
|
|
30
|
-
var str = (v) => v == null ? void 0 : String(v);
|
|
31
|
-
var bool = (v) => v === true;
|
|
32
|
-
function requireId(args) {
|
|
33
|
-
const id = args.id;
|
|
34
|
-
if (typeof id !== "string" || id.length === 0) {
|
|
35
|
-
throw new CliError(EXIT.USAGE, "MISSING_ARGUMENT", "the `id` argument is required");
|
|
36
|
-
}
|
|
37
|
-
return id;
|
|
38
|
-
}
|
|
39
|
-
var PAGING = {
|
|
40
|
-
limit: { type: "number", description: "page size (defaults to the API default)" },
|
|
41
|
-
cursor: { type: "string", description: "opaque nextPage cursor from a prior call" },
|
|
42
|
-
all: { type: "boolean", description: "auto-paginate to the end (ignores cursor/limit paging)" }
|
|
43
|
-
};
|
|
44
|
-
var NO_ARGS = { type: "object", properties: {} };
|
|
45
|
-
var idSchema = (noun) => ({
|
|
46
|
-
type: "object",
|
|
47
|
-
properties: { id: { type: "string", description: `the ${noun} id` } },
|
|
48
|
-
required: ["id"]
|
|
49
|
-
});
|
|
50
|
-
var listArgs = (a) => ({
|
|
51
|
-
limit: str(a.limit),
|
|
52
|
-
cursor: str(a.cursor),
|
|
53
|
-
all: bool(a.all)
|
|
54
|
-
});
|
|
55
|
-
var TOOLS = [
|
|
56
|
-
{
|
|
57
|
-
name: "list_connections",
|
|
58
|
-
description: "List the user's bank/card connections and their fetch state (status, data-through date, consent expiry, per-type counts). Start here to see what is connected. Supports limit/cursor paging and all.",
|
|
59
|
-
inputSchema: { type: "object", properties: { ...PAGING } },
|
|
60
|
-
run: (a, ctx) => fetchConnections(ctx.config, ctx.now, listArgs(a))
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
name: "get_connection",
|
|
64
|
-
description: "Read a single connection by id (from list_connections). Errors CONNECTION_NOT_FOUND if it is not in the user's scope.",
|
|
65
|
-
inputSchema: idSchema("connection"),
|
|
66
|
-
run: (a, ctx) => fetchConnection(ctx.config, ctx.now, requireId(a))
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
name: "list_accounts",
|
|
70
|
-
description: "List accounts with balances (securities embedded). Filter by type (CHECKING|CARD|LOAN|SAVINGS|SECURITY) or connection. Supports limit/cursor/all.",
|
|
71
|
-
inputSchema: {
|
|
72
|
-
type: "object",
|
|
73
|
-
properties: {
|
|
74
|
-
type: { type: "string", description: "CHECKING|CARD|LOAN|SAVINGS|SECURITY" },
|
|
75
|
-
connection: { type: "string", description: "filter to one connection id" },
|
|
76
|
-
...PAGING
|
|
77
|
-
}
|
|
78
|
-
},
|
|
79
|
-
run: (a, ctx) => fetchAccounts(ctx.config, ctx.now, {
|
|
80
|
-
...listArgs(a),
|
|
81
|
-
type: str(a.type),
|
|
82
|
-
connection: str(a.connection)
|
|
83
|
-
})
|
|
84
|
-
},
|
|
85
|
-
{
|
|
86
|
-
name: "get_account",
|
|
87
|
-
description: "Read a single account by id (from list_accounts). Errors ACCOUNT_NOT_FOUND if not in scope.",
|
|
88
|
-
inputSchema: idSchema("account"),
|
|
89
|
-
run: (a, ctx) => fetchAccount(ctx.config, ctx.now, requireId(a))
|
|
90
|
-
},
|
|
91
|
-
{
|
|
92
|
-
name: "list_transactions",
|
|
93
|
-
description: "List transactions, most useful with filters: from/to (YYYY-MM-DD), account, connection, type (BANK|CARD). Page with limit/cursor or fetch everything with all. Hebrew merchant names are returned as-is. To then read one transaction, pass its `SK` (not its `id`) to get_transaction.",
|
|
94
|
-
inputSchema: {
|
|
95
|
-
type: "object",
|
|
96
|
-
properties: {
|
|
97
|
-
from: { type: "string", description: "earliest transaction date (YYYY-MM-DD)" },
|
|
98
|
-
to: { type: "string", description: "latest transaction date (YYYY-MM-DD)" },
|
|
99
|
-
account: { type: "string", description: "filter to one account id" },
|
|
100
|
-
connection: { type: "string", description: "filter to one connection id" },
|
|
101
|
-
type: { type: "string", description: "BANK|CARD" },
|
|
102
|
-
...PAGING
|
|
103
|
-
}
|
|
104
|
-
},
|
|
105
|
-
run: (a, ctx) => fetchTransactions(ctx.config, ctx.now, {
|
|
106
|
-
...listArgs(a),
|
|
107
|
-
from: str(a.from),
|
|
108
|
-
to: str(a.to),
|
|
109
|
-
account: str(a.account),
|
|
110
|
-
connection: str(a.connection),
|
|
111
|
-
type: str(a.type)
|
|
112
|
-
})
|
|
113
|
-
},
|
|
114
|
-
{
|
|
115
|
-
name: "get_transaction",
|
|
116
|
-
description: "Read a single transaction by its `SK` \u2014 the composite key from list_transactions, NOT the short `id` field, which this route does not accept. Errors TRANSACTION_NOT_FOUND if not in scope.",
|
|
117
|
-
inputSchema: {
|
|
118
|
-
type: "object",
|
|
119
|
-
properties: {
|
|
120
|
-
id: {
|
|
121
|
-
type: "string",
|
|
122
|
-
description: 'the transaction\'s `SK` from list_transactions, e.g. "TRANSACTION#TYPE#CHECKING#PROVIDER#leumi#RESOURCE<uuid>#<ulid>". The short `id` field of the same transaction will NOT resolve.'
|
|
123
|
-
}
|
|
124
|
-
},
|
|
125
|
-
required: ["id"]
|
|
126
|
-
},
|
|
127
|
-
run: (a, ctx) => fetchTransaction(ctx.config, ctx.now, requireId(a))
|
|
128
|
-
},
|
|
129
|
-
{
|
|
130
|
-
name: "list_categories",
|
|
131
|
-
description: "The static transaction-category taxonomy (English + Hebrew). Use to interpret transaction category fields. No arguments.",
|
|
132
|
-
inputSchema: NO_ARGS,
|
|
133
|
-
run: async (_a, ctx) => ({ data: await fetchCategories(ctx.config, ctx.now) })
|
|
134
|
-
},
|
|
135
|
-
{
|
|
136
|
-
name: "list_providers",
|
|
137
|
-
description: "Reference data: the list of banks/providers, to resolve providerId values. No arguments.",
|
|
138
|
-
inputSchema: NO_ARGS,
|
|
139
|
-
run: (_a, ctx) => fetchProviders(ctx.config, ctx.now)
|
|
140
|
-
},
|
|
141
|
-
{
|
|
142
|
-
name: "list_bank_branches",
|
|
143
|
-
description: "Reference data: bank branches. No arguments (this route takes no paging).",
|
|
144
|
-
inputSchema: NO_ARGS,
|
|
145
|
-
run: (_a, ctx) => fetchBranches(ctx.config, ctx.now)
|
|
146
|
-
},
|
|
147
|
-
{
|
|
148
|
-
name: "get_status",
|
|
149
|
-
description: "Per-connection freshness rollup: for each connection its status, data-through date, consent expiry, and account count, plus staleThresholdDays. Call this first to decide whether data is fresh enough before answering questions about balances or transactions.",
|
|
150
|
-
inputSchema: NO_ARGS,
|
|
151
|
-
run: async (_a, ctx) => {
|
|
152
|
-
const { data, staleThresholdDays } = await fetchStatus(ctx.config, ctx.now);
|
|
153
|
-
return { data, staleThresholdDays };
|
|
154
|
-
}
|
|
155
|
-
},
|
|
156
|
-
{
|
|
157
|
-
name: "refresh_connections",
|
|
158
|
-
description: "Trigger an on-demand refresh of ALL connections (org-wide). This COSTS 20 credits \u2014 always confirm with the user before calling it. Data lands after a few minutes; poll get_status to watch progress. Returns the refresh outcome (accepted / already_running).",
|
|
159
|
-
inputSchema: NO_ARGS,
|
|
160
|
-
run: (_a, ctx) => fetchRefresh(ctx.config, ctx.now)
|
|
161
|
-
}
|
|
162
|
-
];
|
|
163
|
-
var BY_NAME = new Map(TOOLS.map((t) => [t.name, t]));
|
|
164
|
-
function errorEnvelope(error) {
|
|
165
|
-
const e = error instanceof CliError ? error : new CliError(EXIT.UNEXPECTED, "UNEXPECTED", String(error?.message ?? error));
|
|
166
|
-
return { error: { code: e.code, message: e.message, ...e.extra } };
|
|
167
|
-
}
|
|
168
|
-
async function callTool(name, args, io) {
|
|
169
|
-
try {
|
|
170
|
-
const tool = BY_NAME.get(name);
|
|
171
|
-
if (!tool) {
|
|
172
|
-
throw new CliError(EXIT.USAGE, "UNKNOWN_TOOL", `no tool named '${name}'`);
|
|
173
|
-
}
|
|
174
|
-
let config = io.config;
|
|
175
|
-
if (!config) {
|
|
176
|
-
const result = await loadConfig(io.env);
|
|
177
|
-
if (!result.ok) throw notConfigured(result);
|
|
178
|
-
config = result.config;
|
|
179
|
-
}
|
|
180
|
-
return await tool.run(args ?? {}, { config, now: io.now ?? /* @__PURE__ */ new Date() });
|
|
181
|
-
} catch (error) {
|
|
182
|
-
return errorEnvelope(error);
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
// src/mcp/server.ts
|
|
187
|
-
async function startMcpServer(env) {
|
|
188
|
-
const server = new Server(
|
|
189
|
-
{ name: "financy", version: VERSION },
|
|
190
|
-
{ capabilities: { tools: {} } }
|
|
191
|
-
);
|
|
192
|
-
server.setRequestHandler(ListToolsRequestSchema, () => ({
|
|
193
|
-
tools: TOOLS.map((t) => ({
|
|
194
|
-
name: t.name,
|
|
195
|
-
description: t.description,
|
|
196
|
-
inputSchema: t.inputSchema
|
|
197
|
-
}))
|
|
198
|
-
}));
|
|
199
|
-
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
200
|
-
const result = await callTool(request.params.name, request.params.arguments ?? {}, { env });
|
|
201
|
-
return { content: [{ type: "text", text: JSON.stringify(result) }] };
|
|
202
|
-
});
|
|
203
|
-
await server.connect(new StdioServerTransport());
|
|
204
|
-
}
|
|
205
|
-
export {
|
|
206
|
-
startMcpServer
|
|
207
|
-
};
|