Skip to main content
Glama

add_edges

Add multiple edges between nodes in a knowledge graph to define relationships, including edge types and optional weights, using the MemoryMesh MCP server.

Instructions

Add multiple new edges between nodes in the knowledge graph. Edges should be in active voice

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
edgesYesArray of edges to add

Implementation Reference

  • The switch case handler that executes the "add_edges" MCP tool logic by calling the knowledge graph manager to add edges and formatting the tool response.
    case "add_edges":
        const addedEdges = await this.knowledgeGraphManager.addEdges(args.edges);
        return formatToolResponse({
            data: {edges: addedEdges},
            actionTaken: "Added edges to knowledge graph"
        });
  • The tool definition including name, description, and input schema for validating parameters to the "add_edges" tool.
    {
        name: "add_edges",
        description: "Add multiple new edges between nodes in the knowledge graph. Edges should be in active voice",
        inputSchema: {
            type: "object",
            properties: {
                edges: {
                    type: "array",
                    description: "Array of edges to add",
                    items: {
                        type: "object",
                        description: "Edge to add",
                        properties: {
                            from: {type: "string", description: "The name of the node where the edge starts"},
                            to: {type: "string", description: "The name of the node where the edge ends"},
                            edgeType: {type: "string", description: "The type of the edge"},
                            weight: {
                                type: "number",
                                description: "Optional edge weight (0-1 range). Defaults to 1 if not specified",
                                minimum: 0,
                                maximum: 1
                            }
                        },
                        required: ["from", "to", "edgeType"],
                    },
                },
            },
            required: ["edges"],
        },
    },
  • Registers the static tools, including "add_edges", into the central tools registry map by name.
    allStaticTools.forEach(tool => {
        this.tools.set(tool.name, tool);
    });
  • Core implementation of adding edges to the graph storage, with validation, events, and persistence. Called indirectly by the tool handler.
    async addEdges(edges: Edge[]): Promise<Edge[]> {
        try {
            this.emit('beforeAddEdges', {edges});
    
            const graph = await this.storage.loadGraph();
    
            // Validate edge uniqueness and node existence using GraphValidator
            const newEdges = edges.filter(edge => {
                GraphValidator.validateEdgeUniqueness(graph, edge);
                // Ensure weights are set
                return EdgeWeightUtils.ensureWeight(edge);
            });
    
            if (newEdges.length === 0) {
                return [];
            }
    
            for (const edge of newEdges) {
                GraphValidator.validateNodeExists(graph, edge.from);
                GraphValidator.validateNodeExists(graph, edge.to);
            }
    
            graph.edges.push(...newEdges);
            await this.storage.saveGraph(graph);
    
            this.emit('afterAddEdges', {edges: newEdges});
            return newEdges;
        } catch (error) {
            const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
            throw new Error(errorMessage);
        }
    }
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 the tool adds edges but fails to describe critical behaviors such as whether this is a mutation that requires specific permissions, if it overwrites existing edges, what happens on errors, or the expected response format. The mention of 'active voice' is stylistic and doesn't add meaningful behavioral insight.

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 front-loaded with the core purpose in the first sentence, making it efficient. However, the second sentence ('Edges should be in active voice') adds little value and could be considered wasteful, slightly reducing the score from perfect.

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 a mutation tool with no annotations and no output schema, the description is insufficient. It lacks details on behavioral traits, error handling, return values, and differentiation from sibling tools, making it incomplete for an AI agent to use effectively without additional context.

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?

The schema description coverage is 100%, meaning the input schema already documents the 'edges' parameter and its nested properties thoroughly. The description adds no additional semantic information about parameters beyond what's in the schema, so it meets the baseline score of 3 without compensating for any gaps.

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 ('Add multiple new edges') and resource ('between nodes in the knowledge graph'), making the purpose understandable. However, it doesn't explicitly distinguish this tool from its sibling 'update_edges' or explain why one would add edges versus update existing ones, which prevents 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 minimal guidance with the phrase 'Edges should be in active voice,' which is vague and not a practical usage rule. It offers no explicit advice on when to use this tool versus alternatives like 'update_edges' or 'delete_edges,' nor does it mention prerequisites or context for adding edges, leaving the agent with little direction.

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/CheMiguel23/MemoryMesh'

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