@abraca/mcp 1.0.2 → 1.0.5

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.
@@ -18783,7 +18783,10 @@ function childrenOf$1(entries, parentId) {
18783
18783
  }
18784
18784
  function descendantsOf(entries, id) {
18785
18785
  const result = [];
18786
+ const visited = /* @__PURE__ */ new Set();
18786
18787
  function collect(pid) {
18788
+ if (visited.has(pid)) return;
18789
+ visited.add(pid);
18787
18790
  for (const child of childrenOf$1(entries, pid)) {
18788
18791
  result.push(child);
18789
18792
  collect(child.id);
@@ -18792,18 +18795,39 @@ function descendantsOf(entries, id) {
18792
18795
  collect(id);
18793
18796
  return result;
18794
18797
  }
18795
- function buildTree$1(entries, rootId, maxDepth, currentDepth = 0) {
18798
+ function buildTree$1(entries, rootId, maxDepth, currentDepth = 0, visited = /* @__PURE__ */ new Set()) {
18796
18799
  if (maxDepth >= 0 && currentDepth >= maxDepth) return [];
18797
- return childrenOf$1(entries, rootId).map((entry) => ({
18798
- id: entry.id,
18799
- label: entry.label,
18800
- type: entry.type,
18801
- meta: entry.meta,
18802
- order: entry.order,
18803
- children: buildTree$1(entries, entry.id, maxDepth, currentDepth + 1)
18804
- }));
18800
+ return childrenOf$1(entries, rootId).filter((e) => !visited.has(e.id)).map((entry) => {
18801
+ const next = new Set(visited);
18802
+ next.add(entry.id);
18803
+ return {
18804
+ id: entry.id,
18805
+ label: entry.label,
18806
+ type: entry.type,
18807
+ meta: entry.meta,
18808
+ order: entry.order,
18809
+ children: buildTree$1(entries, entry.id, maxDepth, currentDepth + 1, next)
18810
+ };
18811
+ });
18805
18812
  }
18806
18813
  function registerTreeTools(mcp, server) {
18814
+ mcp.tool("_debug_list_all", "List ALL tree entries with their raw parentId. For debugging circular references.", {}, async () => {
18815
+ const treeMap = server.getTreeMap();
18816
+ if (!treeMap) return { content: [{
18817
+ type: "text",
18818
+ text: "Not connected"
18819
+ }] };
18820
+ const entries = readEntries$1(treeMap);
18821
+ return { content: [{
18822
+ type: "text",
18823
+ text: JSON.stringify(entries.map((e) => ({
18824
+ id: e.id,
18825
+ label: e.label,
18826
+ parentId: e.parentId,
18827
+ type: e.type
18828
+ })), null, 2)
18829
+ }] };
18830
+ });
18807
18831
  mcp.tool("list_documents", "List direct children of a document (defaults to root). Returns id, label, type, meta, order.", { parentId: zod.z.string().optional().describe("Parent document ID. Omit for root-level documents.") }, async ({ parentId }) => {
18808
18832
  const treeMap = server.getTreeMap();
18809
18833
  if (!treeMap) return { content: [{
@@ -18837,7 +18861,7 @@ function registerTreeTools(mcp, server) {
18837
18861
  mcp.tool("create_document", "Create a new document in the tree. Returns the new document ID.", {
18838
18862
  parentId: zod.z.string().optional().describe("Parent document ID. Omit for top-level pages. Use a document ID for nested/child pages."),
18839
18863
  label: zod.z.string().describe("Display name / title for the document."),
18840
- type: zod.z.string().optional().describe("Page type: \"doc\", \"kanban\", \"calendar\", \"table\", \"outline\", \"gallery\", \"slides\", \"timeline\", \"whiteboard\", \"map\", \"desktop\", \"mindmap\", \"graph\". Omit to inherit parent view."),
18864
+ type: zod.z.string().optional().describe("Page type: \"doc\", \"kanban\", \"calendar\", \"table\", \"outline\", \"gallery\", \"slides\", \"timeline\", \"whiteboard\", \"map\", \"dashboard\", \"mindmap\", \"graph\". Omit to inherit parent view."),
18841
18865
  meta: zod.z.record(zod.z.unknown()).optional().describe("Initial metadata (PageMeta fields: color as hex string, icon as Lucide kebab-case name like \"star\"/\"code-2\"/\"users\" — never emoji, dateStart, dateEnd, priority 0-4, tags array, etc). Omit icon entirely to use page type default.")
18842
18866
  }, async ({ parentId, label, type, meta }) => {
18843
18867
  const treeMap = server.getTreeMap();
@@ -18951,7 +18975,7 @@ function registerTreeTools(mcp, server) {
18951
18975
  });
18952
18976
  mcp.tool("change_document_type", "Change the page type view of a document (data is preserved).", {
18953
18977
  id: zod.z.string().describe("Document ID."),
18954
- type: zod.z.string().describe("New page type (e.g. \"doc\", \"kanban\", \"table\", \"calendar\", \"outline\", \"gallery\", \"slides\", \"timeline\", \"whiteboard\", \"map\", \"desktop\", \"mindmap\", \"graph\").")
18978
+ type: zod.z.string().describe("New page type (e.g. \"doc\", \"kanban\", \"table\", \"calendar\", \"outline\", \"gallery\", \"slides\", \"timeline\", \"whiteboard\", \"map\", \"dashboard\", \"mindmap\", \"graph\").")
18955
18979
  }, async ({ id, type }) => {
18956
18980
  const treeMap = server.getTreeMap();
18957
18981
  if (!treeMap) return { content: [{