Skip to main content
Glama

add_observations

Enhance knowledge graph entities by adding new observations to their data, enabling structured updates for improved reasoning and analysis in the MCP Think Tank server.

Instructions

Add new observations to existing entities in the knowledge graph

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
observationsYesArray of entity observations to add

Implementation Reference

  • The execute handler for the 'add_observations' tool. Loops through provided observations, calls memoryStore.add for each, collects results, saves changes, and returns JSON summary.
    execute: async (args) => {
      const results = {
        updated: [] as Array<{entityName: string, added: string[]}>,
        failed: [] as Array<{entityName: string, reason: string}>
      };
    
      for (const item of args.observations) {
        try {
          const added: string[] = [];
          for (const content of item.contents) {
            await memoryStore.add(item.entityName, content, {
              version: '1.0'
            });
            added.push(content);
          }
          
          if (added.length > 0) {
            results.updated.push({
              entityName: item.entityName,
              added
            });
          }
        } catch (error) {
          results.failed.push({
            entityName: item.entityName,
            reason: `Failed to add observations: ${error}`
          });
        }
      }
    
      // Save changes
      await memoryStore.save();
    
      // Return as string
      return JSON.stringify({
        updated: results.updated.length > 0 ? results.updated : null,
        failed: results.failed.length > 0 ? results.failed : null,
        message: `Added observations to ${results.updated.length} entities. Failed for ${results.failed.length} entities.`
      });
    }
  • Registration of the 'add_observations' MCP tool on the FastMCP server, specifying name, description, and schema.
    server.addTool({
      name: 'add_observations',
      description: 'Add new observations to existing entities in the knowledge graph',
      parameters: Schemas.AddObservationsSchema,
  • Zod schema definition for validating inputs to the add_observations tool.
    export const AddObservationsSchema = z.object({
      observations: z.array(z.object({
        entityName: z.string().min(1).describe('Name of the entity to add observations to'),
        contents: z.array(z.string()).describe('Observations to add to the entity')
      })).describe('Array of entity observations to add')
    });
  • Low-level helper method in JsonlMemoryStore that actually adds an observation to an entity, updates the graph, handles auto-linking, and persists to JSONL file. Called by the tool handler.
    async add(entityName: string, text: string, metadata?: {
      version?: string;
      tags?: string[];
      agent?: string;
    }): Promise<Observation> {
      await this.getLoadingPromise();
    
      // Create observation with timestamp
      const observation: Observation = {
        text,
        timestamp: new Date().toISOString(),
        version: metadata?.version
      };
    
      // Get entity or create if it doesn't exist
      let entity = this.enhancedEntities.get(entityName);
      let isNewEntity = false;
      if (!entity) {
        entity = {
          name: entityName,
          entityType: 'default', // Default type if entity doesn't exist
          observations: []
        };
        this.enhancedEntities.set(entityName, entity);
        isNewEntity = true;
    
        // Also add to the graph for backward compatibility
        this.graph.addEntity({
          name: entityName,
          entityType: 'default',
          observations: []
        });
      }
    
      // Add observation to entity
      entity.observations.push(observation);
    
      // Update graph for backward compatibility
      this.graph.addObservations(entityName, [text]);
    
      // If this is a new entity and auto-linking is enabled, create relationships
      if (isNewEntity && this.autoLinkEnabled) {
        await this.createAutoLinks(entityName, text);
      }
    
      // Save changes
      await this.save();
    
      return observation;
    }
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It states the tool adds observations to existing entities, implying a mutation operation, but doesn't cover critical aspects like permissions needed, whether changes are reversible, rate limits, error handling (e.g., if entities don't exist), or what the response looks like (since no output schema exists). This leaves significant gaps for a mutation tool.

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. Every element ('Add new observations', 'to existing entities', 'in the knowledge graph') contributes directly to understanding the tool's function.

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 is a mutation operation (adding data) with no annotations and no output schema, the description is insufficient. It lacks details on behavioral traits (e.g., idempotency, side effects), error conditions, or response format, which are critical for an AI agent to use it correctly in a knowledge graph context with many sibling tools.

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 single parameter 'observations' and its nested structure (entityName, contents). The description adds no parameter-specific details beyond implying the tool works on existing entities, which is already suggested by the schema's entityName field. This meets the baseline for high schema coverage.

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'), providing a specific verb+resource combination. It distinguishes from obvious siblings like 'delete_observations' and 'upsert_entities', though it doesn't explicitly contrast with all potential alternatives like 'update_relations' which might also modify graph content.

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 (e.g., cannot create new entities), or direct comparisons to siblings like 'upsert_entities' (which might handle entity creation) or 'update_relations' (which modifies different graph elements).

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/flight505/mcp-think-tank'

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