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); }

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