Skip to main content
Glama
j3k0

Elasticsearch Knowledge Graph for MCP

by j3k0

get_recent

Retrieve recently accessed entities and their relations from the Elasticsearch Knowledge Graph for MCP, with options to limit results and include detailed observations, supporting efficient memory-based queries.

Instructions

Get recently accessed entities from knowledge graph (memory) and their relations

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
includeObservationsNoWhether to include full entity observations in results (default: false)
limitNoMax results (default: 20 if includeObservations is false, 5 if true)
memory_zoneYesOptional memory zone to get recent entities from. If not specified, uses the default zone.

Implementation Reference

  • src/index.ts:447-471 (registration)
    Registration of the get_recent tool in the listTools response, including name, description, and input schema.
    {
      name: "get_recent",
      description: "Get recently accessed entities from knowledge graph (memory) and their relations",
      inputSchema: {
        type: "object",
        properties: {
          limit: {
            type: "integer",
            description: "Max results (default: 20 if includeObservations is false, 5 if true)"
          },
          includeObservations: {
            type: "boolean",
            description: "Whether to include full entity observations in results (default: false)",
            default: false
          },
          memory_zone: {
            type: "string",
            description: "Optional memory zone to get recent entities from. If not specified, uses the default zone."
          }
        },
        required: ["memory_zone"],
        additionalProperties: false,
        "$schema": "http://json-schema.org/draft-07/schema#"
      }
    },
  • Handler for executing the get_recent tool call, parses arguments, invokes kgClient.getRecentEntities, and formats response.
    else if (toolName === "get_recent") {
      const limit = params.limit || 20;
      const includeObservations = params.includeObservations ?? false;
      const zone = params.memory_zone;
      
      const recentEntities = await kgClient.getRecentEntities(limit, includeObservations, zone);
      
      return formatResponse({
        entities: recentEntities.map(e => ({
          name: e.name,
          entityType: e.entityType,
          observations: e.observations
        })),
        total: recentEntities.length
      });
    }
  • Helper method getRecentEntities in KnowledgeGraphClient that implements the core logic by searching all entities sorted by lastRead timestamp (recency).
    async getRecentEntities(limit: number, includeObservations: boolean, zone?: string): Promise<ESEntity[]> {
      const actualZone = zone || this.defaultZone;
      
      // Search with empty query but sort by recency
      const searchParams: ESSearchParams = {
        query: "*", // Use wildcard instead of empty query to match all documents
        limit: limit,
        sortBy: 'recent', // Sort by recency
        includeObservations
      };
      
      // Add zone if specified
      if (actualZone) {
        (searchParams as any).zone = actualZone;
      }
      
      const results = await this.search(searchParams);
      
      // Filter to only include entities
      return results.hits.hits
        .filter((hit: any) => hit._source.type === 'entity')
        .map((hit: any) => hit._source);
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions retrieving 'recently accessed entities' but doesn't specify what 'recent' means (e.g., time window, access count), whether results are sorted, or if there are rate limits or permissions required. This leaves significant gaps for a tool that interacts with a knowledge graph.

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

Conciseness5/5

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

The description is a single, efficient sentence that front-loads the core purpose without unnecessary words. It directly communicates the tool's function, making it easy to parse and understand quickly.

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

Completeness3/5

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

Given the tool's moderate complexity (3 parameters, no output schema, no annotations), the description is minimal but covers the basic purpose. However, it lacks details on behavioral aspects like recency definition, sorting, or error handling, which are important for a knowledge graph query tool. The absence of an output schema increases the need for more context, but the description doesn't compensate adequately.

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?

Schema description coverage is 100%, so the schema fully documents the three parameters (includeObservations, limit, memory_zone) with clear descriptions. The description adds no additional parameter semantics beyond what's in the schema, resulting in a baseline score of 3.

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

Purpose4/5

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

The description clearly states the verb 'Get' and the resource 'recently accessed entities from knowledge graph (memory) and their relations', which is specific and actionable. However, it doesn't explicitly distinguish this tool from sibling tools like 'search_nodes' or 'inspect_knowledge_graph', which might also retrieve graph data, so it falls short of a perfect score.

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. For example, it doesn't explain how 'get_recent' differs from 'search_nodes' or 'inspect_knowledge_graph' in terms of recency filtering or scope, leaving the agent to infer usage from the name alone.

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/j3k0/mcp-brain-tools'

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