@astramindapp/mcp-server 0.18.0 → 0.20.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/dist/server.js CHANGED
@@ -293,15 +293,15 @@ function createMindMcpServer(client) {
293
293
  // ─── mind_folders ───────────────────────────────────────
294
294
  // Organize documents into folders. Folders are a presentation layer — the
295
295
  // knowledge graph still indexes every document regardless of folder.
296
- server.tool("mind_folders", "Organize your MIND documents into folders. Folders are a presentation layer — the knowledge graph still indexes and retrieves across every document regardless of folder. Use mind_remember to create a document, then mind_folders move_documents to file it. Actions: list, create, rename, move, delete, move_documents.", {
296
+ server.tool("mind_folders", "Organize your MIND documents into folders. Folders are a presentation layer — the knowledge graph still indexes and retrieves across every document regardless of folder. Use mind_remember to create a document, then mind_folders move_documents to file it. Actions: list, create, rename, move, delete, move_documents, set_hint (set the agent-routing hint read by mind_folder_suggest).", {
297
297
  action: zod_1.z
298
- .enum(["list", "create", "rename", "move", "delete", "move_documents"])
299
- .describe("list (all folders + counts), create (new folder), rename (change a folder's name), move (re-nest a folder), delete (remove a folder — its documents and subfolders move up a level, nothing is deleted), move_documents (file documents into a folder)"),
298
+ .enum(["list", "create", "rename", "move", "delete", "move_documents", "set_hint"])
299
+ .describe("list (all folders + counts + routing hints), create (new folder; pass routing_hint to enable agent-routing), rename (change a folder's name), move (re-nest a folder), delete (remove a folder — its documents and subfolders move up a level, nothing is deleted), move_documents (file documents into a folder), set_hint (write/clear the routing_hint that mind_folder_suggest reads)"),
300
300
  name: zod_1.z.string().optional().describe("Folder name — required for create and rename"),
301
301
  folder_id: zod_1.z
302
302
  .string()
303
303
  .optional()
304
- .describe("Folder id — the folder to rename/move/delete, or the destination for move_documents (omit or pass 'root' to file documents at the top level)"),
304
+ .describe("Folder id — the folder to rename/move/delete/set_hint, or the destination for move_documents (omit or pass 'root' to file documents at the top level)"),
305
305
  parent_id: zod_1.z
306
306
  .string()
307
307
  .optional()
@@ -310,7 +310,11 @@ function createMindMcpServer(client) {
310
310
  .array(zod_1.z.string())
311
311
  .optional()
312
312
  .describe("Document ids to file — required for move_documents"),
313
- }, async ({ action, name, folder_id, parent_id, doc_ids }) => {
313
+ routing_hint: zod_1.z
314
+ .string()
315
+ .optional()
316
+ .describe("Free-text instruction answering \"when should MIND save things to this folder?\". Read by mind_folder_suggest to LLM-route new content. Pass on create to set up-front; pass on set_hint to update. Pass empty string to clear (disables the folder from auto-routing)."),
317
+ }, async ({ action, name, folder_id, parent_id, doc_ids, routing_hint }) => {
314
318
  try {
315
319
  switch (action) {
316
320
  case "list": {
@@ -328,7 +332,9 @@ function createMindMcpServer(client) {
328
332
  const byId = new Map(res.folders.map((f) => [f.id, f]));
329
333
  const lines = res.folders.map((f) => {
330
334
  const parent = f.parent_id ? byId.get(f.parent_id)?.name ?? "?" : "(top level)";
331
- return `• ${f.name} — ${f.document_count ?? 0} doc(s) · id: ${f.id} · parent: ${parent}`;
335
+ const hint = (f.routing_hint || "").trim();
336
+ const hintTail = hint ? ` · hint: ${hint.length > 80 ? hint.slice(0, 80) + "…" : hint}` : "";
337
+ return `• ${f.name} — ${f.document_count ?? 0} doc(s) · id: ${f.id} · parent: ${parent}${hintTail}`;
332
338
  });
333
339
  return {
334
340
  content: [
@@ -346,10 +352,10 @@ function createMindMcpServer(client) {
346
352
  case "create": {
347
353
  if (!name)
348
354
  throw new Error("'name' is required to create a folder");
349
- const res = await client.createFolder(name, parent_id ?? null);
355
+ const res = await client.createFolder(name, parent_id ?? null, routing_hint);
350
356
  return {
351
357
  content: [
352
- { type: "text", text: `Created folder "${res.folder.name}" (id: ${res.folder.id})` },
358
+ { type: "text", text: `Created folder "${res.folder.name}" (id: ${res.folder.id})${routing_hint ? " · routing hint set" : ""}` },
353
359
  ],
354
360
  };
355
361
  }
@@ -404,6 +410,24 @@ function createMindMcpServer(client) {
404
410
  ],
405
411
  };
406
412
  }
413
+ case "set_hint": {
414
+ if (!folder_id)
415
+ throw new Error("'folder_id' is required to set a routing hint");
416
+ if (routing_hint === undefined)
417
+ throw new Error("'routing_hint' is required for set_hint (pass empty string to clear)");
418
+ const res = await client.updateFolder(folder_id, { routing_hint });
419
+ const cleared = !routing_hint.trim();
420
+ return {
421
+ content: [
422
+ {
423
+ type: "text",
424
+ text: cleared
425
+ ? `Cleared routing hint on "${res.folder.name}" — folder is no longer auto-routed.`
426
+ : `Routing hint set on "${res.folder.name}". mind_folder_suggest will now consider this folder.`,
427
+ },
428
+ ],
429
+ };
430
+ }
407
431
  default:
408
432
  throw new Error(`Unknown action: ${action}`);
409
433
  }
@@ -415,6 +439,154 @@ function createMindMcpServer(client) {
415
439
  };
416
440
  }
417
441
  });
442
+ // ─── mind_folder_routes ─────────────────────────────────
443
+ // Deterministic per-source_type system-folder routing. Configure once
444
+ // and every life_item / crm / chat-save / etc. lands in its designated
445
+ // folder automatically. ``apply_recommended`` is the one-tap setup.
446
+ server.tool("mind_folder_routes", "Configure deterministic system-folder routing — which folder each kind of system-generated doc (life items, CRM, chat saves, tasks, training, reasoning trajectories, playbooks, trader signals, cloud imports) is filed into automatically. Actions: list, set, clear, apply_recommended (idempotent one-tap setup that creates Life/CRM/Chats/Reasoning/Trader folders and wires every source_type to its destination). User uploads are unaffected — this is system writes only.", {
447
+ action: zod_1.z
448
+ .enum(["list", "set", "clear", "apply_recommended"])
449
+ .describe("list (current routing table + every supported source_type with label/description), set (route one source_type to a folder), clear (remove a route — that source_type goes to the top level again), apply_recommended (create Life/CRM/Chats/Reasoning/Trader folders if missing and wire all routes; idempotent and safe to re-run)"),
450
+ source_type: zod_1.z
451
+ .string()
452
+ .optional()
453
+ .describe("Required for set and clear. Canonical values: life_item, task, crm, chat, training, trajectory, playbook, trader, document. Custom values accepted (the route will fire whenever save_document_record is called with that source_type)."),
454
+ folder_id: zod_1.z
455
+ .string()
456
+ .optional()
457
+ .describe("Required for set — the folder id to route this source_type into."),
458
+ }, async ({ action, source_type, folder_id }) => {
459
+ try {
460
+ switch (action) {
461
+ case "list": {
462
+ const res = await client.listFolderRoutes();
463
+ const folders = await client.listFolders();
464
+ const folderById = new Map(folders.folders.map((f) => [f.id, f]));
465
+ const lines = res.categories.map((cat) => {
466
+ const fid = res.routes[cat.source_type];
467
+ const folder = fid ? folderById.get(fid) : null;
468
+ const dest = folder
469
+ ? `→ ${folder.name} (id: ${fid})`
470
+ : "→ (unrouted — files at top level)";
471
+ return `• ${cat.label} [${cat.source_type}] ${dest}\n ${cat.description}`;
472
+ });
473
+ const configured = Object.keys(res.routes).length;
474
+ return {
475
+ content: [
476
+ {
477
+ type: "text",
478
+ text: [
479
+ `${configured}/${res.categories.length} routes configured.`,
480
+ "",
481
+ ...lines,
482
+ ].join("\n"),
483
+ },
484
+ ],
485
+ };
486
+ }
487
+ case "set": {
488
+ if (!source_type)
489
+ throw new Error("'source_type' is required");
490
+ if (!folder_id)
491
+ throw new Error("'folder_id' is required for set");
492
+ await client.setFolderRoute(source_type, folder_id);
493
+ return {
494
+ content: [
495
+ {
496
+ type: "text",
497
+ text: `Routed source_type "${source_type}" → folder ${folder_id}. Future writes of that type will file there automatically.`,
498
+ },
499
+ ],
500
+ };
501
+ }
502
+ case "clear": {
503
+ if (!source_type)
504
+ throw new Error("'source_type' is required");
505
+ await client.clearFolderRoute(source_type);
506
+ return {
507
+ content: [
508
+ {
509
+ type: "text",
510
+ text: `Cleared route for "${source_type}". Future writes of that type land at the top level.`,
511
+ },
512
+ ],
513
+ };
514
+ }
515
+ case "apply_recommended": {
516
+ const res = await client.applyRecommendedFolders();
517
+ const lines = [];
518
+ if (res.created.length)
519
+ lines.push(`Created: ${res.created.join(", ")}`);
520
+ if (res.reused.length)
521
+ lines.push(`Reused: ${res.reused.join(", ")}`);
522
+ if (res.hint_updated.length)
523
+ lines.push(`Hints filled: ${res.hint_updated.join(", ")}`);
524
+ lines.push("");
525
+ lines.push(`${res.routes_set.length} routes set:`);
526
+ for (const r of res.routes_set) {
527
+ lines.push(` • ${r.source_type} → ${r.folder_name}`);
528
+ }
529
+ return { content: [{ type: "text", text: lines.join("\n") }] };
530
+ }
531
+ default:
532
+ throw new Error(`Unknown action: ${action}`);
533
+ }
534
+ }
535
+ catch (err) {
536
+ return {
537
+ content: [
538
+ { type: "text", text: `Error managing folder routes: ${err}` },
539
+ ],
540
+ isError: true,
541
+ };
542
+ }
543
+ });
544
+ // ─── mind_folder_suggest ─────────────────────────────────
545
+ // LLM-driven content-aware folder picker. Reads every folder's
546
+ // routing_hint and chooses the best match (or null when nothing fits).
547
+ server.tool("mind_folder_suggest", "Ask MIND which folder a piece of content belongs in. Reads every folder's routing_hint (set via mind_folders set_hint) and uses a cheap LLM to pick the best match. Returns folder_id=null when no folder's hint clearly applies — in that case leave the doc unfiled rather than guess. Typical agent flow: suggest → mind_remember (create the doc) → mind_folders move_documents (file it to the suggested folder).", {
548
+ content: zod_1.z
549
+ .string()
550
+ .describe("The text of the new document you're about to file. The picker reads it against every folder's routing_hint."),
551
+ title: zod_1.z
552
+ .string()
553
+ .optional()
554
+ .describe("Optional title — helps the picker disambiguate short content."),
555
+ }, async ({ content, title }) => {
556
+ try {
557
+ const res = await client.suggestFolder(content, title);
558
+ if (!res.folder_id) {
559
+ return {
560
+ content: [
561
+ {
562
+ type: "text",
563
+ text: `No folder match — ${res.reason}\n\nLeave the doc unfiled or call mind_folder_routes apply_recommended to set up the default folder layout.`,
564
+ },
565
+ ],
566
+ };
567
+ }
568
+ return {
569
+ content: [
570
+ {
571
+ type: "text",
572
+ text: [
573
+ `Suggested folder: ${res.folder_name} (id: ${res.folder_id})`,
574
+ `Confidence: ${Math.round(res.confidence * 100)}%`,
575
+ `Reason: ${res.reason}`,
576
+ ].join("\n"),
577
+ },
578
+ ],
579
+ };
580
+ }
581
+ catch (err) {
582
+ return {
583
+ content: [
584
+ { type: "text", text: `Error suggesting folder: ${err}` },
585
+ ],
586
+ isError: true,
587
+ };
588
+ }
589
+ });
418
590
  // ─── mind_context ───────────────────────────────────────
419
591
  // Get structured always-loaded context.
420
592
  // Equivalent to OpenClaw's SOUL.md + USER.md + AGENTS.md bootstrap injection,
@@ -453,14 +625,15 @@ function createMindMcpServer(client) {
453
625
  // ─── mind_life ──────────────────────────────────────────
454
626
  // Read/write goals, projects, tasks, calendar events, stats.
455
627
  // Enhanced: calendar CRUD, stats, move, get.
456
- server.tool("mind_life", "Manage Focus → Project → Outcome hierarchy + calendar in MIND Life. Items are either projects (top-level domain/client buckets that live inside a Focus) or outcomes (deliverables that live under a parent project). Use `item_type` + `parent_id` + `focus_id` on create/update to wire the hierarchy. Use list filters (item_type, parent_id, focus_id, top_level_only) to slice the board.", {
628
+ server.tool("mind_life", "Manage Focus → Project → Outcome hierarchy + calendar in MIND Life. Items are either projects (top-level domain/client buckets that live inside a Focus) or outcomes (deliverables that live under a parent project). Use `item_type` + `parent_id` + `focus_id` on create/update to wire the hierarchy. Use list filters (item_type, parent_id, focus_id, top_level_only) to slice the board. Share a project with another MIND account using share/list_shares/revoke_share (requires LIFE_SHARING_ENABLED on the backend; grantee gets the project + its outcomes on their board).", {
457
629
  action: zod_1.z
458
630
  .enum([
459
631
  "list", "create", "update", "complete", "delete", "bulk_delete", "move", "get",
460
632
  "calendar_list", "calendar_create", "calendar_update", "calendar_delete",
461
633
  "stats",
634
+ "share", "list_shares", "revoke_share",
462
635
  ])
463
- .describe("What to do: list/create/update/complete/delete/bulk_delete/move/get items, calendar_list/calendar_create/calendar_update/calendar_delete events, stats (productivity overview)"),
636
+ .describe("What to do: list/create/update/complete/delete/bulk_delete/move/get items, calendar_list/calendar_create/calendar_update/calendar_delete events, stats (productivity overview), share (grant another MIND account access to a project) / list_shares (who a project is shared with) / revoke_share (drop a grant)"),
464
637
  title: zod_1.z.string().optional().describe("Title for new items or calendar events"),
465
638
  description: zod_1.z.string().optional().describe("Description for new items"),
466
639
  status: zod_1.z
@@ -501,7 +674,13 @@ function createMindMcpServer(client) {
501
674
  top_level_only: zod_1.z.boolean().optional().describe("On list — true returns only items with no parent (board roots: projects + unassigned outcomes)."),
502
675
  include_completed: zod_1.z.boolean().optional().describe("On list — false hides completed items. Defaults true."),
503
676
  limit: zod_1.z.number().int().min(1).max(500).optional().describe("On list — max items to return (1–500, default 30)."),
504
- }, async ({ action, title, description, status, priority, due_date, item_id, item_ids, start_time, end_time, event_id, all_day, tags, color, target_date, item_type, parent_id, focus_id, agent_ids, workflow_ids, top_level_only, include_completed, limit }) => {
677
+ grantee_username: zod_1.z.string().optional().describe("Username to grant access to (action=share). Must be an existing MIND account."),
678
+ share_role: zod_1.z
679
+ .enum(["owner", "viewer"])
680
+ .optional()
681
+ .describe("Role for the grant (action=share). 'owner' = full control over the project + its outcomes. 'viewer' = read-only. Default: viewer."),
682
+ share_id: zod_1.z.string().optional().describe("Share-grant id to revoke (action=revoke_share). Get it from action=list_shares."),
683
+ }, async ({ action, title, description, status, priority, due_date, item_id, item_ids, start_time, end_time, event_id, all_day, tags, color, target_date, item_type, parent_id, focus_id, agent_ids, workflow_ids, top_level_only, include_completed, limit, grantee_username, share_role, share_id }) => {
505
684
  try {
506
685
  switch (action) {
507
686
  case "list": {
@@ -801,6 +980,59 @@ function createMindMcpServer(client) {
801
980
  }
802
981
  return { content: [{ type: "text", text: lines.join("\n") }] };
803
982
  }
983
+ case "share": {
984
+ if (!item_id || !grantee_username) {
985
+ return {
986
+ content: [{ type: "text", text: "Error: item_id (project id) and grantee_username are required for share" }],
987
+ isError: true,
988
+ };
989
+ }
990
+ const role = share_role ?? "viewer";
991
+ const grant = await client.addLifeShare(item_id, grantee_username, role);
992
+ const label = grant.grantee_label && grant.grantee_label !== grant.grantee_username
993
+ ? `${grant.grantee_label} (@${grant.grantee_username})`
994
+ : `@${grant.grantee_username}`;
995
+ return {
996
+ content: [
997
+ {
998
+ type: "text",
999
+ text: `✅ Shared project "${grant.project_title ?? grant.project_id}" with ${label} as ${grant.role} (share id: ${grant.id})`,
1000
+ },
1001
+ ],
1002
+ };
1003
+ }
1004
+ case "list_shares": {
1005
+ if (!item_id) {
1006
+ return {
1007
+ content: [{ type: "text", text: "Error: item_id (project id) is required for list_shares" }],
1008
+ isError: true,
1009
+ };
1010
+ }
1011
+ const result = await client.listLifeShares(item_id);
1012
+ const shares = result.shares ?? [];
1013
+ if (shares.length === 0) {
1014
+ return { content: [{ type: "text", text: "No shares on this project yet." }] };
1015
+ }
1016
+ const lines = shares.map((s) => {
1017
+ const label = s.grantee_label && s.grantee_label !== s.grantee_username
1018
+ ? `${s.grantee_label} (@${s.grantee_username})`
1019
+ : `@${s.grantee_username}`;
1020
+ return `• ${label} — ${s.role}${s.granted_by ? ` (granted by @${s.granted_by})` : ""} — id: ${s.id}`;
1021
+ });
1022
+ return { content: [{ type: "text", text: lines.join("\n") }] };
1023
+ }
1024
+ case "revoke_share": {
1025
+ if (!item_id || !share_id) {
1026
+ return {
1027
+ content: [{ type: "text", text: "Error: item_id (project id) and share_id are required for revoke_share. Get the share_id from action=list_shares." }],
1028
+ isError: true,
1029
+ };
1030
+ }
1031
+ await client.revokeLifeShare(item_id, share_id);
1032
+ return {
1033
+ content: [{ type: "text", text: `✅ Revoked share ${share_id} on project ${item_id}` }],
1034
+ };
1035
+ }
804
1036
  }
805
1037
  }
806
1038
  catch (err) {