projectionlab-mcp 1.3.1 → 1.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/HOW-IT-WORKS.md +1 -1
- package/MANUAL-SETUP.md +1 -1
- package/REFERENCE.md +7 -7
- package/SETUP-FOR-AGENTS.md +1 -1
- package/dist/bootstrap.js +0 -1
- package/dist/bootstrap.js.map +1 -1
- package/dist/bridge.d.ts +8 -14
- package/dist/config.js +4 -2
- package/dist/config.js.map +1 -1
- package/dist/currentFinances.d.ts +4 -12
- package/dist/currentFinances.js +8 -44
- package/dist/currentFinances.js.map +1 -1
- package/dist/dataModel.d.ts +9 -11
- package/dist/dataModel.js +25 -849
- package/dist/dataModel.js.map +1 -1
- package/dist/diff.d.ts +10 -20
- package/dist/diff.js +30 -163
- package/dist/diff.js.map +1 -1
- package/dist/extensionBridge.d.ts +16 -15
- package/dist/extensionBridge.js +33 -49
- package/dist/extensionBridge.js.map +1 -1
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/layout.d.ts +32 -36
- package/dist/layout.js +44 -62
- package/dist/layout.js.map +1 -1
- package/dist/linkedFields.d.ts +2 -5
- package/dist/linkedFields.js +3 -5
- package/dist/linkedFields.js.map +1 -1
- package/dist/pathPatch.d.ts +3 -4
- package/dist/pathPatch.js +8 -8
- package/dist/pathPatch.js.map +1 -1
- package/dist/planSettings.d.ts +4 -6
- package/dist/planSettings.js +5 -9
- package/dist/planSettings.js.map +1 -1
- package/dist/plans.d.ts +2 -2
- package/dist/plans.js +2 -2
- package/dist/realEstate.d.ts +0 -21
- package/dist/realEstate.js +0 -117
- package/dist/realEstate.js.map +1 -1
- package/dist/resources/dataModel.d.ts +2 -6
- package/dist/resources/dataModel.js +12 -53
- package/dist/resources/dataModel.js.map +1 -1
- package/dist/resources/knowledge.d.ts +2 -7
- package/dist/resources/knowledge.js +8 -245
- package/dist/resources/knowledge.js.map +1 -1
- package/dist/resources/planData.js +1 -1
- package/dist/resources/planData.js.map +1 -1
- package/dist/settingsReport.d.ts +25 -0
- package/dist/settingsReport.js +464 -0
- package/dist/settingsReport.js.map +1 -0
- package/dist/settingsReportLayout.d.ts +59 -0
- package/dist/settingsReportLayout.js +367 -0
- package/dist/settingsReportLayout.js.map +1 -0
- package/dist/snapshot.d.ts +1 -2
- package/dist/snapshot.js +2 -2
- package/dist/snapshot.js.map +1 -1
- package/dist/summary.d.ts +3 -8
- package/dist/summary.js +7 -71
- package/dist/summary.js.map +1 -1
- package/dist/tools/bootstrap.js +1 -1
- package/dist/tools/bootstrap.js.map +1 -1
- package/dist/tools/clonePlan.js +3 -3
- package/dist/tools/clonePlan.js.map +1 -1
- package/dist/tools/connection.js +3 -3
- package/dist/tools/connection.js.map +1 -1
- package/dist/tools/deletePlan.js +3 -3
- package/dist/tools/deletePlan.js.map +1 -1
- package/dist/tools/diff.js +17 -23
- package/dist/tools/diff.js.map +1 -1
- package/dist/tools/export.js +2 -2
- package/dist/tools/export.js.map +1 -1
- package/dist/tools/getCurrentFinances.js +8 -48
- package/dist/tools/getCurrentFinances.js.map +1 -1
- package/dist/tools/getPlan.js +2 -4
- package/dist/tools/getPlan.js.map +1 -1
- package/dist/tools/getPlanSection.js +19 -10
- package/dist/tools/getPlanSection.js.map +1 -1
- package/dist/tools/getPlanSettings.js +8 -12
- package/dist/tools/getPlanSettings.js.map +1 -1
- package/dist/tools/restore.js +12 -87
- package/dist/tools/restore.js.map +1 -1
- package/dist/tools/schema.js +16 -71
- package/dist/tools/schema.js.map +1 -1
- package/dist/tools/settingsReport.d.ts +3 -0
- package/dist/tools/settingsReport.js +76 -0
- package/dist/tools/settingsReport.js.map +1 -0
- package/dist/tools/snapshots.js +9 -14
- package/dist/tools/snapshots.js.map +1 -1
- package/dist/tools/summary.js +1 -1
- package/dist/tools/summary.js.map +1 -1
- package/dist/tools/updateAccount.js +16 -26
- package/dist/tools/updateAccount.js.map +1 -1
- package/dist/tools/updatePlanEvent.js +10 -10
- package/dist/tools/updatePlanEvent.js.map +1 -1
- package/dist/tools/updatePlanSection.js +4 -5
- package/dist/tools/updatePlanSection.js.map +1 -1
- package/dist/tools/updatePlanSettings.js +4 -4
- package/dist/tools/updatePlanSettings.js.map +1 -1
- package/dist/tools/writeGuard.d.ts +3 -2
- package/dist/tools/writeGuard.js +5 -4
- package/dist/tools/writeGuard.js.map +1 -1
- package/dist/types/projectionlab.d.ts +4 -5
- package/dist/types/wire.d.ts +1 -1
- package/dist/types/wire.js.map +1 -1
- package/package.json +1 -1
- package/skills/projectionlab/SKILL.md +42 -64
- package/dist/resources/layoutResource.d.ts +0 -19
- package/dist/resources/layoutResource.js +0 -43
- package/dist/resources/layoutResource.js.map +0 -1
|
@@ -26,9 +26,9 @@ returns `browser`, `pageLoaded`, `apiAvailable`, `apiKeyValid`, `errors`,
|
|
|
26
26
|
answered. When the first four flags are `true`, proceed. Otherwise fix the
|
|
27
27
|
first failing item with the user, one step at a time, then check again.
|
|
28
28
|
|
|
29
|
-
`apiContract` is the Plugin API contract the page offers: `
|
|
30
|
-
ProjectionLab
|
|
31
|
-
|
|
29
|
+
`apiContract` is the Plugin API contract the page offers: `2` on
|
|
30
|
+
ProjectionLab 5. A page that reports no contract or another one fails the
|
|
31
|
+
check with `UNSUPPORTED_API_VERSION`, and nothing is read or written there.
|
|
32
32
|
|
|
33
33
|
`notices` are plain sentences about the server's release, never connection
|
|
34
34
|
failures. When the list is not empty, tell the user each one once, in plain
|
|
@@ -52,7 +52,7 @@ options page (browsers isolate extension storage by ID, so settings do not trans
|
|
|
52
52
|
| `browser: false`, port held by a program that is not projectionlab-mcp | Some other program is listening on the WebSocket port | Ask the user to stop that program, or set `PL_WS_PORT` to a free port for this server and enter the same port on the extension's options page |
|
|
53
53
|
| `browser: false`, handing the port over did not complete | Another instance holds the port and the browser did not reconnect here in time | Run `projectionlab_check_connection` again; if it keeps failing, ask the user to close the other agent's session |
|
|
54
54
|
| `browser: false` otherwise | No extension or snippet is connected | See "Connecting the browser" |
|
|
55
|
-
| `pageLoaded: false` | No ProjectionLab tab is open, or the account is on
|
|
55
|
+
| `pageLoaded: false` | No ProjectionLab tab is open, or the account is on Early Access and the extension has not been allowed to use it | Ask the user to open https://app.projectionlab.com and log in. If ProjectionLab sends them to https://ea.projectionlab.com, ask them to press **Allow ea.projectionlab.com** on the extension's options page and approve the browser's prompt |
|
|
56
56
|
| `apiAvailable: false` | Plugins are off, or the user is logged out | ProjectionLab -> Account Settings -> Plugins -> enable plugins |
|
|
57
57
|
| `apiKeyValid: false` | The key does not match the account | Ask the user to copy the key again from Account Settings -> Plugins |
|
|
58
58
|
|
|
@@ -93,7 +93,7 @@ Recommended, persistent: the **MCP Bridge for ProjectionLab** browser extension.
|
|
|
93
93
|
The status changes to **Connected** and the toolbar icon shows a green
|
|
94
94
|
check.
|
|
95
95
|
4. Open https://app.projectionlab.com and log in. If ProjectionLab sends the
|
|
96
|
-
user to https://ea.projectionlab.com (
|
|
96
|
+
user to https://ea.projectionlab.com (Early Access), they press
|
|
97
97
|
**Allow ea.projectionlab.com** on the options page and approve the
|
|
98
98
|
browser's prompt.
|
|
99
99
|
|
|
@@ -122,6 +122,7 @@ narrowest read that answers the question.
|
|
|
122
122
|
| One whole plan | `projectionlab_get_plan` |
|
|
123
123
|
| One section of a plan, one event, or one path in it | `projectionlab_get_plan_section` |
|
|
124
124
|
| Assumptions, Chance of Success, withdrawal strategy | `projectionlab_get_plan_settings` |
|
|
125
|
+
| A readable report of a plan's settings, or two plans' settings side by side | `projectionlab_get_settings_report` |
|
|
125
126
|
| Current Finances, or one account's editable paths | `projectionlab_get_current_finances` |
|
|
126
127
|
| Everything (rarely needed) | `projectionlab_export_data` |
|
|
127
128
|
| Snapshots already saved (id, time, operation, sections) | `projectionlab_list_snapshots` |
|
|
@@ -140,6 +141,19 @@ narrowest read that answers the question.
|
|
|
140
141
|
`listPaths: true` to list editable dot paths with their JSON types.
|
|
141
142
|
- `projectionlab_get_plan_settings` returns `variables`, `montecarlo` and
|
|
142
143
|
`withdrawalStrategy` as dot paths with JSON types; pass `section` for one.
|
|
144
|
+
- `projectionlab_get_settings_report` renders the same three sections as a
|
|
145
|
+
markdown report for the user, grouped by topic with everyday settings first
|
|
146
|
+
(growth and inflation, withdrawals, tax strategy, taxes, bonds), then more
|
|
147
|
+
and advanced ones. Settings use their on-screen label where one is known and
|
|
148
|
+
an italic descriptive name otherwise, with values as the app shows them.
|
|
149
|
+
Settings the plan's current choices leave unused (a withdrawal rule that is
|
|
150
|
+
not selected, custom rate curves in fixed mode) are listed near the end
|
|
151
|
+
with the choice that would use them. Add
|
|
152
|
+
`comparePlanIdentifier` for a second plan's column and a Differs marker, and
|
|
153
|
+
`differencesOnly: true` to list only what differs. Show the report as
|
|
154
|
+
returned. Use it when the user asks to see, review or compare settings; use
|
|
155
|
+
`projectionlab_get_plan_settings` for the paths a write needs, and
|
|
156
|
+
`projectionlab_diff` with `planA` and `planB` for events and accounts.
|
|
143
157
|
- `projectionlab_get_current_finances` with an exact `accountId` and
|
|
144
158
|
`listPaths: true` lists that account's editable paths. Real-estate assets
|
|
145
159
|
(`type: "real-estate"` in `assets`) carry a `realEstate` block:
|
|
@@ -235,11 +249,9 @@ values; it is not an API, and it does not contain the application logic.
|
|
|
235
249
|
When a change's effect matters, the user has to look at the result in the
|
|
236
250
|
ProjectionLab UI. The stored data cannot show it.
|
|
237
251
|
|
|
238
|
-
### ProjectionLab 5
|
|
252
|
+
### How ProjectionLab 5 stores the data
|
|
239
253
|
|
|
240
|
-
|
|
241
|
-
on ProjectionLab 5 and its data has a different layout. The read tools handle
|
|
242
|
-
both layouts; these differences show through:
|
|
254
|
+
These traits of the ProjectionLab 5 data show through the tools:
|
|
243
255
|
|
|
244
256
|
- **No active plan.** A ProjectionLab 5 plan has no `active` flag, so
|
|
245
257
|
`projectionlab_get_plan` reports `active: "not reported"`. Never call a plan
|
|
@@ -255,8 +267,7 @@ both layouts; these differences show through:
|
|
|
255
267
|
`eventIdentifier` matches no event id or name. A priority's `accountId` is
|
|
256
268
|
different: it holds the id of the plan's account event, not the Current
|
|
257
269
|
Finances account id. Keep the two kinds of id apart.
|
|
258
|
-
- **Linked fields belong to Current Finances.**
|
|
259
|
-
event takes some fields from the item it links to, and ProjectionLab
|
|
270
|
+
- **Linked fields belong to Current Finances.** A linked event takes some fields from the item it links to, and ProjectionLab
|
|
260
271
|
overwrites a value written to them in the plan. An account event takes its
|
|
261
272
|
name, type, balance, owner, icon, liquidity, cost basis and withdrawal terms
|
|
262
273
|
(`EWAge`, `hasEWPenalty`, `EWPenaltyRate`, `withdrawContribsFree`), among
|
|
@@ -272,22 +283,12 @@ both layouts; these differences show through:
|
|
|
272
283
|
Finances document, not one per plan, so `projectionlab_update_account` and
|
|
273
284
|
a Current Finances restore change what every plan starts from. Say so in
|
|
274
285
|
the preview before confirming. Plans keep their own copies of the linked
|
|
275
|
-
fields.
|
|
276
|
-
|
|
277
|
-
|
|
286
|
+
fields. Those copies refresh when a plan is opened or saved, so an export
|
|
287
|
+
can show an old value in a plan nobody has opened since. Read today's
|
|
288
|
+
figure from Current Finances, not from a plan event. A balance or value
|
|
278
289
|
edit also overwrites that account's `accountHistory` entry for the current
|
|
279
290
|
day.
|
|
280
|
-
- **
|
|
281
|
-
follow the layout the last connection check found. Read
|
|
282
|
-
`projectionlab://data-model?layout=v4` or `?layout=v5` (the same for
|
|
283
|
-
`knowledge`) to pick one explicitly.
|
|
284
|
-
- **Every write but Progress works.** The plan tools (`projectionlab_update_plan_event`,
|
|
285
|
-
`projectionlab_update_plan_section`, `projectionlab_update_plan_settings`,
|
|
286
|
-
`projectionlab_clone_plan`, `projectionlab_delete_plan`,
|
|
287
|
-
`projectionlab_restore_plans`) and `projectionlab_update_account` behave as
|
|
288
|
-
on ProjectionLab 4. `projectionlab_update_account` reports the account's
|
|
289
|
-
`kind` instead of a `collection`.
|
|
290
|
-
- **Current Finances restores keep missing accounts.** On ProjectionLab 5,
|
|
291
|
+
- **Current Finances restores keep missing accounts.**
|
|
291
292
|
`projectionlab_restore_current_finances` and a rollback of a Current
|
|
292
293
|
Finances snapshot replace every non-account field and each account they
|
|
293
294
|
hold, but never delete an account: one missing from the submission or the
|
|
@@ -295,9 +296,8 @@ both layouts; these differences show through:
|
|
|
295
296
|
lists those as `keptAccounts`; tell the user, and have them archive or
|
|
296
297
|
delete such an account in the ProjectionLab app if it should go.
|
|
297
298
|
- **Settings restores replace the whole document.**
|
|
298
|
-
`projectionlab_restore_settings
|
|
299
|
-
|
|
300
|
-
document it cannot read. Settings are account-wide, not per plan.
|
|
299
|
+
With `projectionlab_restore_settings`, the submission replaces every
|
|
300
|
+
setting, and ProjectionLab refuses a settings document it cannot read. Settings are account-wide, not per plan.
|
|
301
301
|
- **Year alignment can change plans.** The account's year alignment
|
|
302
302
|
(`settings.plan.alignment`) and a plan's override (`variables.alignment`)
|
|
303
303
|
decide where each plan year starts, and so how many plan years the plan
|
|
@@ -316,12 +316,9 @@ both layouts; these differences show through:
|
|
|
316
316
|
document the user has just edited until a read shows the edit: a write
|
|
317
317
|
replaces the unsaved change.
|
|
318
318
|
- **Progress cannot be written.** ProjectionLab 5 records Progress history
|
|
319
|
-
by itself whenever a current value changes
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
`WRITE_NOT_SUPPORTED` before they preview or snapshot anything. Tell the
|
|
323
|
-
user plainly; to bring back Progress from a backup file, they use Restore
|
|
324
|
-
in the ProjectionLab app.
|
|
319
|
+
by itself whenever a current value changes and offers no way to replace
|
|
320
|
+
it, so no tool writes it. Tell the user plainly; to bring back Progress
|
|
321
|
+
from a backup file, they use Restore in the ProjectionLab app.
|
|
325
322
|
- **Old snapshots.** A snapshot taken on ProjectionLab 4 cannot be compared
|
|
326
323
|
with or restored onto ProjectionLab 5 data: `projectionlab_diff` and
|
|
327
324
|
`projectionlab_rollback` refuse it with `LAYOUT_MISMATCH`. A ProjectionLab 4
|
|
@@ -336,7 +333,7 @@ Change the plan only when the user explicitly asks for that change.
|
|
|
336
333
|
- Never guess a path. Read it first with `projectionlab_get_plan_settings`,
|
|
337
334
|
`projectionlab_get_plan_section` or `projectionlab_get_current_finances`,
|
|
338
335
|
the last two with `listPaths: true`.
|
|
339
|
-
- Never assume a rate's scale. ProjectionLab
|
|
336
|
+
- Never assume a rate's scale. ProjectionLab stores most rates as
|
|
340
337
|
percentage points (`variables.inflation: 3` means 3%), but some as fractions
|
|
341
338
|
(`variables.taxStrategy.bracketRate: 0.22` means 22%). Read the current
|
|
342
339
|
value first and write the new one on the same scale; `projectionlab://data-model`
|
|
@@ -376,8 +373,8 @@ not enable writes on your own.
|
|
|
376
373
|
|
|
377
374
|
### Units
|
|
378
375
|
|
|
379
|
-
The scale of a number is the easiest thing to get wrong.
|
|
380
|
-
|
|
376
|
+
The scale of a number is the easiest thing to get wrong.
|
|
377
|
+
`projectionlab://data-model` records these scales:
|
|
381
378
|
|
|
382
379
|
- Rates in `variables` are percentage points: `inflation: 3` means 3%.
|
|
383
380
|
- `taxStrategy.bracketRate` and `taxStrategy.capGainsBracketRate` are decimal
|
|
@@ -452,7 +449,7 @@ Every tool below also takes `confirm` (default `false`, a dry run).
|
|
|
452
449
|
| A what-if copy of a plan | `projectionlab_clone_plan` | `planIdentifier`, `newName` |
|
|
453
450
|
| Remove a plan the user has decided to discard | `projectionlab_delete_plan` | `planId` (exact ID only) |
|
|
454
451
|
| A whole plan section, rebuilt deliberately | `projectionlab_update_plan_section` | `planIdentifier`, `section`, complete `sectionData`, plus `expectedPlanVersion` from the dry run |
|
|
455
|
-
| Replace a whole data area (rare) | `projectionlab_restore_plans`, `projectionlab_restore_current_finances`, `
|
|
452
|
+
| Replace a whole data area (rare) | `projectionlab_restore_plans`, `projectionlab_restore_current_finances`, `projectionlab_restore_settings` | `plans`, `currentFinances`, `settings`: the complete replacement |
|
|
456
453
|
| Undo a confirmed change | `projectionlab_rollback` | exactly one of `snapshotId`, `nBack`, `beforeTime` |
|
|
457
454
|
|
|
458
455
|
Prefer the targeted tools: they change only the paths given and keep sibling
|
|
@@ -480,9 +477,8 @@ patch the copy.
|
|
|
480
477
|
refuses the last remaining plan. Its snapshot lets
|
|
481
478
|
`projectionlab_rollback` restore the deleted plan.
|
|
482
479
|
|
|
483
|
-
`projectionlab_restore_current_finances`, `projectionlab_restore_plans
|
|
484
|
-
`
|
|
485
|
-
an entire data area. Use them only when the user wants exactly that.
|
|
480
|
+
`projectionlab_restore_current_finances`, `projectionlab_restore_plans` and
|
|
481
|
+
`projectionlab_restore_settings` replace an entire data area. Use them only when the user wants exactly that.
|
|
486
482
|
`projectionlab_restore_plans` refuses an empty array, which would delete every
|
|
487
483
|
plan.
|
|
488
484
|
|
|
@@ -627,27 +623,10 @@ must-have." Same plan and event as the example above.
|
|
|
627
623
|
`{"spendingType": {"before": "discretionary", "after": "essential"}}`.
|
|
628
624
|
Show it, get the user's approval, then confirm.
|
|
629
625
|
|
|
630
|
-
**Change a Current Finances account
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
property reads as `type: "real-estate"`). Then
|
|
635
|
-
`projectionlab_get_current_finances` with that `accountId` and
|
|
636
|
-
`listPaths: true` lists the account's editable paths, including `amount`
|
|
637
|
-
and `balance`.
|
|
638
|
-
2. `projectionlab_update_account` with
|
|
639
|
-
`{"accountId": "acct_abc123", "pathChanges": {"amount": 480000}}` returns
|
|
640
|
-
`dryRun: true`, the `accountName`, `collection: "assets"`, and `changes`
|
|
641
|
-
such as `{"amount": {"before": 450000, "after": 480000}}`. A property's
|
|
642
|
-
market value is stored in `amount`; `balance` is its outstanding loan, so
|
|
643
|
-
a value change goes in `amount`, never `balance`. Show the preview.
|
|
644
|
-
3. After the user approves, repeat the call with `"confirm": true`. The reply
|
|
645
|
-
gives `verified` and saves a snapshot of Current Finances.
|
|
646
|
-
|
|
647
|
-
**The same change on ProjectionLab 5.** When `projectionlab_check_connection`
|
|
648
|
-
reports `apiContract: 2`, Current Finances accounts are records of
|
|
649
|
-
`documents.currentFinances.accounts`, keyed by id and narrowed by `kind`, and
|
|
650
|
-
a property keeps its loan in a separate debt record.
|
|
626
|
+
**Change a Current Finances account.** User: "Our rental property is worth
|
|
627
|
+
480000 now; update Current Finances." Current Finances accounts are records
|
|
628
|
+
of `documents.currentFinances.accounts`, keyed by id and narrowed by `kind`,
|
|
629
|
+
and a property keeps its loan in a separate debt record.
|
|
651
630
|
|
|
652
631
|
1. `projectionlab_describe_schema` reports `layout: "v5"` and lists every
|
|
653
632
|
account with its stored `kind` and `type`: the property is a
|
|
@@ -663,8 +642,7 @@ a property keeps its loan in a separate debt record.
|
|
|
663
642
|
`listPaths: true` lists the record's editable paths, including `value` and
|
|
664
643
|
`purchasePrice`. Then `projectionlab_update_account` with
|
|
665
644
|
`{"accountId": "asset_abc123", "pathChanges": {"value": 480000}}` returns
|
|
666
|
-
`dryRun: true`, the `accountName`, `kind: "real-asset"`
|
|
667
|
-
ProjectionLab 4 reply carries a `collection`, and `changes` such as
|
|
645
|
+
`dryRun: true`, the `accountName`, `kind: "real-asset"`, and `changes` such as
|
|
668
646
|
`{"value": {"before": 450000, "after": 480000}}`. A property's market value
|
|
669
647
|
is stored in `value`, never in `balance`: `balance` belongs to the debt, so
|
|
670
648
|
the loan itself changes only by patching `debt_abc123`. Say in the preview
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { type McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
-
import type { Bridge } from "../bridge.js";
|
|
3
|
-
import { type ExportLayout } from "../layout.js";
|
|
4
|
-
export interface LayoutResourceSpec {
|
|
5
|
-
name: string;
|
|
6
|
-
uri: string;
|
|
7
|
-
title: string;
|
|
8
|
-
description: string;
|
|
9
|
-
render: (layout: ExportLayout) => string;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Registers a markdown resource whose text follows the ProjectionLab layout.
|
|
13
|
-
*
|
|
14
|
-
* The plain URI is a fixed resource, so it is listed and read by exact match.
|
|
15
|
-
* `<uri>?layout=v4` and `<uri>?layout=v5` are served by a URI template beside
|
|
16
|
-
* it, because the SDK reads a fixed resource only when the requested URI
|
|
17
|
-
* matches it exactly, query string included.
|
|
18
|
-
*/
|
|
19
|
-
export declare function registerLayoutResource(server: McpServer, bridge: Bridge | undefined, spec: LayoutResourceSpec): void;
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { ResourceTemplate, } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
-
import { layoutForContract } from "../layout.js";
|
|
3
|
-
/**
|
|
4
|
-
* Registers a markdown resource whose text follows the ProjectionLab layout.
|
|
5
|
-
*
|
|
6
|
-
* The plain URI is a fixed resource, so it is listed and read by exact match.
|
|
7
|
-
* `<uri>?layout=v4` and `<uri>?layout=v5` are served by a URI template beside
|
|
8
|
-
* it, because the SDK reads a fixed resource only when the requested URI
|
|
9
|
-
* matches it exactly, query string included.
|
|
10
|
-
*/
|
|
11
|
-
export function registerLayoutResource(server, bridge, spec) {
|
|
12
|
-
const metadata = {
|
|
13
|
-
title: spec.title,
|
|
14
|
-
description: spec.description,
|
|
15
|
-
mimeType: "text/markdown",
|
|
16
|
-
};
|
|
17
|
-
const read = async (uri) => {
|
|
18
|
-
let layout;
|
|
19
|
-
const param = uri.searchParams.get("layout");
|
|
20
|
-
if (param === "v5" || param === "v4") {
|
|
21
|
-
layout = param;
|
|
22
|
-
}
|
|
23
|
-
else if (bridge) {
|
|
24
|
-
// The contract the last connection check or write read; reading a
|
|
25
|
-
// resource never waits on the browser.
|
|
26
|
-
const contract = bridge.knownApiContract();
|
|
27
|
-
if (contract !== undefined)
|
|
28
|
-
layout = layoutForContract(contract);
|
|
29
|
-
}
|
|
30
|
-
return {
|
|
31
|
-
contents: [
|
|
32
|
-
{
|
|
33
|
-
uri: uri.href,
|
|
34
|
-
text: spec.render(layout ?? "v4"),
|
|
35
|
-
mimeType: "text/markdown",
|
|
36
|
-
},
|
|
37
|
-
],
|
|
38
|
-
};
|
|
39
|
-
};
|
|
40
|
-
server.registerResource(spec.name, spec.uri, metadata, read);
|
|
41
|
-
server.registerResource(`${spec.name}-layout`, new ResourceTemplate(`${spec.uri}{?layout}`, { list: undefined }), metadata, read);
|
|
42
|
-
}
|
|
43
|
-
//# sourceMappingURL=layoutResource.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"layoutResource.js","sourceRoot":"","sources":["../../src/resources/layoutResource.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,GAEjB,MAAM,yCAAyC,CAAC;AAEjD,OAAO,EAAE,iBAAiB,EAAqB,MAAM,cAAc,CAAC;AAUpE;;;;;;;GAOG;AACH,MAAM,UAAU,sBAAsB,CACpC,MAAiB,EACjB,MAA0B,EAC1B,IAAwB;IAExB,MAAM,QAAQ,GAAG;QACf,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,WAAW,EAAE,IAAI,CAAC,WAAW;QAC7B,QAAQ,EAAE,eAAe;KAC1B,CAAC;IACF,MAAM,IAAI,GAAG,KAAK,EAAE,GAAQ,EAAE,EAAE;QAC9B,IAAI,MAAgC,CAAC;QACrC,MAAM,KAAK,GAAG,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC7C,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;YACrC,MAAM,GAAG,KAAK,CAAC;QACjB,CAAC;aAAM,IAAI,MAAM,EAAE,CAAC;YAClB,kEAAkE;YAClE,uCAAuC;YACvC,MAAM,QAAQ,GAAG,MAAM,CAAC,gBAAgB,EAAE,CAAC;YAC3C,IAAI,QAAQ,KAAK,SAAS;gBAAE,MAAM,GAAG,iBAAiB,CAAC,QAAQ,CAAC,CAAC;QACnE,CAAC;QACD,OAAO;YACL,QAAQ,EAAE;gBACR;oBACE,GAAG,EAAE,GAAG,CAAC,IAAI;oBACb,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,IAAI,IAAI,CAAC;oBACjC,QAAQ,EAAE,eAAe;iBAC1B;aACF;SACF,CAAC;IACJ,CAAC,CAAC;IAEF,MAAM,CAAC,gBAAgB,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC;IAC7D,MAAM,CAAC,gBAAgB,CACrB,GAAG,IAAI,CAAC,IAAI,SAAS,EACrB,IAAI,gBAAgB,CAAC,GAAG,IAAI,CAAC,GAAG,WAAW,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,EACjE,QAAQ,EACR,IAAI,CACL,CAAC;AACJ,CAAC"}
|