Skip to main content
Glama

add_entity_observation

Enhance entity records by appending observations in SourceSage MCP server. Input entity name and observation to dynamically update and store contextual data for efficient retrieval and analysis.

Instructions

Add an observation to an entity.

Args: entity_name: Name of the entity observation: Observation to add

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
entity_nameYes
observationYes

Implementation Reference

  • The handler function decorated with @self.mcp.tool(), which registers and implements the add_entity_observation tool. It locates the entity by name and delegates to KnowledgeGraph.add_observation.
    def add_entity_observation(entity_name: str, observation: str) -> str:
        """Add an observation to an entity.
    
        Args:
            entity_name: Name of the entity
            observation: Observation to add
        """
        # Find entity by name
        entities = self.knowledge.find_entity(entity_name)
    
        if not entities:
            return f"Error: Entity '{entity_name}' not found"
    
        # If multiple entities with the same name, use the first one
        entity_id = entities[0].entity_id
    
        success = self.knowledge.add_observation(entity_id, observation)
    
        if not success:
            return f"Error: Failed to add observation to entity '{entity_name}'"
    
        # Save knowledge if storage path is set
        if self.storage_path:
            self.knowledge.save_to_file(self.storage_path)
    
        return f"Observation added to entity '{entity_name}'"
  • Supporting method in KnowledgeGraph class that adds a unique observation to an entity's observations list and updates the timestamp.
    def add_observation(self, entity_id: str, observation: str) -> bool:
        """Add an observation to an entity.
    
        Args:
            entity_id: The ID of the entity
            observation: The observation to add
    
        Returns:
            True if successful, False otherwise
        """
        if entity_id not in self.entities:
            return False
    
        entity = self.entities[entity_id]
    
        if observation not in entity.observations:
            entity.observations.append(observation)
            entity.updated_at = time.time()
    
        return True
  • The function signature defines the input schema (entity_name: str, observation: str) and output (str) for the tool, used by MCP for validation.
    """Add an observation to an entity.
  • The @self.mcp.tool() decorator registers the add_entity_observation function as an MCP tool.
    def add_entity_observation(entity_name: str, observation: str) -> str:

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.0

TDQS

C2.9/5.0
Behavior2/5

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

No annotations and minimal description. Does not disclose whether observations are appended, overwritten, or require entity existence. Lacks behavioral details.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Very brief, but lacks depth. Concise but under-specified for a mutation tool.

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?

No output schema and no mention of return values or side effects. Incomplete for understanding the tool's full behavior.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 0%, and description only restates parameter names and types from the schema without adding meaning (e.g., format or constraints).

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb 'add' and the resource 'observation to an entity', distinguishing it from siblings like register_entity or get_entity_details.

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?

No guidance on when to use this tool vs alternatives. No mention of prerequisites (e.g., entity must exist) or exclusions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Deploy Server

Other Tools

Related Tools