Skip to main content
Glama

read_graph

Retrieve recent entities and their relationships stored in MCP Memory LibSQL, with optional embeddings for advanced analysis and vector search.

Instructions

Get recent entities and their relations

Input Schema

NameRequiredDescriptionDefault
includeEmbeddingsNoWhether to include embeddings in the returned entities (default: false)

Input Schema (JSON Schema)

{ "properties": { "includeEmbeddings": { "description": "Whether to include embeddings in the returned entities (default: false)", "type": "boolean" } }, "required": [], "type": "object" }

Implementation Reference

  • Core handler function that implements the logic to read recent entities and their relations from the database to form a graph.
    public static async readGraph( limit = 10, includeEmbeddings = false, ): Promise<GraphResult> { try { // Get recent entities const recentEntities = await getRecentEntities(limit, includeEmbeddings); // If no entities found, return empty graph if (!recentEntities || recentEntities.length === 0) { return { entities: [], relations: [], }; } // Get entity names const entityNames = recentEntities.map((entity: Entity) => entity.name); // Get relations for these entities const relations = await getRelationsForEntities(entityNames); // Return graph result return { entities: recentEntities, relations, }; } catch (error) { throw new DatabaseError( `Failed to read graph: ${error instanceof Error ? error.message : String(error)}` ); } }
  • MCP server tool handler for 'read_graph' that parses input, calls the readGraph service function, and formats the response.
    case 'read_graph': { // Safely access properties with type assertions const includeEmbeddings = args.includeEmbeddings as boolean || false; // Use a fixed limit of 10 for the number of entities to return const result = await readGraph(10, includeEmbeddings); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2), }, ], }; }
  • src/index.ts:171-183 (registration)
    Registration of the 'read_graph' tool in the MCP server's listTools response, including name, description, and input schema.
    name: 'read_graph', description: 'Get recent entities and their relations', inputSchema: { type: 'object', properties: { includeEmbeddings: { type: 'boolean', description: 'Whether to include embeddings in the returned entities (default: false)', }, }, required: [], }, },
  • TypeScript interface defining the input schema for the read_graph tool.
    interface ReadGraphInput { includeEmbeddings?: boolean; }

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/joleyline/mcp-memory-libsql'

If you have feedback or need assistance with the MCP directory API, please join our Discord server