File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -465,6 +465,30 @@ server.registerTool(
465465 }
466466) ;
467467
468+ // Expose the knowledge graph as a readable MCP Resource.
469+ // This demonstrates the Resources protocol feature, enabling clients
470+ // to discover and read the graph without calling a tool.
471+ server . registerResource (
472+ "knowledge_graph" ,
473+ "memory://knowledge-graph" ,
474+ {
475+ description : "The full knowledge graph with all entities and relations" ,
476+ mimeType : "application/json" ,
477+ } ,
478+ async ( uri ) => {
479+ const graph = await knowledgeGraphManager . readGraph ( ) ;
480+ return {
481+ contents : [
482+ {
483+ uri : uri . href ,
484+ mimeType : "application/json" ,
485+ text : JSON . stringify ( graph , null , 2 ) ,
486+ } ,
487+ ] ,
488+ } ;
489+ }
490+ ) ;
491+
468492async function main ( ) {
469493 // Initialize memory file path with backward compatibility
470494 MEMORY_FILE_PATH = await ensureMemoryFilePath ( ) ;
You can’t perform that action at this time.
0 commit comments