Skip to main content
Glama
itseasy21

Knowledge Graph Memory Server

update_relations

Modify multiple existing connections between entities in a knowledge graph to maintain accurate relationship data.

Instructions

Update multiple existing relations in the knowledge graph

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
relationsYes

Implementation Reference

  • The core handler function in KnowledgeGraphManager that updates existing relations by merging provided data into matching relations, incrementing version, and persisting to the memory file.
    async updateRelations(relations: Relation[]): Promise<Relation[]> {
      const graph = await this.loadGraph();
      const updatedRelations = relations.map(updateRelation => {
        const existingRelation = graph.relations.find(r =>
          r.from === updateRelation.from &&
          r.to === updateRelation.to &&
          r.relationType === updateRelation.relationType
        );
        if (!existingRelation) {
          throw new Error(`Relation not found`);
        }
        return {
          ...existingRelation,
          ...updateRelation,
          version: existingRelation.version + 1,
          createdAt: new Date().toISOString()
        };
      });
      
      // Update relations in the graph
      updatedRelations.forEach(updatedRelation => {
        const index = graph.relations.findIndex(r =>
          r.from === updatedRelation.from &&
          r.to === updatedRelation.to &&
          r.relationType === updatedRelation.relationType
        );
        if (index !== -1) {
          graph.relations[index] = updatedRelation;
        }
      });
      
      await this.saveGraph(graph);
      return updatedRelations;
    }
  • JSON schema defining the input for the update_relations tool: an object containing an array of relations, each with 'from', 'to', and 'relationType' fields.
    inputSchema: {
      type: "object",
      properties: {
        relations: {
          type: "array",
          items: {
            type: "object",
            properties: {
              from: { type: "string", description: "The name of the entity where the relation starts" },
              to: { type: "string", description: "The name of the entity where the relation ends" },
              relationType: { type: "string", description: "The type of the relation" },
            },
            required: ["from", "to", "relationType"],
          },
        },
      },
      required: ["relations"],
    },
  • index.ts:480-501 (registration)
    Registers the update_relations tool in the list_tools response, providing name, description, and input schema.
    {
      name: "update_relations",
      description: "Update multiple existing relations in the knowledge graph",
      inputSchema: {
        type: "object",
        properties: {
          relations: {
            type: "array",
            items: {
              type: "object",
              properties: {
                from: { type: "string", description: "The name of the entity where the relation starts" },
                to: { type: "string", description: "The name of the entity where the relation ends" },
                relationType: { type: "string", description: "The type of the relation" },
              },
              required: ["from", "to", "relationType"],
            },
          },
        },
        required: ["relations"],
      },
    },
  • index.ts:537-538 (registration)
    Dispatches the call_tool request for 'update_relations' to the KnowledgeGraphManager.updateRelations method in the switch statement.
    case "update_relations":
      return { content: [{ type: "text", text: JSON.stringify(await knowledgeGraphManager.updateRelations(args.relations as Relation[]), null, 2) }] };
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 'Update multiple existing relations' which implies mutation, but doesn't cover critical aspects like required permissions, whether updates are atomic or batched, error handling, or what happens if relations don't exist. This is inadequate for a mutation tool with zero annotation coverage.

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 directly states the tool's purpose without unnecessary words. It's appropriately sized and front-loaded, making it easy to parse quickly.

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 complexity of updating multiple relations in a knowledge graph, no annotations, no output schema, and poor parameter coverage, the description is insufficient. It lacks details on behavior, parameters, and outcomes, making it incomplete for safe and effective tool invocation by an agent.

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

Parameters1/5

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

The description adds no parameter semantics beyond what's implied by the tool name. With 0% schema description coverage and 1 parameter ('relations'), the schema provides structure but no descriptions for nested properties. The description fails to explain what 'relations' contains or how updates are applied, leaving parameters largely undocumented.

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 ('Update') and resource ('multiple existing relations in the knowledge graph'), making the purpose understandable. However, it doesn't explicitly differentiate from sibling tools like 'create_relations' or 'delete_relations' beyond the 'update' verb, which is why it doesn't reach a perfect score.

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., relations must exist), exclusions, or compare it to siblings like 'create_relations' or 'delete_relations', leaving the agent with minimal context for selection.

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/itseasy21/mcp-knowledge-graph'

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