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) {
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 states the tool adds observations to existing entities, implying a mutation operation, but lacks details on permissions, side effects (e.g., if duplicates are allowed), error handling, or response format. This is inadequate for a mutation tool with zero annotation coverage.

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 directly states the tool's purpose without unnecessary words. It's front-loaded and appropriately sized, making it easy to parse quickly.

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 tool's complexity (a mutation operation with nested parameters), lack of annotations, and no output schema, the description is incomplete. It fails to address critical aspects like behavioral traits, error conditions, or return values, making it insufficient for safe and effective use by an AI agent.

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 0%, but the description mentions 'observations' and 'existing entities,' which aligns with the input schema's 'observations' array containing 'entityName' and 'contents.' However, it doesn't add meaningful semantics beyond this basic mapping, such as format constraints or examples, leaving parameters partially documented.

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 action ('Add new observations') and target ('to existing entities in the knowledge graph'), which is specific and unambiguous. However, it doesn't explicitly differentiate from sibling tools like 'create_entities' or 'delete_observations' beyond the implied distinction between adding to existing entities versus creating new ones.

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. It doesn't mention prerequisites (e.g., entities must exist), exclusions, or comparisons to siblings like 'create_entities' for new entities or 'delete_observations' for removal, leaving usage context unclear.

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

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