Skip to content

Commit cb66bcc

Browse files
committed
feat(memory): expose knowledge graph as MCP Resource
1 parent ccf6751 commit cb66bcc

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

src/memory/index.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff 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+
468492
async function main() {
469493
// Initialize memory file path with backward compatibility
470494
MEMORY_FILE_PATH = await ensureMemoryFilePath();

0 commit comments

Comments
 (0)