Skip to main content
Glama

add_observations

Add new observations to existing entities in a knowledge graph to enhance semantic search and code indexing capabilities.

Instructions

Add new observations to existing entities in the knowledge graph

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
observationsYes

Implementation Reference

  • Main handler for the 'add_observations' tool. Validates input parameters, invokes the knowledge graph manager to add observations, formats the result in MCP content format, and handles errors.
    export const addObservationsHandler = async (args) => { if (!args.observations || !Array.isArray(args.observations)) { throw new Error("The 'observations' parameter is required and must be an array"); } // Valider chaque observation for (const observation of args.observations) { if (!observation.entityName || typeof observation.entityName !== 'string') { throw new Error("Each observation must have an 'entityName' string property"); } if (!observation.contents || !Array.isArray(observation.contents)) { throw new Error("Each observation must have a 'contents' array property"); } } try { const result = await knowledgeGraphManager.addObservations(args.observations); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] }; } catch (error) { console.error("Error in add_observations tool:", error); throw error; } };
  • Tool definition including name, description, and input schema for validating 'add_observations' tool calls.
    export const addObservationsTool = { name: "add_observations", description: "Add new observations to existing entities in the knowledge graph", inputSchema: { type: "object", properties: { observations: { type: "array", items: { type: "object", properties: { entityName: { type: "string", description: "The name of the entity to add the observations to" }, contents: { type: "array", items: { type: "string" }, description: "An array of observation contents to add" }, }, required: ["entityName", "contents"], }, }, }, required: ["observations"], }, };
  • Core helper method in KnowledgeGraphManager that loads the graph from JSONL, adds non-duplicate observations to specified entities, saves the graph, and returns results.
    async addObservations(observations) { const graph = await this.loadGraph(); const results = observations.map(o => { const entity = graph.entities.find(e => e.name === o.entityName); if (!entity) { throw new Error(`Entity with name ${o.entityName} not found`); } const newObservations = o.contents.filter(content => !entity.observations.includes(content)); entity.observations.push(...newObservations); return { entityName: o.entityName, addedObservations: newObservations }; }); await this.saveGraph(graph); return results; }
  • Dynamic registration of tools (including 'add_observations') via AutoRegistry scanning tool directories and calling toolRegistry.register(tool, handler) for matching Tool/Handler exports.
    toolRegistry.register(tool, handler); this.registeredTools.add(tool.name); registeredCount++; if (this.config.verbose) { console.log(`✅ Outil enregistré automatiquement: ${tool.name} (${path})`); } } catch (error) {

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/ali-48/rag-mcp-server'

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