From cb66bccc6f9f408797ae715b5cc11a474a402112 Mon Sep 17 00:00:00 2001 From: Lazreg Raed Date: Wed, 11 Feb 2026 21:57:46 +0100 Subject: [PATCH] feat(memory): expose knowledge graph as MCP Resource --- src/memory/index.ts | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/memory/index.ts b/src/memory/index.ts index 600a7edcc8..a04ea8252b 100644 --- a/src/memory/index.ts +++ b/src/memory/index.ts @@ -465,6 +465,30 @@ server.registerTool( } ); +// Expose the knowledge graph as a readable MCP Resource. +// This demonstrates the Resources protocol feature, enabling clients +// to discover and read the graph without calling a tool. +server.registerResource( + "knowledge_graph", + "memory://knowledge-graph", + { + description: "The full knowledge graph with all entities and relations", + mimeType: "application/json", + }, + async (uri) => { + const graph = await knowledgeGraphManager.readGraph(); + return { + contents: [ + { + uri: uri.href, + mimeType: "application/json", + text: JSON.stringify(graph, null, 2), + }, + ], + }; + } +); + async function main() { // Initialize memory file path with backward compatibility MEMORY_FILE_PATH = await ensureMemoryFilePath();