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:

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/sarathsp06/sourcesage'

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