read_graph
Extract recent entities and their relationships from a high-performance MCP server using libSQL for memory persistence and vector search. Enhance entity management and semantic knowledge retrieval.
Instructions
Get recent entities and their relations
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:150-182 (handler)The handler function for the 'read_graph' MCP tool. It calls the database's read_graph method, serializes the result to JSON text content, and handles errors by returning an error response.async () => { try { const result = await db.read_graph(); return { content: [ { type: 'text' as const, text: JSON.stringify(result, null, 2), }, ], }; } catch (error) { return { content: [ { type: 'text' as const, text: JSON.stringify( { error: 'internal_error', message: error instanceof Error ? error.message : 'Unknown error', }, null, 2, ), }, ], isError: true, }; } },
- src/index.ts:145-149 (registration)Registration of the 'read_graph' tool with the MCP server via server.tool(). Specifies the tool name and description. No input schema is provided as the tool takes no parameters.server.tool( { name: 'read_graph', description: 'Get recent entities and their relations', },
- src/db/client.ts:356-365 (helper)Helper method in DatabaseManager class that fetches recent entities using get_recent_entities() and their relations using get_relations_for_entities(), returning the graph data structure.async read_graph(): Promise<{ entities: Entity[]; relations: Relation[]; }> { const recent_entities = await this.get_recent_entities(); const relations = await this.get_relations_for_entities( recent_entities, ); return { entities: recent_entities, relations }; }