Skip to main content
Glama

register_relationship

Define and store relationships between code entities, such as calls, inherits, or imports, to maintain structured connections and metadata within a codebase.

Instructions

Register a relationship between entities.

Args: from_entity: Name of the source entity to_entity: Name of the target entity relationship_type: Type of relationship (calls, inherits, imports, etc.) metadata: Additional metadata as key-value pairs

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
from_entityYes
metadataNo
relationship_typeYes
to_entityYes

Implementation Reference

  • The handler function for the 'register_relationship' tool. It finds entities by name, creates a relation between them using KnowledgeGraph.add_relation, saves the knowledge graph if storage is configured, and returns the relation ID or error message.
    def register_relationship(
        from_entity: str,
        to_entity: str,
        relationship_type: str,
        metadata: dict[str, Any] | None = None,
    ) -> str:
        """Register a relationship between entities.
    
        Args:
            from_entity: Name of the source entity
            to_entity: Name of the target entity
            relationship_type: Type of relationship (calls, inherits, imports, etc.)
            metadata: Additional metadata as key-value pairs
        """
        # Find entities by name
        from_entities = self.knowledge.find_entity(from_entity)
        to_entities = self.knowledge.find_entity(to_entity)
    
        if not from_entities:
            return f"Error: Source entity '{from_entity}' not found"
    
        if not to_entities:
            return f"Error: Target entity '{to_entity}' not found"
    
        # If multiple entities with the same name, use the first one
        from_id = from_entities[0].entity_id
        to_id = to_entities[0].entity_id
    
        relation_id = self.knowledge.add_relation(
            from_id=from_id,
            to_id=to_id,
            relation_type=relationship_type,
            metadata=metadata,
        )
    
        if not relation_id:
            return "Error: Failed to create relationship"
    
        # Save knowledge if storage path is set
        if self.storage_path:
            self.knowledge.save_to_file(self.storage_path)
    
        return f"Relationship registered with ID: {relation_id}"
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. 'Register' implies a write/mutation operation, but the description doesn't disclose whether this requires specific permissions, whether relationships are reversible, what happens on duplicate registration, or what the response looks like. For a mutation tool with zero annotation coverage, this is a significant gap.

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

Conciseness4/5

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

The description is appropriately sized with a clear purpose statement followed by parameter documentation. The two-sentence structure is efficient, though the 'Args:' section formatting is slightly verbose. Every sentence serves a purpose without unnecessary elaboration.

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?

For a mutation tool with 4 parameters, 0% schema description coverage, no annotations, and no output schema, the description is inadequate. It doesn't explain what happens after registration, whether there are validation rules, what metadata can contain, or how this tool relates to sibling entity operations. The context signals indicate high complexity that isn't addressed.

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?

With 0% schema description coverage, the description provides basic parameter documentation in the Args section, listing all 4 parameters with brief explanations. However, it doesn't fully compensate for the coverage gap - it lacks details about parameter formats, constraints, or the meaning of 'calls, inherits, imports, etc.' for relationship_type. The description adds value but doesn't provide complete parameter semantics.

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 ('register') and resource ('relationship between entities'), providing a specific verb+resource combination. However, it doesn't differentiate this tool from its siblings like 'register_entity', 'register_pattern', or 'register_style_convention' - all of which appear to be registration operations for different resource types.

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. With siblings like 'register_entity', 'query_entities', and 'get_entity_details', there's clear need for usage context about when relationship registration is appropriate versus entity registration or querying, but none is provided.

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

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