@artesian/tides-mcp 0.1.0 → 0.2.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 +9 -8
- package/dist/tides-mcp.js +80 -19
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# Tides MCP
|
|
2
2
|
|
|
3
|
-
This lets your AI assistant work with your Tides ledger. It runs on your computer. It opens your ledger there, so Tides' servers never see your finances.
|
|
3
|
+
This lets your AI assistant work with your Tides ledger. It runs on your computer. It opens your ledger there, so Tides' servers never see your finances. It is the only Tides MCP: the old address ending in `/mcp` no longer works.
|
|
4
4
|
|
|
5
|
-
**Warning.** Whatever the assistant reads is sent to the company that runs the assistant. Only
|
|
5
|
+
**Warning.** Whatever the assistant reads is sent to the company that runs the assistant. Only connect an assistant you trust with your finances.
|
|
6
6
|
|
|
7
7
|
## Install
|
|
8
8
|
|
|
@@ -38,15 +38,16 @@ Add this to `~/.cursor/mcp.json`:
|
|
|
38
38
|
}
|
|
39
39
|
```
|
|
40
40
|
|
|
41
|
-
##
|
|
41
|
+
## Connect it
|
|
42
42
|
|
|
43
|
-
1. Ask the assistant to pair
|
|
44
|
-
2.
|
|
45
|
-
3.
|
|
43
|
+
1. Ask the assistant to connect to Tides, or run `tides-mcp pair` in a terminal.
|
|
44
|
+
2. Tides opens in your browser and shows this computer's name and a code. Check the code matches the one the assistant shows, then select Approve.
|
|
45
|
+
3. If the browser doesn't open, use the link the assistant gives you, or open Settings, then Tides MCP, and enter the code. Either way, do it within ten minutes.
|
|
46
|
+
4. If you asked the assistant, ask it to connect again so it picks up the approval. `tides-mcp pair` waits on its own.
|
|
46
47
|
|
|
47
|
-
The
|
|
48
|
+
The keys that connect this computer stay in your system keychain (macOS Keychain, Windows Credential Manager, or the Linux secret service). If there is no keychain, they are kept in `~/.config/tides-mcp/secrets.json`, readable only by you.
|
|
48
49
|
|
|
49
|
-
To remove this computer,
|
|
50
|
+
To remove this computer, disconnect it in Tides under Settings, then Tides MCP. Running `tides-mcp unpair` also clears its keys from this computer.
|
|
50
51
|
|
|
51
52
|
## Deleting and restoring
|
|
52
53
|
|
package/dist/tides-mcp.js
CHANGED
|
@@ -15531,10 +15531,33 @@ class StdioServerTransport {
|
|
|
15531
15531
|
});
|
|
15532
15532
|
}
|
|
15533
15533
|
}
|
|
15534
|
+
|
|
15535
|
+
// src/browser.ts
|
|
15536
|
+
import { spawn } from "node:child_process";
|
|
15537
|
+
var pairingLink = (serverUrl, code) => `${serverUrl}/settings?${new URLSearchParams({ pair: code })}`;
|
|
15538
|
+
function command(url, platform) {
|
|
15539
|
+
if (platform === "darwin")
|
|
15540
|
+
return ["open", [url]];
|
|
15541
|
+
if (platform === "win32")
|
|
15542
|
+
return ["cmd", ["/c", "start", "", url]];
|
|
15543
|
+
return ["xdg-open", [url]];
|
|
15544
|
+
}
|
|
15545
|
+
function browserOpener(platform = process.platform, run = spawn) {
|
|
15546
|
+
return (url) => {
|
|
15547
|
+
try {
|
|
15548
|
+
const [file, args] = command(url, platform);
|
|
15549
|
+
const child = run(file, args, { detached: true, stdio: "ignore" });
|
|
15550
|
+
child.on("error", () => {
|
|
15551
|
+
return;
|
|
15552
|
+
});
|
|
15553
|
+
child.unref();
|
|
15554
|
+
} catch {}
|
|
15555
|
+
};
|
|
15556
|
+
}
|
|
15534
15557
|
// package.json
|
|
15535
15558
|
var package_default = {
|
|
15536
15559
|
name: "@artesian/tides-mcp",
|
|
15537
|
-
version: "0.
|
|
15560
|
+
version: "0.2.0",
|
|
15538
15561
|
description: "Tides for your AI assistant: decrypts your ledger on this computer.",
|
|
15539
15562
|
type: "module",
|
|
15540
15563
|
bin: {
|
|
@@ -15710,6 +15733,8 @@ function deviceClient(http, token) {
|
|
|
15710
15733
|
form.set("pin", JSON.stringify(options.pin));
|
|
15711
15734
|
return json("POST", "/api/v1/arrivals/upload", { body: form });
|
|
15712
15735
|
},
|
|
15736
|
+
health: () => json("GET", "/api/v1/health"),
|
|
15737
|
+
sens: (filter) => json("GET", "/api/v1/sens", { query: { ...filter, limit: 100 } }),
|
|
15713
15738
|
searchInstruments: (q) => json("GET", "/api/v1/instruments", { query: { q, limit: 10 } }),
|
|
15714
15739
|
watchlist: () => json("GET", "/api/v1/watchlist"),
|
|
15715
15740
|
watch: (instrumentId) => json("POST", "/api/v1/watchlist", { body: { instrumentId } }),
|
|
@@ -19372,7 +19397,7 @@ var POLL_HEADER = "x-tides-poll";
|
|
|
19372
19397
|
|
|
19373
19398
|
class PairingExpiredError extends Error {
|
|
19374
19399
|
constructor() {
|
|
19375
|
-
super("The
|
|
19400
|
+
super("The code expired before it was approved. Connect again and enter the new code within ten minutes.");
|
|
19376
19401
|
this.name = "PairingExpiredError";
|
|
19377
19402
|
}
|
|
19378
19403
|
}
|
|
@@ -19407,7 +19432,7 @@ async function startPairing(http, secrets, name, options = {}) {
|
|
|
19407
19432
|
}
|
|
19408
19433
|
|
|
19409
19434
|
// src/secrets.ts
|
|
19410
|
-
import { spawn } from "node:child_process";
|
|
19435
|
+
import { spawn as spawn2 } from "node:child_process";
|
|
19411
19436
|
import {
|
|
19412
19437
|
chmod,
|
|
19413
19438
|
mkdir,
|
|
@@ -19425,7 +19450,7 @@ var defaultSecretsPath = () => join(homedir(), ".config", SERVICE, "secrets.json
|
|
|
19425
19450
|
var toHex = (text) => Buffer.from(text, "utf8").toString("hex");
|
|
19426
19451
|
var fromHex = (hex) => Buffer.from(hex.trim(), "hex").toString("utf8");
|
|
19427
19452
|
var spawnRun = (command, args, input) => new Promise((resolve, reject) => {
|
|
19428
|
-
const child =
|
|
19453
|
+
const child = spawn2(command, args, { windowsHide: true });
|
|
19429
19454
|
let stdout = "";
|
|
19430
19455
|
let stderr = "";
|
|
19431
19456
|
child.stdout.on("data", (chunk) => {
|
|
@@ -32607,6 +32632,33 @@ var mailTools = [
|
|
|
32607
32632
|
})
|
|
32608
32633
|
];
|
|
32609
32634
|
|
|
32635
|
+
// src/tools/market.ts
|
|
32636
|
+
var DAY_MS3 = 86400000;
|
|
32637
|
+
var marketTools = [
|
|
32638
|
+
tool({
|
|
32639
|
+
name: "get_sens",
|
|
32640
|
+
description: "JSE SENS announcements for a JSE code or an instrument id, newest first.",
|
|
32641
|
+
input: {
|
|
32642
|
+
ticker: string2().min(1).max(20).optional(),
|
|
32643
|
+
instrumentId: uuid2().optional(),
|
|
32644
|
+
days: number2().int().min(1).max(365).optional().describe("Look back this many days (default 30)")
|
|
32645
|
+
},
|
|
32646
|
+
run: async ({ ticker, instrumentId, days }, session) => {
|
|
32647
|
+
if (!ticker && !instrumentId)
|
|
32648
|
+
throw new Error("Pass a ticker or an instrumentId.");
|
|
32649
|
+
const since = session.ctx.now().getTime() - (days ?? 30) * DAY_MS3;
|
|
32650
|
+
const rows = await session.api.sens({ ticker, instrumentId });
|
|
32651
|
+
return json2(rows.filter((row) => Date.parse(row.publishedAt) >= since));
|
|
32652
|
+
}
|
|
32653
|
+
}),
|
|
32654
|
+
tool({
|
|
32655
|
+
name: "get_status",
|
|
32656
|
+
description: "Checks that Tides and its database are up.",
|
|
32657
|
+
input: {},
|
|
32658
|
+
run: async (_args, session) => json2(await session.api.health())
|
|
32659
|
+
})
|
|
32660
|
+
];
|
|
32661
|
+
|
|
32610
32662
|
// src/tools/rules.ts
|
|
32611
32663
|
var Id9 = uuid2();
|
|
32612
32664
|
var Rule = PAYLOADS.rule.omit({ order: true });
|
|
@@ -32976,6 +33028,7 @@ var ledgerTools = [
|
|
|
32976
33028
|
...tradeTools,
|
|
32977
33029
|
...inboxTools,
|
|
32978
33030
|
...watchlistTools,
|
|
33031
|
+
...marketTools,
|
|
32979
33032
|
...mailTools,
|
|
32980
33033
|
...deletedTools
|
|
32981
33034
|
];
|
|
@@ -32985,10 +33038,10 @@ function sessionTools(info) {
|
|
|
32985
33038
|
return [
|
|
32986
33039
|
{
|
|
32987
33040
|
name: "device_status",
|
|
32988
|
-
description: "Shows which Tides
|
|
33041
|
+
description: "Shows which Tides server this computer is connected to and its name, after checking the connection still works.",
|
|
32989
33042
|
async run(_args, session) {
|
|
32990
33043
|
await session.ctx.api.categories();
|
|
32991
|
-
return `
|
|
33044
|
+
return `Connected as "${session.deviceName}" to ${info.serverUrl}.`;
|
|
32992
33045
|
}
|
|
32993
33046
|
},
|
|
32994
33047
|
...ledgerTools
|
|
@@ -32998,21 +33051,21 @@ function sessionTools(info) {
|
|
|
32998
33051
|
// src/unlock.ts
|
|
32999
33052
|
class NotPairedError extends Error {
|
|
33000
33053
|
constructor() {
|
|
33001
|
-
super("This computer isn't
|
|
33054
|
+
super("This computer isn't connected to Tides yet. Run `tides-mcp pair`, then type the code in Tides under Settings → Tides MCP.");
|
|
33002
33055
|
this.name = "NotPairedError";
|
|
33003
33056
|
}
|
|
33004
33057
|
}
|
|
33005
33058
|
|
|
33006
33059
|
class RevokedError extends Error {
|
|
33007
33060
|
constructor() {
|
|
33008
|
-
super("Tides no longer accepts this
|
|
33061
|
+
super("Tides no longer accepts this computer: it was disconnected, or your account was reset. Connect it again with `tides-mcp pair`.");
|
|
33009
33062
|
this.name = "RevokedError";
|
|
33010
33063
|
}
|
|
33011
33064
|
}
|
|
33012
33065
|
|
|
33013
33066
|
class WrongKeysError extends Error {
|
|
33014
33067
|
constructor() {
|
|
33015
|
-
super("
|
|
33068
|
+
super("This computer couldn't open your Tides data, so it stopped. Ask me to connect again, and disconnect the old one in Tides under Settings → Tides MCP.");
|
|
33016
33069
|
this.name = "WrongKeysError";
|
|
33017
33070
|
}
|
|
33018
33071
|
}
|
|
@@ -33129,13 +33182,13 @@ async function startUp(secrets, http, version = VERSION, warn = (line) => proces
|
|
|
33129
33182
|
}
|
|
33130
33183
|
|
|
33131
33184
|
// src/server.ts
|
|
33132
|
-
var REVOKED_MESSAGE = "This
|
|
33185
|
+
var REVOKED_MESSAGE = "This computer was disconnected in Tides. Ask me to connect again.";
|
|
33133
33186
|
var reply = (text, isError = false, notes = []) => ({
|
|
33134
33187
|
content: [text, ...notes].map((line) => ({ type: "text", text: line })),
|
|
33135
33188
|
...isError ? { isError } : {}
|
|
33136
33189
|
});
|
|
33137
33190
|
function buildServer(state, http, secrets, options) {
|
|
33138
|
-
const server = new McpServer({ name: "tides", version:
|
|
33191
|
+
const server = new McpServer({ name: "tides", version: VERSION });
|
|
33139
33192
|
const initial = state();
|
|
33140
33193
|
let session = initial === "unreachable" ? null : initial;
|
|
33141
33194
|
let unlocking = null;
|
|
@@ -33150,7 +33203,7 @@ function buildServer(state, http, secrets, options) {
|
|
|
33150
33203
|
function registerUnpaired() {
|
|
33151
33204
|
clearTools();
|
|
33152
33205
|
registered.push(server.registerTool("pair_device", {
|
|
33153
|
-
description: "Pairs this computer with the user's Tides account. Call it once to get a code for the user to
|
|
33206
|
+
description: "Pairs this computer with the user's Tides account. Call it once to open Tides in the browser and get a link and code for the user to approve, then call it again after they have approved."
|
|
33154
33207
|
}, pairDevice));
|
|
33155
33208
|
}
|
|
33156
33209
|
async function activeSession() {
|
|
@@ -33242,7 +33295,11 @@ function buildServer(state, http, secrets, options) {
|
|
|
33242
33295
|
}
|
|
33243
33296
|
if (first) {
|
|
33244
33297
|
current.shown = true;
|
|
33245
|
-
|
|
33298
|
+
const link = pairingLink(options.serverUrl, started.code);
|
|
33299
|
+
try {
|
|
33300
|
+
(options.openBrowser ?? browserOpener())(link);
|
|
33301
|
+
} catch {}
|
|
33302
|
+
return reply(`Open this link to approve: ${link} — or type the code ${started.code} in Tides under Settings → Tides MCP within ten minutes. Then ask me to connect again.`);
|
|
33246
33303
|
}
|
|
33247
33304
|
if (!current.approved) {
|
|
33248
33305
|
try {
|
|
@@ -33270,7 +33327,7 @@ function buildServer(state, http, secrets, options) {
|
|
|
33270
33327
|
});
|
|
33271
33328
|
return reply(error.message, true);
|
|
33272
33329
|
}
|
|
33273
|
-
return reply(error instanceof UnreachableError ? error.message : "
|
|
33330
|
+
return reply(error instanceof UnreachableError ? error.message : "Connected, but your Tides data could not be opened. Ask me to connect again to retry.", true);
|
|
33274
33331
|
}
|
|
33275
33332
|
if (pairing === current)
|
|
33276
33333
|
pairing = null;
|
|
@@ -33297,21 +33354,25 @@ async function main(argv) {
|
|
|
33297
33354
|
switch (command) {
|
|
33298
33355
|
case "pair": {
|
|
33299
33356
|
const pairing = await startPairing(http, secrets, hostname2());
|
|
33300
|
-
|
|
33357
|
+
const link = pairingLink(url, pairing.code);
|
|
33358
|
+
browserOpener()(link);
|
|
33359
|
+
say(`Open this link to approve:
|
|
33360
|
+
|
|
33361
|
+
${link}
|
|
33301
33362
|
|
|
33302
|
-
|
|
33363
|
+
or type the code ${pairing.code} in Tides under Settings → Tides MCP within ten minutes.
|
|
33303
33364
|
`);
|
|
33304
33365
|
await pairing.wait();
|
|
33305
|
-
say("
|
|
33366
|
+
say("Connected. Your AI assistant can use Tides now.");
|
|
33306
33367
|
return;
|
|
33307
33368
|
}
|
|
33308
33369
|
case "unpair":
|
|
33309
33370
|
await secrets.clear();
|
|
33310
|
-
say("This computer
|
|
33371
|
+
say("This computer is disconnected. Disconnect it in Tides under Settings → Tides MCP as well.");
|
|
33311
33372
|
return;
|
|
33312
33373
|
case "status": {
|
|
33313
33374
|
const session = await unlock(secrets, http);
|
|
33314
|
-
say(`
|
|
33375
|
+
say(`Connected to ${url} as "${session.deviceName}"; your data opens.`);
|
|
33315
33376
|
return;
|
|
33316
33377
|
}
|
|
33317
33378
|
case undefined: {
|