@levitating/tensor-mcp 6.0.0 → 6.1.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 +34 -7
- package/dist/index.js +76 -19
- package/package.json +1 -1
- package/skills/tensor/SKILL.md +6 -2
package/README.md
CHANGED
|
@@ -84,13 +84,15 @@ Set two environment variables:
|
|
|
84
84
|
| `TENSOR_BASE_URL` | Tensor instance URL, e.g. `https://tensor.levitating.org` (default: `http://localhost:5000`) |
|
|
85
85
|
| `TENSOR_MCP_READ_ONLY` | Optional. `1` lists only the tools that read (since 6.0.0) |
|
|
86
86
|
| `TENSOR_MCP_TOOLSETS` | Optional. A comma-separated subset of `ledger`, `work`, `files`, `web`: only those halves of Tensor are listed, plus the four tools that need no scope (since 6.0.0). Unknown names are ignored |
|
|
87
|
+
| `TENSOR_AGENT_NAME` | Optional. The name this agent goes by, when several agents share one key. Tensor records it beside the key on every write and prints it as a claim ("calls itself …"), never in place of the key's own name. Better still, give each agent its own key: a key's name must be unique among your live keys |
|
|
87
88
|
|
|
88
|
-
The
|
|
89
|
-
security boundary (the key's scopes are). The hosted endpoint
|
|
90
|
-
two as request headers, `X-Tensor-Read-Only: 1` and
|
|
91
|
-
`X-Tensor-Toolsets: ledger,work`,
|
|
92
|
-
|
|
93
|
-
the exact MCP URL it was issued
|
|
89
|
+
The two `TENSOR_MCP_*` variables narrow the list to save the agent's context;
|
|
90
|
+
they are not a security boundary (the key's scopes are). The hosted endpoint
|
|
91
|
+
takes the same two as request headers, `X-Tensor-Read-Only: 1` and
|
|
92
|
+
`X-Tensor-Toolsets: ledger,work`, and the agent's name as `X-Tensor-Agent`,
|
|
93
|
+
for a client that lets you set headers. They are headers rather than query
|
|
94
|
+
parameters because an OAuth token is bound to the exact MCP URL it was issued
|
|
95
|
+
for.
|
|
94
96
|
|
|
95
97
|
## Running standalone
|
|
96
98
|
|
|
@@ -407,7 +409,7 @@ Bodies and comments are TipTap JSON, never HTML — the write tools take plain t
|
|
|
407
409
|
| `list_todos` | `tensor:todos:read` | List todos with server-side filters (state, category, assignee, priority, tag, parent, linked record, search, `trash`) and sort. `assigneeId` and `tagId` take one id or several |
|
|
408
410
|
| `get_todo` | `tensor:todos:read` | One todo: body, state, canonical tags, links, sub-task counts. Links to records your key cannot read are omitted |
|
|
409
411
|
| `get_todo_subtree` | `tensor:todos:read` | The branch under a todo — counts and depth, for naming what a delete or a re-parent takes with it |
|
|
410
|
-
| `get_todo_activity` | `tensor:todos:read` | Activity feed, folded from the mutation audit log — a rolling
|
|
412
|
+
| `get_todo_activity` | `tensor:todos:read` | Activity feed, folded from the mutation audit log — a rolling one-year window (past 90 days an entry says what changed, not to what), not permanent history |
|
|
411
413
|
| `create_todo` | `tensor:todos:write` + each `links` target's read scope | Create a todo (plain-text `body`, wrapped to TipTap JSON; `stateId` from `list_todo_states`). The optional `links` array takes the same target types as `attach_todo_link` — the six ledger records plus todo, idea and memo, never `file` — and a target your key cannot read fails the create with a `403` rather than being dropped |
|
|
412
414
|
| `update_todo` | `tensor:todos:write` | Partial update; optional stale-write guard via `expectedUpdatedAt` |
|
|
413
415
|
| `delete_todo` | `tensor:todos:write` | Move the todo **and its whole branch** to Trash, atomically. Soft; `restore_todo` undoes it, and Trash self-empties after 60 days |
|
|
@@ -447,6 +449,7 @@ The capture inbox. An idea's body is a TipTap document since 4.2.0 — plain tex
|
|
|
447
449
|
| `restore_idea` | `tensor:ideas:write` | Restore from Trash, on the side of the archive it was deleted from |
|
|
448
450
|
| `archive_idea` | `tensor:ideas:write` | Archive: off the active stream, kept for good (5.6.0). Idempotent; an idea in Trash is a `409` |
|
|
449
451
|
| `unarchive_idea` | `tensor:ideas:write` | Back into the active stream (5.6.0). Idempotent; an idea in Trash is a `409` |
|
|
452
|
+
| `get_idea_activity` | `tensor:ideas:read` | Activity feed, folded from the mutation audit log — who changed the idea, through which client and why; a rolling one-year window (past 90 days an entry says what changed, not to what), not permanent history |
|
|
450
453
|
| `list_idea_comments` | `tensor:ideas:read` | The comment thread |
|
|
451
454
|
| `create_idea_comment` | `tensor:ideas:write` | Comment (plain text, stored as TipTap JSON) |
|
|
452
455
|
| `update_idea_comment` | `tensor:ideas:write` | Edit your own comment — comments are never deletable here |
|
|
@@ -526,6 +529,30 @@ The Tensor user who issued the key is the ceiling: a key can never do more than
|
|
|
526
529
|
|
|
527
530
|
Newest first. A tool rename or removal is a MAJOR bump; new tools and new optional inputs are MINOR (`docs/contract/MCP.md` §6).
|
|
528
531
|
|
|
532
|
+
### 6.1.0 — Saying why, and working beside other agents
|
|
533
|
+
New optional inputs only; no tool is renamed or removed and no scope changes.
|
|
534
|
+
|
|
535
|
+
- **Every write tool takes `reason`**: one sentence, at most 200 characters,
|
|
536
|
+
sent as `X-Tensor-Reason`. Tensor keeps it with the write for a year and
|
|
537
|
+
shows it, quoted, beside the change in Activity and the change log.
|
|
538
|
+
- **The agent's own name**: `TENSOR_AGENT_NAME` (stdio) or the
|
|
539
|
+
`X-Tensor-Agent` header (hosted) is sent on every call, for agents sharing
|
|
540
|
+
one key. Tensor prints it as a claim beside the key's name.
|
|
541
|
+
- **Stale writes refused**: `update_entity`, `update_account`, `update_asset`,
|
|
542
|
+
`update_institution`, `update_position` and `update_idea` take
|
|
543
|
+
`expectedUpdatedAt`, as `update_todo` did. A record that changed meanwhile
|
|
544
|
+
answers 409 `stale_write` with the current record and who changed it, and
|
|
545
|
+
the tool says what to do about it.
|
|
546
|
+
- **`list_changes` says who**: each change carries `via` (kind, name, door,
|
|
547
|
+
tool, the name the agent called itself, and the credential's `ref`) and
|
|
548
|
+
`reason`. New filters: `excludeSelf`, `via` (`agent`, `web`, `app`, `key`,
|
|
549
|
+
`oauth`, `system`) and `actor` (one credential's `ref`).
|
|
550
|
+
- A write's answer now names the client that made it in `changedVia`
|
|
551
|
+
(and `createdVia` on a create), instead of the one before.
|
|
552
|
+
- **One new read tool, `get_idea_activity`** (`tensor:ideas:read`): an idea's feed, the
|
|
553
|
+
twin of `get_todo_activity` — the latest 50 entries of who changed it,
|
|
554
|
+
through which client, and why.
|
|
555
|
+
|
|
529
556
|
### 6.0.0 — Shorter tool list, pages, and one call per question
|
|
530
557
|
**Breaking:** the paged list tools answer `{ items, hasMore, nextOffset }`
|
|
531
558
|
instead of a bare array, and ask for 100 rows by default (the REST default is
|
package/dist/index.js
CHANGED
|
@@ -25,6 +25,7 @@ How to work well here:
|
|
|
25
25
|
6. Lists answer {items, hasMore, nextOffset}: 100 rows unless you pass limit (at most 1000); pass nextOffset as offset for the next page. Filter on the server (filters combine with AND; a value Tensor cannot parse is ignored, which widens the answer) and catch up with list_changes(since) instead of re-reading everything. Times are epoch milliseconds.
|
|
26
26
|
7. A body you send (todos, ideas, comments) is plain text, one paragraph per line; Tensor stores a document and returns the text as body or bodyText. Sending body replaces the whole body. You can edit only your own comments, and none can be deleted.
|
|
27
27
|
8. A download or media URL is a bearer link to a private file and stays in this conversation: mint one only right before fetching, and never repost it. Each one is logged.
|
|
28
|
+
9. Other agents and people work here too, and every write records which client made it. Give a write a short reason when it is not obvious; the user sees it beside the change. Edit with the updatedAt you read as expectedUpdatedAt, so a change someone made meanwhile is refused (409 with the current record) instead of overwritten. list_changes(excludeSelf: true) shows what others did since you last looked.
|
|
28
29
|
|
|
29
30
|
Before an unfamiliar job, call get_guide with a topic: ledger, imports, work, files or safety.`;
|
|
30
31
|
var GUIDE_TOPICS = {
|
|
@@ -120,7 +121,7 @@ attach_todo_link, attach_idea_link and attach_file_link join a record to any led
|
|
|
120
121
|
search_records is one ranked search over every type you can read. It resolves reference ids directly (TSK-12, IDEA-7, AS021). Types your scopes do not cover are left out silently. For market tickers use search_market_quotes instead.
|
|
121
122
|
|
|
122
123
|
## Keeping up to date
|
|
123
|
-
list_changes(since) returns creates, updates and deletes across everything your scopes can read, kept for
|
|
124
|
+
list_changes(since) returns creates, updates and deletes across everything your scopes can read, kept for a year, each with the client that made it (via) and the reason it gave. Resume from the until it returns. When coverage.complete is false, do a full read instead. excludeSelf: true leaves out your own writes; via: ["agent"] or actor (a change's via.ref) narrows it to other agents or to one.`
|
|
124
125
|
},
|
|
125
126
|
files: {
|
|
126
127
|
title: "Files: finding, uploading, attaching and downloading",
|
|
@@ -162,6 +163,9 @@ Soft deletes (todos, ideas, files, bookmarks, tab groups) are recoverable for 60
|
|
|
162
163
|
## Retrying
|
|
163
164
|
Every write a retry could duplicate takes an optional idempotencyKey. Use a fresh unique value per intended write and the SAME value when you retry that write after a timeout or a network error; Tensor then returns the first result instead of writing again. Never reuse a key for a different write.
|
|
164
165
|
|
|
166
|
+
## Working beside other agents
|
|
167
|
+
Every write records which client made it: the key or the connection, never a name you choose. If you share a key with other agents, the user can give you a name for it (TENSOR_AGENT_NAME for the stdio package, or the X-Tensor-Agent header); Tensor shows it as the name you call yourself, beside the key's own. Each write tool takes an optional reason (one sentence, at most 200 characters); the user reads it beside the change in Activity, so write it for them and keep it factual. Before editing a record someone else may touch, read it and pass its updatedAt as expectedUpdatedAt: a 409 stale_write means it changed meanwhile, and the answer carries the current record and who changed it. Merge onto that and retry, or ask the user when the two changes disagree. Never retry the same edit blindly without it.
|
|
168
|
+
|
|
165
169
|
## What this connection can do
|
|
166
170
|
Each connection carries scopes (portfolio, reference, files, todos, ideas, bookmarks, tabs, each read or write, plus the data pipeline). Only the tools its scopes reach are listed, and a 403 names a missing scope. Some things no connection can do, by design: read memos or browsing history; change FX rates, loan terms or fund terms (they are read-only); empty a Trash or permanently purge; create API keys or change its own access. When you cannot do something, tell the user which scope or which part of the Tensor app it needs.
|
|
167
171
|
|
|
@@ -170,7 +174,7 @@ Each connection carries scopes (portfolio, reference, files, todos, ideas, bookm
|
|
|
170
174
|
- 401: the credential is revoked, expired or wrong. The user must reconnect Tensor.
|
|
171
175
|
- 403: a missing scope (named in the message) or something no connection may do. Do not retry.
|
|
172
176
|
- 404: no such record for this connection. Check the id with search_records or a list_ call.
|
|
173
|
-
- 409: a conflict with the record's current state (a cycle, a state still in use,
|
|
177
|
+
- 409: a conflict with the record's current state (a cycle, a state still in use), stale_write (it changed since the updatedAt you sent: read current, merge, retry), an idempotencyKey problem, or delete_blocked (other records still use this one). The message says which.
|
|
174
178
|
- 428: not an error. A permanent delete is waiting for the user's yes; see "Ask the user before".
|
|
175
179
|
- 429: rate limited (an API key allows 120 requests a minute). Wait as told, then continue. Batch work instead of looping single calls.
|
|
176
180
|
- 5xx: Tensor failed. One retry is fine; then report it with the errorId.
|
|
@@ -378,7 +382,7 @@ var TOOL_SCOPE_LISTS = {
|
|
|
378
382
|
"tensor:files:write": "create_file_upload_url confirm_file_upload update_file delete_file restore_file attach_file_link detach_file_link create_file_folder update_file_folder delete_file_folder",
|
|
379
383
|
"tensor:todos:read": "list_todos get_todo get_todo_subtree get_todo_activity list_todo_comments list_todo_states list_todo_tags list_todo_files list_todo_links",
|
|
380
384
|
"tensor:todos:write": "create_todo update_todo delete_todo restore_todo set_todo_parent reorder_todo set_todo_tags create_todo_comment update_todo_comment create_todo_state update_todo_state delete_todo_state create_todo_tag update_todo_tag delete_todo_tag attach_todo_file detach_todo_file attach_todo_link detach_todo_link",
|
|
381
|
-
"tensor:ideas:read": "list_ideas get_idea list_idea_comments list_idea_tags list_idea_sites get_idea_media_url list_idea_links list_idea_kinds",
|
|
385
|
+
"tensor:ideas:read": "list_ideas get_idea get_idea_activity list_idea_comments list_idea_tags list_idea_sites get_idea_media_url list_idea_links list_idea_kinds",
|
|
382
386
|
"tensor:ideas:write": "create_idea update_idea delete_idea restore_idea archive_idea unarchive_idea create_idea_comment update_idea_comment create_idea_upload_url attach_idea_link detach_idea_link",
|
|
383
387
|
"tensor:bookmarks:read": "list_bookmarks get_bookmark list_bookmark_folders",
|
|
384
388
|
"tensor:bookmarks:write": "create_bookmark update_bookmark delete_bookmark restore_bookmark create_bookmark_folder update_bookmark_folder delete_bookmark_folder move_bookmark move_bookmark_folder",
|
|
@@ -435,6 +439,9 @@ function isIdempotentTool(name) {
|
|
|
435
439
|
const a = toolAnnotations(name);
|
|
436
440
|
return a.readOnlyHint || a.idempotentHint === true;
|
|
437
441
|
}
|
|
442
|
+
function toolTakesReason(name) {
|
|
443
|
+
return !toolAnnotations(name).readOnlyHint;
|
|
444
|
+
}
|
|
438
445
|
function toolTakesIdempotencyKey(name) {
|
|
439
446
|
return !isIdempotentTool(name) && !name.startsWith("data_") && !NO_KEY_TOOLS.has(name);
|
|
440
447
|
}
|
|
@@ -490,8 +497,11 @@ async function unlessMissing(call) {
|
|
|
490
497
|
}
|
|
491
498
|
}
|
|
492
499
|
var IDEMPOTENCY_KEY_INPUT = z2.string().min(1).max(200).optional().describe("Send the same value on a retry and it is written once.");
|
|
500
|
+
var REASON_INPUT = z2.string().max(200).optional().describe("Why, in one sentence. Shown beside the change in Tensor.");
|
|
501
|
+
var EXPECTED_UPDATED_AT_INPUT = z2.number().optional().describe("The updatedAt you read. If the record changed since, the edit is refused (409) with the current record.");
|
|
493
502
|
var CALL_CLIENT = new AsyncLocalStorage();
|
|
494
503
|
var CALL_KEY = new AsyncLocalStorage();
|
|
504
|
+
var CALL_REASON = new AsyncLocalStorage();
|
|
495
505
|
var DEFINITIONS = null;
|
|
496
506
|
function toolDefinitions() {
|
|
497
507
|
if (DEFINITIONS) return DEFINITIONS;
|
|
@@ -503,24 +513,39 @@ function toolDefinitions() {
|
|
|
503
513
|
throw new Error(`MCP tool ${name} has no entry in TOOL_SCOPE_LISTS (mcp-server/tools.ts).`);
|
|
504
514
|
}
|
|
505
515
|
const takesKey = toolTakesIdempotencyKey(name);
|
|
516
|
+
const annotations = toolAnnotations(name);
|
|
517
|
+
const takesReason = toolTakesReason(name);
|
|
518
|
+
const keyed = takesKey ? (args, extra) => {
|
|
519
|
+
const { idempotencyKey, ...rest } = args ?? {};
|
|
520
|
+
if (typeof idempotencyKey !== "string" || !idempotencyKey) return handler(rest, extra);
|
|
521
|
+
return CALL_KEY.run({ base: idempotencyKey, writes: 0 }, () => handler(rest, extra));
|
|
522
|
+
} : handler;
|
|
506
523
|
definitions.push({
|
|
507
524
|
name,
|
|
508
525
|
scope,
|
|
509
526
|
description,
|
|
510
|
-
shape:
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
527
|
+
shape: {
|
|
528
|
+
...shape,
|
|
529
|
+
...takesKey ? { idempotencyKey: IDEMPOTENCY_KEY_INPUT } : {},
|
|
530
|
+
...takesReason ? { reason: REASON_INPUT } : {}
|
|
531
|
+
},
|
|
532
|
+
annotations,
|
|
533
|
+
handler: takesReason ? (args, extra) => {
|
|
534
|
+
const { reason, ...rest } = args ?? {};
|
|
535
|
+
if (typeof reason !== "string" || !reason.trim()) return keyed(rest, extra);
|
|
536
|
+
return CALL_REASON.run(reason, () => keyed(rest, extra));
|
|
537
|
+
} : keyed
|
|
517
538
|
});
|
|
518
539
|
}
|
|
519
540
|
};
|
|
520
541
|
const api2 = (method, path, body, options) => {
|
|
521
542
|
const client = CALL_CLIENT.getStore();
|
|
522
543
|
if (!client) throw new Error("A Tensor MCP tool ran without a client bound (registerAllTools binds one per call).");
|
|
523
|
-
return client(method, path, body, {
|
|
544
|
+
return client(method, path, body, {
|
|
545
|
+
...options,
|
|
546
|
+
idempotencyKey: idempotencyKeyFor(CALL_KEY, method),
|
|
547
|
+
reason: options?.reason ?? CALL_REASON.getStore()
|
|
548
|
+
});
|
|
524
549
|
};
|
|
525
550
|
defineTools(collector, api2);
|
|
526
551
|
for (const d of definitions) toolsetOf(d.scope);
|
|
@@ -574,6 +599,8 @@ function describeApiFailure(method, path, status, text, retryAfter) {
|
|
|
574
599
|
advice = "The first attempt is still running. Retry in a few seconds with the same idempotencyKey.";
|
|
575
600
|
} else if (status === 409 && parsed?.code === "idempotency_key_conflict") {
|
|
576
601
|
advice = "That idempotencyKey was already used with different arguments. Use a new key for a new write.";
|
|
602
|
+
} else if (status === 409 && parsed?.code === "stale_write") {
|
|
603
|
+
advice = "Someone changed this record since you read it (`changedBy` says who, `current` is the record now). Merge your change onto `current`, and retry with its updatedAt; ask the user if the two changes disagree.";
|
|
577
604
|
} else if (status === 409 && parsed?.code === "delete_blocked") {
|
|
578
605
|
advice = "Other records still use this one (preview.blockedBy). Tell the user what they are; it can be deleted only after those are moved or deleted.";
|
|
579
606
|
} else if (status === 428) {
|
|
@@ -687,6 +714,7 @@ function defineTools(server2, api2) {
|
|
|
687
714
|
"Edit an entity. Only the fields sent change.",
|
|
688
715
|
{
|
|
689
716
|
id: z2.number().describe("Entity ID to update"),
|
|
717
|
+
expectedUpdatedAt: EXPECTED_UPDATED_AT_INPUT,
|
|
690
718
|
name: z2.string().optional().describe("New entity name"),
|
|
691
719
|
type: z2.string().optional().describe("New entity type key"),
|
|
692
720
|
jurisdiction: z2.string().optional().describe("Legal jurisdiction"),
|
|
@@ -846,6 +874,7 @@ function defineTools(server2, api2) {
|
|
|
846
874
|
"Edit an account. Only the fields sent change.",
|
|
847
875
|
{
|
|
848
876
|
id: z2.number().describe("Account ID to update"),
|
|
877
|
+
expectedUpdatedAt: EXPECTED_UPDATED_AT_INPUT,
|
|
849
878
|
name: z2.string().optional(),
|
|
850
879
|
entityId: z2.number().optional(),
|
|
851
880
|
accountType: z2.string().optional().describe("Account type key"),
|
|
@@ -921,6 +950,7 @@ function defineTools(server2, api2) {
|
|
|
921
950
|
"Edit an asset. Set tickerSymbol to link or relink it to a market quote.",
|
|
922
951
|
{
|
|
923
952
|
id: z2.number().describe("Asset ID to update"),
|
|
953
|
+
expectedUpdatedAt: EXPECTED_UPDATED_AT_INPUT,
|
|
924
954
|
name: z2.string().optional(),
|
|
925
955
|
assetClass: z2.string().optional(),
|
|
926
956
|
symbol: z2.string().optional().describe("Display ticker. Does not price the asset."),
|
|
@@ -1059,6 +1089,7 @@ function defineTools(server2, api2) {
|
|
|
1059
1089
|
"Edit a position. Changing quantity, averageCost, a cash balance (currentValue) or a capital account's costBasis also appends one `adjustment` ledger row recording the difference. Use it to restate totals; record a known trade with create_transaction.",
|
|
1060
1090
|
{
|
|
1061
1091
|
id: z2.number().describe("Position ID to update"),
|
|
1092
|
+
expectedUpdatedAt: z2.number().optional().describe("The updatedAt you read. If the position changed since (an edit, a price, a valuation or a transaction), the edit is refused (409) with the current position."),
|
|
1062
1093
|
entityId: z2.number().optional(),
|
|
1063
1094
|
accountId: z2.number().optional(),
|
|
1064
1095
|
assetId: z2.number().optional(),
|
|
@@ -1252,6 +1283,7 @@ function defineTools(server2, api2) {
|
|
|
1252
1283
|
"Edit an institution.",
|
|
1253
1284
|
{
|
|
1254
1285
|
id: z2.number().describe("Institution ID"),
|
|
1286
|
+
expectedUpdatedAt: EXPECTED_UPDATED_AT_INPUT,
|
|
1255
1287
|
name: z2.string().optional(),
|
|
1256
1288
|
notes: z2.string().optional()
|
|
1257
1289
|
},
|
|
@@ -1626,17 +1658,23 @@ function defineTools(server2, api2) {
|
|
|
1626
1658
|
);
|
|
1627
1659
|
server2.tool(
|
|
1628
1660
|
"list_changes",
|
|
1629
|
-
"Creates, updates and deletes since a time, to catch up instead of re-reading. Resume from the returned `until`. If `coverage.complete` is false the delta is untrustworthy: do a full read. Kept
|
|
1661
|
+
"Creates, updates and deletes since a time, to catch up instead of re-reading. Each change says which client made it (`via`) and why, if it said (`reason`). Resume from the returned `until`. If `coverage.complete` is false the delta is untrustworthy: do a full read. Kept a year. Only types your scopes read appear; memos, links, tags, terms, FX and settings never do.",
|
|
1630
1662
|
{
|
|
1631
1663
|
since: z2.number().optional().describe("Epoch-ms lower bound (exclusive). Omit or 0 for everything on record."),
|
|
1632
1664
|
limit: z2.number().optional().describe("Max changes per page. Default 500."),
|
|
1633
|
-
resourceType: z2.string().optional().describe("Only changes to this resource type, e.g. 'position', 'asset', 'entity'")
|
|
1665
|
+
resourceType: z2.string().optional().describe("Only changes to this resource type, e.g. 'position', 'asset', 'entity'"),
|
|
1666
|
+
excludeSelf: z2.boolean().optional().describe("Leave out this connection's own changes: what others did since."),
|
|
1667
|
+
via: z2.array(z2.enum(["agent", "web", "app", "key", "oauth", "system"])).optional().describe("Only changes from these kinds of client; agent = key or oauth."),
|
|
1668
|
+
actor: z2.string().optional().describe("Only changes by one credential: a change's via.ref, e.g. key:ak_\u2026")
|
|
1634
1669
|
},
|
|
1635
|
-
async ({ since, limit, resourceType }) => {
|
|
1670
|
+
async ({ since, limit, resourceType, excludeSelf, via, actor }) => {
|
|
1636
1671
|
const params = new URLSearchParams();
|
|
1637
1672
|
if (since) params.set("since", String(since));
|
|
1638
1673
|
if (limit) params.set("limit", String(limit));
|
|
1639
1674
|
if (resourceType) params.set("resourceType", resourceType);
|
|
1675
|
+
if (excludeSelf) params.set("excludeSelf", "true");
|
|
1676
|
+
if (via?.length) params.set("via", via.join(","));
|
|
1677
|
+
if (actor) params.set("actor", actor);
|
|
1640
1678
|
const qs = params.toString();
|
|
1641
1679
|
const data = await api2("GET", `/api/v1/changes${qs ? `?${qs}` : ""}`);
|
|
1642
1680
|
return { content: [{ type: "text", text: JSON.stringify(data) }] };
|
|
@@ -1961,7 +1999,7 @@ function defineTools(server2, api2) {
|
|
|
1961
1999
|
);
|
|
1962
2000
|
server2.tool(
|
|
1963
2001
|
"get_todo_activity",
|
|
1964
|
-
"A todo's latest 50 activity entries. Kept
|
|
2002
|
+
"A todo's latest 50 activity entries. Kept a year; past 90 days an entry says what changed, not to what.",
|
|
1965
2003
|
{ id: z2.number().describe("Todo ID") },
|
|
1966
2004
|
async ({ id }) => {
|
|
1967
2005
|
const data = await api2("GET", `/api/todos/${id}/activity`);
|
|
@@ -2009,7 +2047,7 @@ function defineTools(server2, api2) {
|
|
|
2009
2047
|
priority: z2.number().optional().describe("0 = none, 1 = urgent, 2 = high, 3 = medium, 4 = low"),
|
|
2010
2048
|
assigneeId: z2.number().nullable().optional().describe("User ID, or null to unassign"),
|
|
2011
2049
|
dueDate: z2.string().nullable().optional().describe("ISO YYYY-MM-DD, or null to clear"),
|
|
2012
|
-
expectedUpdatedAt:
|
|
2050
|
+
expectedUpdatedAt: EXPECTED_UPDATED_AT_INPUT
|
|
2013
2051
|
},
|
|
2014
2052
|
async ({ id, body, ...rest }) => {
|
|
2015
2053
|
const payload = { ...rest };
|
|
@@ -2354,6 +2392,7 @@ function defineTools(server2, api2) {
|
|
|
2354
2392
|
"Edit an idea. `tags` replaces the tag set; `media` appends. Sending body replaces the whole body document, inline images included (they stay in the gallery): read the idea first if you did not write it.",
|
|
2355
2393
|
{
|
|
2356
2394
|
id: z2.number().describe("Idea ID"),
|
|
2395
|
+
expectedUpdatedAt: EXPECTED_UPDATED_AT_INPUT,
|
|
2357
2396
|
kind: z2.enum(IDEA_KINDS).optional(),
|
|
2358
2397
|
title: z2.string().nullable().optional(),
|
|
2359
2398
|
url: z2.string().nullable().optional(),
|
|
@@ -2413,6 +2452,15 @@ function defineTools(server2, api2) {
|
|
|
2413
2452
|
return { content: [{ type: "text", text: JSON.stringify(data) }] };
|
|
2414
2453
|
}
|
|
2415
2454
|
);
|
|
2455
|
+
server2.tool(
|
|
2456
|
+
"get_idea_activity",
|
|
2457
|
+
"An idea's latest 50 activity entries: who changed it, through which client, and why. Kept a year; past 90 days an entry says what changed, not to what.",
|
|
2458
|
+
{ id: z2.number().describe("Idea ID") },
|
|
2459
|
+
async ({ id }) => {
|
|
2460
|
+
const data = await api2("GET", `/api/ideas/${id}/activity`);
|
|
2461
|
+
return { content: [{ type: "text", text: JSON.stringify(data) }] };
|
|
2462
|
+
}
|
|
2463
|
+
);
|
|
2416
2464
|
server2.tool(
|
|
2417
2465
|
"list_idea_comments",
|
|
2418
2466
|
"An idea's comments. Read bodyText.",
|
|
@@ -2812,15 +2860,24 @@ function createApiClient(opts) {
|
|
|
2812
2860
|
const apiKey = opts.apiKey;
|
|
2813
2861
|
const extraHeaders = Object.fromEntries(
|
|
2814
2862
|
Object.entries(opts.headers ?? {}).filter(
|
|
2815
|
-
([name]) => !/^(authorization|accept|content-type|idempotency-key|tensor-confirm)$/i.test(name)
|
|
2863
|
+
([name]) => !/^(authorization|accept|content-type|idempotency-key|tensor-confirm|x-tensor-reason)$/i.test(name)
|
|
2816
2864
|
)
|
|
2817
2865
|
);
|
|
2866
|
+
const agentName = opts.agentName?.trim();
|
|
2867
|
+
if (agentName) {
|
|
2868
|
+
for (const name of Object.keys(extraHeaders)) if (/^x-tensor-agent$/i.test(name)) delete extraHeaders[name];
|
|
2869
|
+
extraHeaders["X-Tensor-Agent"] = encodeURIComponent(Array.from(agentName).slice(0, 120).join(""));
|
|
2870
|
+
}
|
|
2818
2871
|
return async (method, path, body, options) => {
|
|
2819
2872
|
const headers = {
|
|
2820
2873
|
...extraHeaders,
|
|
2821
2874
|
Authorization: `Bearer ${apiKey}`,
|
|
2822
2875
|
Accept: "application/json"
|
|
2823
2876
|
};
|
|
2877
|
+
const reason = options?.reason?.trim();
|
|
2878
|
+
if (reason && method !== "GET") {
|
|
2879
|
+
headers["X-Tensor-Reason"] = encodeURIComponent(reason.slice(0, 200));
|
|
2880
|
+
}
|
|
2824
2881
|
if (body !== void 0) {
|
|
2825
2882
|
headers["Content-Type"] = "application/json";
|
|
2826
2883
|
}
|
|
@@ -2869,7 +2926,7 @@ var SERVER_IDENTITY = {
|
|
|
2869
2926
|
// package.json
|
|
2870
2927
|
var package_default = {
|
|
2871
2928
|
name: "@levitating/tensor-mcp",
|
|
2872
|
-
version: "6.
|
|
2929
|
+
version: "6.1.0",
|
|
2873
2930
|
description: "Tensor MCP \u2014 Model Context Protocol server for the Tensor wealth management API. Exposes the Tensor API as tools for Claude, Cursor, Codex, and any MCP-aware client.",
|
|
2874
2931
|
type: "module",
|
|
2875
2932
|
main: "./dist/index.js",
|
|
@@ -2942,7 +2999,7 @@ var server = new McpServer({
|
|
|
2942
2999
|
// reasoning live in ./guide.ts; server/routes/mcp.ts passes the same constant.
|
|
2943
3000
|
instructions: SERVER_INSTRUCTIONS
|
|
2944
3001
|
});
|
|
2945
|
-
var api = createApiClient({ apiKey: API_KEY, baseUrl: BASE_URL });
|
|
3002
|
+
var api = createApiClient({ apiKey: API_KEY, baseUrl: BASE_URL, agentName: process.env.TENSOR_AGENT_NAME });
|
|
2946
3003
|
var SELECTION = {
|
|
2947
3004
|
readOnly: parseFlag(process.env.TENSOR_MCP_READ_ONLY),
|
|
2948
3005
|
toolsets: parseToolsets(process.env.TENSOR_MCP_TOOLSETS)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@levitating/tensor-mcp",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.1.0",
|
|
4
4
|
"description": "Tensor MCP — Model Context Protocol server for the Tensor wealth management API. Exposes the Tensor API as tools for Claude, Cursor, Codex, and any MCP-aware client.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
package/skills/tensor/SKILL.md
CHANGED
|
@@ -22,6 +22,7 @@ How to work well here:
|
|
|
22
22
|
6. Lists answer {items, hasMore, nextOffset}: 100 rows unless you pass limit (at most 1000); pass nextOffset as offset for the next page. Filter on the server (filters combine with AND; a value Tensor cannot parse is ignored, which widens the answer) and catch up with list_changes(since) instead of re-reading everything. Times are epoch milliseconds.
|
|
23
23
|
7. A body you send (todos, ideas, comments) is plain text, one paragraph per line; Tensor stores a document and returns the text as body or bodyText. Sending body replaces the whole body. You can edit only your own comments, and none can be deleted.
|
|
24
24
|
8. A download or media URL is a bearer link to a private file and stays in this conversation: mint one only right before fetching, and never repost it. Each one is logged.
|
|
25
|
+
9. Other agents and people work here too, and every write records which client made it. Give a write a short reason when it is not obvious; the user sees it beside the change. Edit with the updatedAt you read as expectedUpdatedAt, so a change someone made meanwhile is refused (409 with the current record) instead of overwritten. list_changes(excludeSelf: true) shows what others did since you last looked.
|
|
25
26
|
|
|
26
27
|
Before an unfamiliar job, call get_guide with a topic: ledger, imports, work, files or safety.
|
|
27
28
|
|
|
@@ -113,7 +114,7 @@ attach_todo_link, attach_idea_link and attach_file_link join a record to any led
|
|
|
113
114
|
search_records is one ranked search over every type you can read. It resolves reference ids directly (TSK-12, IDEA-7, AS021). Types your scopes do not cover are left out silently. For market tickers use search_market_quotes instead.
|
|
114
115
|
|
|
115
116
|
### Keeping up to date
|
|
116
|
-
list_changes(since) returns creates, updates and deletes across everything your scopes can read, kept for
|
|
117
|
+
list_changes(since) returns creates, updates and deletes across everything your scopes can read, kept for a year, each with the client that made it (via) and the reason it gave. Resume from the until it returns. When coverage.complete is false, do a full read instead. excludeSelf: true leaves out your own writes; via: ["agent"] or actor (a change's via.ref) narrows it to other agents or to one.
|
|
117
118
|
|
|
118
119
|
## Files
|
|
119
120
|
|
|
@@ -149,6 +150,9 @@ Soft deletes (todos, ideas, files, bookmarks, tab groups) are recoverable for 60
|
|
|
149
150
|
### Retrying
|
|
150
151
|
Every write a retry could duplicate takes an optional idempotencyKey. Use a fresh unique value per intended write and the SAME value when you retry that write after a timeout or a network error; Tensor then returns the first result instead of writing again. Never reuse a key for a different write.
|
|
151
152
|
|
|
153
|
+
### Working beside other agents
|
|
154
|
+
Every write records which client made it: the key or the connection, never a name you choose. If you share a key with other agents, the user can give you a name for it (TENSOR_AGENT_NAME for the stdio package, or the X-Tensor-Agent header); Tensor shows it as the name you call yourself, beside the key's own. Each write tool takes an optional reason (one sentence, at most 200 characters); the user reads it beside the change in Activity, so write it for them and keep it factual. Before editing a record someone else may touch, read it and pass its updatedAt as expectedUpdatedAt: a 409 stale_write means it changed meanwhile, and the answer carries the current record and who changed it. Merge onto that and retry, or ask the user when the two changes disagree. Never retry the same edit blindly without it.
|
|
155
|
+
|
|
152
156
|
### What this connection can do
|
|
153
157
|
Each connection carries scopes (portfolio, reference, files, todos, ideas, bookmarks, tabs, each read or write, plus the data pipeline). Only the tools its scopes reach are listed, and a 403 names a missing scope. Some things no connection can do, by design: read memos or browsing history; change FX rates, loan terms or fund terms (they are read-only); empty a Trash or permanently purge; create API keys or change its own access. When you cannot do something, tell the user which scope or which part of the Tensor app it needs.
|
|
154
158
|
|
|
@@ -157,7 +161,7 @@ Each connection carries scopes (portfolio, reference, files, todos, ideas, bookm
|
|
|
157
161
|
- 401: the credential is revoked, expired or wrong. The user must reconnect Tensor.
|
|
158
162
|
- 403: a missing scope (named in the message) or something no connection may do. Do not retry.
|
|
159
163
|
- 404: no such record for this connection. Check the id with search_records or a list_ call.
|
|
160
|
-
- 409: a conflict with the record's current state (a cycle, a state still in use,
|
|
164
|
+
- 409: a conflict with the record's current state (a cycle, a state still in use), stale_write (it changed since the updatedAt you sent: read current, merge, retry), an idempotencyKey problem, or delete_blocked (other records still use this one). The message says which.
|
|
161
165
|
- 428: not an error. A permanent delete is waiting for the user's yes; see "Ask the user before".
|
|
162
166
|
- 429: rate limited (an API key allows 120 requests a minute). Wait as told, then continue. Batch work instead of looping single calls.
|
|
163
167
|
- 5xx: Tensor failed. One retry is fine; then report it with the errorId.
|