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

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

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;
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden for behavioral disclosure. It mentions 'recent' but doesn't clarify how recency is determined (e.g., time-based, count-based). It also doesn't describe what 'entities and their relations' includes (e.g., format, structure, pagination) or any limitations (e.g., rate limits, authentication needs). The description is too minimal for a tool with potential complexity.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with no wasted words. It's front-loaded with the core action ('Get recent entities and their relations'). However, it could be more structured by explicitly separating purpose from constraints, but given its brevity, it's appropriately concise.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the lack of annotations and output schema, the description is incomplete for a tool that reads graph data. It doesn't explain what 'recent' entails, the format of returned entities/relations, or any behavioral aspects like error handling. For a tool with potential complexity in graph operations, this minimal description leaves significant gaps.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 1 parameter with 100% description coverage, so the schema fully documents 'includeEmbeddings'. The description adds no parameter information beyond what the schema provides. Since schema coverage is high, the baseline score is 3, as the description doesn't need to compensate but also adds no extra value.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states the tool 'Get recent entities and their relations', which provides a basic verb+resource combination. However, it's vague about what 'recent' means (timeframe, recency criteria) and doesn't distinguish this tool from sibling tools like 'search_nodes' or 'create_entities' that also involve entities. The purpose is understandable but lacks specificity.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. With siblings like 'search_nodes' (which might filter entities) and 'create_entities' (which creates rather than reads), there's no indication of when 'read_graph' is appropriate versus these other tools. No exclusions, prerequisites, or alternative suggestions are mentioned.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

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