Skip to main content
Glama
j3k0

Elasticsearch Knowledge Graph for MCP

by j3k0

add_observations

Update entities by adding observations to their data in the Elasticsearch Knowledge Graph, enhancing the memory-like storage and retrieval for AI models.

Instructions

Add observations to an existing entity in knowledge graph (memory)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
memory_zoneYesOptional memory zone where the entity is stored. If not specified, uses the default zone.
nameYesName of entity to add observations to
observationsYesObservations to add to the entity

Implementation Reference

  • Input schema definition for the add_observations tool, defining parameters: name (string), observations (array of strings), memory_zone (string, required).
    { name: "add_observations", description: "Add observations to an existing entity in knowledge graph (memory)", inputSchema: { type: "object", properties: { name: { type: "string", description: "Name of entity to add observations to" }, observations: { type: "array", items: {type: "string"}, description: "Observations to add to the entity" }, memory_zone: { type: "string", description: "Optional memory zone where the entity is stored. If not specified, uses the default zone." } }, required: ["memory_zone", "name", "observations"], additionalProperties: false, "$schema": "http://json-schema.org/draft-07/schema#" } },
  • MCP server tool handler for 'add_observations': validates entity exists, calls kgClient.addObservations, returns formatted success/error response.
    else if (toolName === "add_observations") { const name = params.name; const observations = params.observations; const zone = params.memory_zone; // Get existing entity const entity = await kgClient.getEntity(name, zone); if (!entity) { const zoneMsg = zone ? ` in zone "${zone}"` : ""; return formatResponse({ success: false, error: `Entity "${name}" not found${zoneMsg}`, message: "Please create the entity before adding observations." }); } // Add observations to the entity const updatedEntity = await kgClient.addObservations(name, observations, zone); return formatResponse({ success: true, entity: updatedEntity }); }
  • Core implementation: fetches existing entity using getEntity, appends new observations, saves updated entity via saveEntity, returns the updated ESEntity.
    async addObservations(name: string, observations: string[], zone?: string): Promise<ESEntity> { const actualZone = zone || this.defaultZone; // Get existing entity const entity = await this.getEntity(name, actualZone); if (!entity) { throw new Error(`Entity "${name}" not found in zone "${actualZone}"`); } // Add new observations to the existing ones const updatedObservations = [ ...entity.observations, ...observations ]; // Update the entity const updatedEntity = await this.saveEntity({ name: entity.name, entityType: entity.entityType, observations: updatedObservations, relevanceScore: entity.relevanceScore }, actualZone); return updatedEntity; }

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