projectionlab-mcp 1.2.0 → 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/HOW-IT-WORKS.md +2 -2
- package/MANUAL-SETUP.md +19 -13
- package/README.md +2 -2
- package/REFERENCE.md +2 -2
- package/SETUP-FOR-AGENTS.md +7 -4
- package/dist/bridge.d.ts +6 -0
- package/dist/extensionBridge.d.ts +57 -4
- package/dist/extensionBridge.js +286 -32
- package/dist/extensionBridge.js.map +1 -1
- package/dist/planVersion.d.ts +6 -4
- package/dist/planVersion.js +6 -4
- package/dist/planVersion.js.map +1 -1
- package/dist/tools/clonePlan.js +1 -3
- package/dist/tools/clonePlan.js.map +1 -1
- package/dist/tools/deletePlan.js +1 -3
- package/dist/tools/deletePlan.js.map +1 -1
- package/dist/tools/restore.js +1 -3
- package/dist/tools/restore.js.map +1 -1
- package/dist/tools/snapshots.js +11 -5
- package/dist/tools/snapshots.js.map +1 -1
- package/dist/tools/updatePlanEvent.js +1 -3
- package/dist/tools/updatePlanEvent.js.map +1 -1
- package/dist/tools/updatePlanSection.js +2 -3
- package/dist/tools/updatePlanSection.js.map +1 -1
- package/dist/tools/updatePlanSettings.js +1 -3
- package/dist/tools/updatePlanSettings.js.map +1 -1
- package/dist/types/wire.d.ts +38 -3
- package/dist/types/wire.js +20 -0
- package/dist/types/wire.js.map +1 -1
- package/dist/versionNotices.js +22 -18
- package/dist/versionNotices.js.map +1 -1
- package/package.json +1 -1
- package/skills/projectionlab/SKILL.md +35 -28
package/HOW-IT-WORKS.md
CHANGED
|
@@ -18,7 +18,7 @@ The server opens a WebSocket listener on `127.0.0.1:<PL_WS_PORT>`. A browser-sid
|
|
|
18
18
|
|
|
19
19
|
`src/types/wire.ts` is the contract shared by the server and every executor:
|
|
20
20
|
|
|
21
|
-
- The executor connects and sends a `hello` frame with a shared token, the protocol version, and an `instanceId` (a stable id for the installation: the extension persists one UUID, the snippet generates one per page load). The server validates the `Origin` header (extension or app origin only), checks the token, and replies `helloAck`, or closes with code `4001` (auth), `4002` (version), `4003` (a takeover replaced this executor), or `4004` (busy: another executor holds the connection, retry later). The server keeps one active executor and the incumbent keeps it: a second authenticated executor is refused with `4004`, retries on a slow schedule, and connects by itself when the active one goes away. It takes over only by sending `takeover: true` in the hello (the extension does that when the user presses Save on its options page) or by repeating the incumbent's `instanceId`, which lets an executor replace its own stale socket. The `helloAck` carries the server's release version in `serverVersion` so the extension can show a mismatch line; executors that ignore the field are unaffected, and servers older than the field simply omit it.
|
|
21
|
+
- The executor connects and sends a `hello` frame with a shared token, the protocol version, and an `instanceId` (a stable id for the installation: the extension persists one UUID, the snippet generates one per page load). The server validates the `Origin` header (extension or app origin only), checks the token, and replies `helloAck`, or closes with code `4001` (auth), `4002` (version), `4003` (a takeover replaced this executor), or `4004` (busy: another executor holds the connection, retry later). The server keeps one active executor and the incumbent keeps it: a second authenticated executor is refused with `4004`, retries on a slow schedule, and connects by itself when the active one goes away. It takes over only by sending `takeover: true` in the hello (the extension does that when the user presses Save on its options page) or by repeating the incumbent's `instanceId`, which lets an executor replace its own stale socket. Several server instances (one per host session) can share the port the same way: one holds it and the others retry the bind. A waiting instance with an operation to run connects to the port and sends a `yield` frame carrying the token instead of a `hello`; the holder finishes its queued operations, releases the port, closes its executor with `1012` (an ordinary close, so the executor reconnects within seconds rather than standing by), and closes the yield socket with `4005`. The waiting instance binds the port at once and waits for the executor to reconnect. When several instances wait, the one that loses the bind asks the new holder in turn. A yield from a socket with an `Origin` header is refused, since only another server sends one. The `helloAck` carries the server's release version in `serverVersion` so the extension can show a mismatch line; executors that ignore the field are unaffected, and servers older than the field simply omit it.
|
|
22
22
|
- Requests are `{ id, method, params }`; responses are `{ id, ok, result | error }`. Methods map directly to Plugin API calls plus `describeApi`/`waitForApi`.
|
|
23
23
|
- A ~20 s `ping`/`pong` heartbeat keeps the connection healthy (and keeps a Manifest V3 service worker from being suspended).
|
|
24
24
|
|
|
@@ -50,7 +50,7 @@ The Plugin API provides a targeted `updateAccount` operation for Current Finance
|
|
|
50
50
|
1. **Dry-Run by Default:** without `confirm: true`, the tool returns a structured diff preview instead of mutating anything.
|
|
51
51
|
2. **Fresh State:** the tool requests an uncached export and validates the requested change against the current data.
|
|
52
52
|
3. **Auto-Snapshotting:** on `confirm: true`, the tool passes the affected current section to `SnapshotManager`, which writes a restore-safe local JSON snapshot with an ID and timestamp.
|
|
53
|
-
4. **Conflict Check:** because `restorePlans` replaces every plan, a plan write re-reads the plans just before writing and refuses with `PLAN_CONFLICT` if any plan was added, removed, or saved in ProjectionLab since the tool read them (`
|
|
53
|
+
4. **Conflict Check:** because `restorePlans` replaces every plan, a plan write re-reads the plans just before writing and refuses with `PLAN_CONFLICT` if any plan was added, removed, or saved in ProjectionLab since the tool read them (`restorePlansIfUnchanged` in `src/extensionBridge.ts`). The re-read and the write run as one operation on the bridge, so a port hand-over to another server instance cannot fall between them: of two instances writing plans at once, one write lands and the other is refused. `projectionlab_update_plan_section` also accepts the dry run's `planVersion` as `expectedPlanVersion` and refuses if the plan was saved after the preview.
|
|
54
54
|
5. **Execution:** only then does the bridge call `updateAccount()` or the appropriate `restore*()` method.
|
|
55
55
|
6. **Verification:** the tool performs a fresh re-read and checks that the requested change landed. A verification failure is reported with the snapshot retained for recovery.
|
|
56
56
|
|
package/MANUAL-SETUP.md
CHANGED
|
@@ -5,7 +5,8 @@ assistant and it does these steps with you. Follow this page to set things up
|
|
|
5
5
|
yourself instead.
|
|
6
6
|
|
|
7
7
|
You need **Node.js 20 or newer** ([nodejs.org](https://nodejs.org)) and
|
|
8
|
-
Chrome
|
|
8
|
+
Chrome or Firefox 140 or newer; both are tested with this server. Edge and
|
|
9
|
+
Brave run the same builds as Chrome and Firefox and are unverified.
|
|
9
10
|
|
|
10
11
|
**1. Turn on plugins and copy your API key.** In
|
|
11
12
|
[ProjectionLab](https://app.projectionlab.com), open **Account Settings →
|
|
@@ -39,20 +40,25 @@ For Claude Code and other assistants, see
|
|
|
39
40
|
**4. Restart your assistant.** It starts the server, which creates the browser
|
|
40
41
|
connection token on first start at `~/.projectionlab-mcp/ws-token`.
|
|
41
42
|
|
|
42
|
-
**5. Install the browser extension.**
|
|
43
|
-
the
|
|
44
|
-
|
|
43
|
+
**5. Install the browser extension.** Add **MCP Bridge for ProjectionLab**
|
|
44
|
+
from your browser's store. There is nothing to download, and the store keeps
|
|
45
|
+
the extension up to date.
|
|
45
46
|
|
|
46
|
-
- **Chrome, Edge, or Brave:** open
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
47
|
+
- **Chrome, Edge, or Brave:** open the
|
|
48
|
+
[Chrome Web Store listing](https://chromewebstore.google.com/detail/mcp-bridge-for-projection/njgjmcihabchffonldcgfjiocjalpoaf)
|
|
49
|
+
and choose **Add to Chrome**. Edge asks once whether to allow extensions
|
|
50
|
+
from other stores.
|
|
51
|
+
- **Firefox:** open the
|
|
52
|
+
[Firefox Add-ons listing](https://addons.mozilla.org/en-US/firefox/addon/mcp-bridge-for-projectionlab/)
|
|
53
|
+
and choose **Install Add-on**.
|
|
53
54
|
|
|
54
|
-
|
|
55
|
-
|
|
55
|
+
> **Upgrading from an unpacked zip?** Remove the unpacked extension from
|
|
56
|
+
> your browser's extensions page (`chrome://extensions` or `about:addons`)
|
|
57
|
+
> before adding the store version. Browsers isolate extension settings by
|
|
58
|
+
> extension ID, so enter the port and token into the new extension's options page.
|
|
59
|
+
|
|
60
|
+
Then click the extension's toolbar icon to open its options page and enter
|
|
61
|
+
port `8788` and the token from `~/.projectionlab-mcp/ws-token`.
|
|
56
62
|
|
|
57
63
|
**6. Check the connection.** Open ProjectionLab in that browser and log in.
|
|
58
64
|
Then ask your assistant to run `projectionlab_check_connection`. When every
|
package/README.md
CHANGED
|
@@ -26,10 +26,10 @@ Paste this into your AI assistant:
|
|
|
26
26
|
> package) for me. Follow the setup instructions at
|
|
27
27
|
> `https://github.com/Backroads4Me/projectionlab-mcp/blob/main/SETUP-FOR-AGENTS.md`.
|
|
28
28
|
> I'm not technical, so walk me through anything you need from me (like my
|
|
29
|
-
> ProjectionLab Plugin API key and
|
|
29
|
+
> ProjectionLab Plugin API key and installing the browser extension) one step at
|
|
30
30
|
> a time. Keep it in read-only mode until I say otherwise.
|
|
31
31
|
|
|
32
|
-
Your assistant installs the server, asks for your ProjectionLab Plugin API key, and walks you through a couple of short steps in your browser:
|
|
32
|
+
Your assistant installs the server, asks for your ProjectionLab Plugin API key, and walks you through a couple of short steps in your browser: adding a small helper extension from your browser's extension store and entering a connection code in its settings. When it's done, start asking questions about your plan.
|
|
33
33
|
|
|
34
34
|
If anything gets stuck, tell your assistant what you see on screen; it can troubleshoot from there.
|
|
35
35
|
|
package/REFERENCE.md
CHANGED
|
@@ -37,7 +37,7 @@ mcp_servers:
|
|
|
37
37
|
enabled: true
|
|
38
38
|
```
|
|
39
39
|
|
|
40
|
-
Only one server instance
|
|
40
|
+
Only one server instance holds the WebSocket port at a time, and the browser connects to that one. Hosts that start a server per session or window (Claude Desktop keeps one running for every open session) can have several on the same port. The instance in use takes the port: when a waiting instance gets a tool call, it asks the holder to hand over, the holder finishes the operations it has already queued and releases the port, and the browser reconnects to the new holder within a few seconds. Two agents working at once trade the connection back and forth, with that delay on each switch. A waiting instance also takes the port within a few seconds of the holder exiting. Holders older than this mechanism cannot hand over; `projectionlab_check_connection` says so, and closing that session or quitting its host frees the port. It also says when the port is held by a program that is not projectionlab-mcp, in which case set `PL_WS_PORT` to a free port and enter the same port on the extension's options page.
|
|
41
41
|
|
|
42
42
|
## Agent instructions
|
|
43
43
|
|
|
@@ -143,7 +143,7 @@ The server starts without `PL_API_KEY` so it can tell the agent what is missing;
|
|
|
143
143
|
|
|
144
144
|
Write operations (`update_*`, `restore_*`, `clone_plan`, `delete_plan`) default to **dry-run mode**. Pass `confirm: true` to execute. Before any confirmed mutation, the server automatically snapshots the affected data section to disk so you can roll back with `projectionlab_rollback`. Writes are disabled entirely unless `PL_READ_ONLY=false`.
|
|
145
145
|
|
|
146
|
-
Every write that replaces the plans array re-reads the plans just before writing and refuses with `PLAN_CONFLICT` if any plan was added, removed, or saved in ProjectionLab since the tool read them, so an edit made in the ProjectionLab UI is never silently overwritten. `projectionlab_update_plan_section` also returns a `planVersion` in its dry run; pass it back as `expectedPlanVersion` when confirming to refuse the write if the plan was saved after the preview.
|
|
146
|
+
Every write that replaces the plans array re-reads the plans just before writing and refuses with `PLAN_CONFLICT` if any plan was added, removed, or saved in ProjectionLab since the tool read them, so an edit made in the ProjectionLab UI, or a write by another agent's server instance, is never silently overwritten. `projectionlab_update_plan_section` also returns a `planVersion` in its dry run; pass it back as `expectedPlanVersion` when confirming to refuse the write if the plan was saved after the preview.
|
|
147
147
|
|
|
148
148
|
Plan reads hide secret values: a secret-named field (`apiKey`, `token`, `password`, …) comes back as `[REDACTED]`. A payload for `projectionlab_update_plan_section` or any `restore_*` tool that still holds that sentinel under a secret-named key is refused with `INVALID_INPUT`, dry runs included, naming the offending dot paths. Supply the real value, or change single fields with `projectionlab_update_plan_event` or `projectionlab_update_plan_settings`, which patch by path and never round-trip hidden values.
|
|
149
149
|
|
package/SETUP-FOR-AGENTS.md
CHANGED
|
@@ -25,10 +25,13 @@ The config location varies by host; see [Adding the server to your MCP host](htt
|
|
|
25
25
|
|
|
26
26
|
**4. Connect the browser.** The server reaches ProjectionLab through the user's own browser. Pick the path that fits:
|
|
27
27
|
|
|
28
|
-
- **Recommended: the browser extension** (persists across restarts
|
|
29
|
-
- **Chrome / Edge / Brave:**
|
|
30
|
-
- **Firefox (140+):**
|
|
31
|
-
Then have them open the extension's **options page** and enter the WebSocket **port** (default `8788`) and the **shared token** from `~/.projectionlab-mcp/ws-token`.
|
|
28
|
+
- **Recommended: the browser extension** (persists across restarts, and the store keeps it updated). Have the user add **MCP Bridge for ProjectionLab** from their browser's store. Opening the page is yours to do; clicking the install button is theirs:
|
|
29
|
+
- **Chrome / Edge / Brave:** the [Chrome Web Store listing](https://chromewebstore.google.com/detail/mcp-bridge-for-projection/njgjmcihabchffonldcgfjiocjalpoaf) → **Add to Chrome**. Edge asks once whether to allow extensions from other stores.
|
|
30
|
+
- **Firefox (140+):** the [Firefox Add-ons listing](https://addons.mozilla.org/en-US/firefox/addon/mcp-bridge-for-projectionlab/) → **Install Add-on**.
|
|
31
|
+
Then have them open the extension's **options page** (click its toolbar icon) and enter the WebSocket **port** (default `8788`) and the **shared token** from `~/.projectionlab-mcp/ws-token`.
|
|
32
|
+
Chrome and Firefox are tested with this server; Edge and Brave run the same
|
|
33
|
+
builds and are unverified, so steer the user to Chrome or Firefox when they
|
|
34
|
+
have a choice, and treat a Brave or Edge report as unverified until reproduced.
|
|
32
35
|
|
|
33
36
|
- **Quick alternative: no install.** Call the `projectionlab_get_bootstrap` tool, then have the user paste the returned snippet into their ProjectionLab tab's developer console (F12 → Console). It works the same way but must be re-pasted if they reload the page. Good for a first test drive.
|
|
34
37
|
|
package/dist/bridge.d.ts
CHANGED
|
@@ -24,6 +24,12 @@ export interface Bridge {
|
|
|
24
24
|
updateAccount(accountId: string, data: Record<string, unknown>, force?: boolean): Promise<void>;
|
|
25
25
|
restoreCurrentFinances(state: unknown): Promise<void>;
|
|
26
26
|
restorePlans(plans: unknown[]): Promise<void>;
|
|
27
|
+
/**
|
|
28
|
+
* Writes `plans` unless a plan was added, removed, or saved since `read`
|
|
29
|
+
* was taken, in which case it throws PLAN_CONFLICT and writes nothing. The
|
|
30
|
+
* re-read and the write are atomic: no other operation runs between them.
|
|
31
|
+
*/
|
|
32
|
+
restorePlansIfUnchanged(read: unknown[], plans: unknown[]): Promise<void>;
|
|
27
33
|
restoreProgress(progress: unknown): Promise<void>;
|
|
28
34
|
restoreSettings(settings: unknown): Promise<void>;
|
|
29
35
|
invalidateCache(): void;
|
|
@@ -12,6 +12,16 @@ export declare class ExtensionBridge implements Bridge {
|
|
|
12
12
|
private readonly token;
|
|
13
13
|
private portBusy;
|
|
14
14
|
private retryTimer;
|
|
15
|
+
/** While non-zero, bind retries run every TAKEOVER_RETRY_MS until this time. */
|
|
16
|
+
private fastBindUntil;
|
|
17
|
+
/** Why the last yield request failed; "" when none has. */
|
|
18
|
+
private yieldFailure;
|
|
19
|
+
/** The socket of a yield request in flight. */
|
|
20
|
+
private yieldPeer;
|
|
21
|
+
/** When this instance last released the port to another instance. */
|
|
22
|
+
private yieldedAt;
|
|
23
|
+
/** Callbacks run whenever the connection or port state changes. */
|
|
24
|
+
private readonly stateWaiters;
|
|
15
25
|
private closed;
|
|
16
26
|
private opChain;
|
|
17
27
|
private exportCache;
|
|
@@ -19,12 +29,17 @@ export declare class ExtensionBridge implements Bridge {
|
|
|
19
29
|
/** Reads or creates `~/.projectionlab-mcp/ws-token`, keeping the folder
|
|
20
30
|
* 0700 and the file 0600 even when they already existed with looser modes. */
|
|
21
31
|
private loadOrCreateToken;
|
|
32
|
+
private notifyState;
|
|
33
|
+
private scheduleListen;
|
|
22
34
|
/** Binds the WebSocket port. While another instance (another agent on
|
|
23
|
-
* this machine) holds it, retries every PORT_RETRY_MS
|
|
24
|
-
* that instance exits;
|
|
35
|
+
* this machine) holds it, retries every PORT_RETRY_MS, so it takes over
|
|
36
|
+
* once that instance exits; an operation arriving meanwhile asks the
|
|
37
|
+
* holder to yield (requestPort). Executors reconnect on their own
|
|
38
|
+
* schedule. */
|
|
25
39
|
private listen;
|
|
26
|
-
/** New sockets must send a valid hello
|
|
27
|
-
* runs once the first message
|
|
40
|
+
/** New sockets must send a valid hello (or, from another server instance,
|
|
41
|
+
* a yield) before anything else. `helloRead` runs once the first message
|
|
42
|
+
* arrives, whatever it holds. */
|
|
28
43
|
private awaitHello;
|
|
29
44
|
/**
|
|
30
45
|
* Decide whether an authenticated hello becomes the active executor. The
|
|
@@ -38,17 +53,51 @@ export declare class ExtensionBridge implements Bridge {
|
|
|
38
53
|
/** Promote an authenticated socket to the active connection. Replacing a
|
|
39
54
|
* live incumbent (takeover or same instance id) closes it with 4003. */
|
|
40
55
|
private adopt;
|
|
56
|
+
/**
|
|
57
|
+
* Hand the port to the server instance that sent a yield frame on `peer`.
|
|
58
|
+
* Runs on the operation chain, so an operation already sent to the
|
|
59
|
+
* browser finishes before the executor is dropped. The executor is closed
|
|
60
|
+
* with HANDED_OVER, an ordinary code, so it reconnects within seconds and
|
|
61
|
+
* reaches the new holder. This instance then waits for the port like any
|
|
62
|
+
* other, and asks for it back when its next operation arrives.
|
|
63
|
+
*/
|
|
64
|
+
private yieldPort;
|
|
65
|
+
/**
|
|
66
|
+
* Ask the instance holding the port to yield it. Resolves "yielded" when
|
|
67
|
+
* it closes the socket with YIELDED, and "free" when nothing accepts the
|
|
68
|
+
* connection or the holder drops it (it just exited). Otherwise resolves
|
|
69
|
+
* the failure: "refused" when the holder answers 4001 (a server that
|
|
70
|
+
* predates yield frames, or one with a different token), "slow" when a
|
|
71
|
+
* holder that accepted the socket does not release the port within
|
|
72
|
+
* YIELD_TIMEOUT_MS, and "foreign" when the holder does not complete a
|
|
73
|
+
* WebSocket upgrade (a process that is not projectionlab-mcp).
|
|
74
|
+
*/
|
|
75
|
+
private requestPort;
|
|
76
|
+
/** Resolves once `done()` holds, rechecked on every state change, or
|
|
77
|
+
* after `timeoutMs`. */
|
|
78
|
+
private waitForState;
|
|
79
|
+
/**
|
|
80
|
+
* The connected executor's socket. While another instance holds the port,
|
|
81
|
+
* asks it to yield, binds the port, and waits for the executor to
|
|
82
|
+
* reconnect here. When another waiting instance wins the bind instead, the
|
|
83
|
+
* next round asks that instance. Runs on the operation chain, so
|
|
84
|
+
* concurrent operations send one yield between them.
|
|
85
|
+
*/
|
|
86
|
+
private executorSocket;
|
|
41
87
|
private onFrame;
|
|
42
88
|
private settle;
|
|
43
89
|
private wireError;
|
|
44
90
|
private startHeartbeat;
|
|
45
91
|
/** Reject every in-flight request; the executor that was sent to is gone. */
|
|
46
92
|
private abandonRequests;
|
|
93
|
+
/** Forget the executor. With `closeCode`, the socket gets a close frame
|
|
94
|
+
* carrying that code; otherwise it is terminated. */
|
|
47
95
|
private dropConnection;
|
|
48
96
|
private serialize;
|
|
49
97
|
/** Why no executor can be reached, with the fix, for error messages. */
|
|
50
98
|
private notConnectedReason;
|
|
51
99
|
private requireApiKey;
|
|
100
|
+
/** Send one request to the executor. Call only from the operation chain. */
|
|
52
101
|
private request;
|
|
53
102
|
/** Tier 0: console snippet that turns a PL tab into the executor. */
|
|
54
103
|
bootstrapSnippet(): string;
|
|
@@ -62,6 +111,10 @@ export declare class ExtensionBridge implements Bridge {
|
|
|
62
111
|
private restoreCall;
|
|
63
112
|
restoreCurrentFinances(state: unknown): Promise<void>;
|
|
64
113
|
restorePlans(plans: unknown[]): Promise<void>;
|
|
114
|
+
/** Re-reads the plans and writes `plans` as one entry on the operation
|
|
115
|
+
* chain, so neither a hand-over to another instance nor another operation
|
|
116
|
+
* of this one can run between the conflict check and the write. */
|
|
117
|
+
restorePlansIfUnchanged(read: unknown[], plans: unknown[]): Promise<void>;
|
|
65
118
|
restoreProgress(progress: unknown): Promise<void>;
|
|
66
119
|
restoreSettings(settings: unknown): Promise<void>;
|
|
67
120
|
close(): Promise<void>;
|