Skip to main content
Glama
AgentWong

Knowledge Graph Memory Server

by AgentWong

Create Relations

create_relations

Adds multiple new connections between entities in a knowledge graph to establish relationships using active voice descriptions.

Instructions

Create multiple new relations between entities in the knowledge graph. Relations should be in active voice

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
relationsYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
relationsYes

Implementation Reference

  • The actual implementation of the create_relations logic that performs batch insertion into the SQLite database.
    async def create_relations(
        self, 
        relations: List[Dict[str, Any]], 
        batch_size: int = 1000
    ) -> List[Dict[str, Any]]:
        """Create multiple new relations in batches."""
        created_relations = []
        
        async with self.pool.get_connection() as conn:
            async with self.pool.transaction(conn):
                for i in range(0, len(relations), batch_size):
                    batch = relations[i:i + batch_size]
                    relation_objects = [Relation.from_dict(r) for r in batch]
                    
                    # Verify entities exist
                    for relation in relation_objects:
                        cursor = await conn.execute(
                            "SELECT 1 FROM entities WHERE name = ?",
                            (sanitize_input(relation.from_),)
                        )
                        if not await cursor.fetchone():
                            raise EntityNotFoundError(relation.from_)
                        
                        cursor = await conn.execute(
                            "SELECT 1 FROM entities WHERE name = ?",
                            (sanitize_input(relation.to),)
                        )
                        if not await cursor.fetchone():
                            raise EntityNotFoundError(relation.to)
                    
                    # Insert batch
                    await conn.executemany(
                        """
                        INSERT INTO relations (from_entity, to_entity, relation_type) 
                        VALUES (?, ?, ?)
                        ON CONFLICT DO NOTHING
                        """,
                        [(r.from_, r.to, r.relationType) for r in relation_objects]
                    )
                    created_relations.extend([r.to_dict() for r in relation_objects])
                    
        return created_relations
  • Tool registration mapping "create_relations" to the dynamic handler.
    "create_relations": lambda args: handle_tool("create_relations", args),
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 this is a creation operation, implying mutation, but doesn't cover critical aspects like permissions needed, whether it's idempotent, error handling, or rate limits. The active voice note is trivial and doesn't add meaningful behavioral context for tool invocation.

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 brief and to the point with two sentences. The first sentence states the core purpose efficiently, and the second adds a stylistic note. There's no unnecessary fluff, though the active voice guidance could be considered slightly extraneous. It's appropriately sized for a simple tool.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool has an output schema (which handles return values), no annotations, and low schema coverage, the description is minimally adequate. It covers the basic purpose but lacks usage guidelines, behavioral details, and parameter explanations. For a mutation tool in a knowledge graph context, more completeness would be helpful, but the output schema mitigates some gaps.

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%, so the schema provides no parameter descriptions. The tool description doesn't explain what 'relations', 'from', 'to', or 'relationType' mean beyond what's inferable from the names. It mentions 'entities in the knowledge graph' and 'active voice', but these don't clarify parameter usage or semantics. Baseline is 3 due to 0% coverage, but the description adds minimal value.

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 ('Create multiple new relations') and the resource ('between entities in the knowledge graph'), which is specific and actionable. However, it doesn't explicitly differentiate from sibling tools like 'delete_relations' or 'create_entities', though the verb 'create' implies a distinction. The active voice guidance is stylistic rather than functional.

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 like 'create_entities' or 'delete_relations'. It mentions active voice as a stylistic preference, but this doesn't help the agent decide between tools based on functional needs or context. There are no explicit when/when-not statements or prerequisites.

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/AgentWong/optimized-memory-mcp-server'

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