toon-memory 3.1.0 → 3.3.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/src/mcp/tools.ts CHANGED
@@ -1,4 +1,5 @@
1
- import type { McpServer } from "@modelcontextprotocol/server"
1
+ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"
2
+ import { registerAppTool } from "@modelcontextprotocol/ext-apps/server"
2
3
  import { z } from "zod"
3
4
  import { readFileSync, writeFileSync, existsSync, copyFileSync, mkdirSync, readdirSync } from "fs"
4
5
  import { join, basename } from "path"
@@ -1550,6 +1551,35 @@ server.registerTool(
1550
1551
  }
1551
1552
  )
1552
1553
 
1554
+ // ── memory_visualize (MCP Apps) ──────────────────────────────────────────────
1555
+
1556
+ registerAppTool(
1557
+ server as unknown as Parameters<typeof registerAppTool>[0],
1558
+ "memory_visualize",
1559
+ {
1560
+ title: "Open Memory Graph Viewer",
1561
+ description: "Open the interactive memory graph viewer (force-directed graph, stats, timeline, detail panel). Renders inline in MCP Apps-compatible hosts.",
1562
+ inputSchema: {
1563
+ query: z.string().optional().default("").describe("Optional search query to highlight entries in the viewer"),
1564
+ },
1565
+ _meta: { ui: { resourceUri: "ui://viewer" } },
1566
+ },
1567
+ async ({ query }) => {
1568
+ const data = readMemory()
1569
+ const entries = parseEntries(data)
1570
+ const total = entries.length
1571
+ const graph = buildGraph(entries)
1572
+ const edgeCount = [...graph.adjacency.values()].reduce((sum, n) => sum + n.length, 0) / 2
1573
+
1574
+ let msg = `🧠 Memory Graph Viewer — ${total} entries, ${edgeCount} edges`
1575
+ if (query) msg += `\n🔍 Focus: "${query}"`
1576
+
1577
+ return {
1578
+ content: [{ type: "text" as const, text: msg }],
1579
+ }
1580
+ }
1581
+ )
1582
+
1553
1583
  } // end registerTools
1554
1584
 
1555
1585
  /** Parse relative time string to milliseconds. */