Skip to main content
Glama
shaneholloman

mcp-knowledge-graph

aim_memory_link

Create relationships between existing memory entities by specifying a subject, verb, and object to connect related information.

Instructions

Link two memories together with a relationship. Use this to connect related information.

RELATION STRUCTURE: Each link has 'from' (subject), 'relationType' (verb), and 'to' (object).

  • Use active voice verbs: "manages", "works_at", "knows", "attended", "created"

  • Read as: "from relationType to" (e.g., "Alice manages Q4_Project")

  • Avoid passive: use "manages" not "is_managed_by"

IMPORTANT: Both 'from' and 'to' entities must already exist in the same database.

RETURNS: Array of created relations (duplicates are ignored).

DATABASE: Relations are created in the specified 'context' database, or master database if not specified.

EXAMPLES:

  • aim_memory_link({relations: [{from: "John", to: "TechConf2024", relationType: "attended"}]})

  • aim_memory_link({context: "work", relations: [{from: "Alice", to: "Q4_Project", relationType: "manages"}]})

  • Multiple: aim_memory_link({relations: [{from: "John", to: "Alice", relationType: "knows"}, {from: "John", to: "Acme_Corp", relationType: "works_at"}]})

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contextNoOptional memory context. Relations will be created in the specified context's knowledge graph.
locationNoOptional storage location override. 'project' forces project-local .aim directory, 'global' forces global directory. If not specified, uses automatic detection.
relationsYes

Implementation Reference

  • Tool registration and input schema for aim_memory_link — defines name, description, and inputSchema with context, location, and relations fields.
          {
            name: "aim_memory_link",
            description: `Link two memories together with a relationship. Use this to connect related information.
    
    RELATION STRUCTURE: Each link has 'from' (subject), 'relationType' (verb), and 'to' (object).
    - Use active voice verbs: "manages", "works_at", "knows", "attended", "created"
    - Read as: "from relationType to" (e.g., "Alice manages Q4_Project")
    - Avoid passive: use "manages" not "is_managed_by"
    
    IMPORTANT: Both 'from' and 'to' entities must already exist in the same database.
    
    RETURNS: Array of created relations (duplicates are ignored).
    
    DATABASE: Relations are created in the specified 'context' database, or master database if not specified.
    
    EXAMPLES:
    - aim_memory_link({relations: [{from: "John", to: "TechConf2024", relationType: "attended"}]})
    - aim_memory_link({context: "work", relations: [{from: "Alice", to: "Q4_Project", relationType: "manages"}]})
    - Multiple: aim_memory_link({relations: [{from: "John", to: "Alice", relationType: "knows"}, {from: "John", to: "Acme_Corp", relationType: "works_at"}]})`,
            inputSchema: {
              type: "object",
              properties: {
                context: {
                  type: "string",
                  description: "Optional memory context. Relations will be created in the specified context's knowledge graph."
                },
                location: {
                  type: "string",
                  enum: ["project", "global"],
                  description: "Optional storage location override. 'project' forces project-local .aim directory, 'global' forces global directory. If not specified, uses automatic detection."
                },
                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"],
            },
  • Handler for aim_memory_link — calls knowledgeGraphManager.createRelations() with args.relations, args.context, and args.location.
    case "aim_memory_link":
      return { content: [{ type: "text", text: JSON.stringify(await knowledgeGraphManager.createRelations(args.relations as Relation[], args.context as string, args.location as 'project' | 'global'), null, 2) }] };
  • createRelations method in KnowledgeGraphManager — loads the graph, filters out duplicates, adds new relations, saves and returns them.
    async createRelations(relations: Relation[], context?: string, location?: 'project' | 'global'): Promise<Relation[]> {
      const graph = await this.loadGraph(context, location);
      const newRelations = relations.filter(r => !graph.relations.some(existingRelation =>
        existingRelation.from === r.from &&
        existingRelation.to === r.to &&
        existingRelation.relationType === r.relationType
      ));
      graph.relations.push(...newRelations);
      await this.saveGraph(graph, context, location);
      return newRelations;
    }
  • Relation interface — defines the structure of a relation with from, to, and relationType fields.
    interface Relation {
      from: string;
      to: string;
      relationType: string;
    }
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full responsibility. It discloses key behaviors: duplicates are ignored, returns an array of created relations, requires existing entities, and uses active voice. It does not cover error handling or side effects, but the described behaviors are sufficient for safe 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 well-organized with clear sections: purpose, relation structure, important note, returns, database info, and examples. Every sentence adds value, though it is slightly verbose in places. It is front-loaded with key information.

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

Completeness4/5

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

Given no output schema and moderate complexity, the description covers preconditions (entities must exist), return type (array of relations), and includes multiple examples. It does not explicitly tie into sibling tools, but it is complete enough for an agent to use correctly. Minor omissions like error behavior on missing entities are acceptable given the tool's simplicity.

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

Parameters4/5

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

Schema coverage is 67%, placing the burden on the description to add meaning. The description enhances parameter semantics by providing example values for relationType, explaining the relation structure (from-relationType-to), and recommending active voice. This goes beyond the schema's basic descriptions.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description explicitly states the tool's purpose: 'Link two memories together with a relationship.' and 'Use this to connect related information.' It clearly differentiates from sibling tools like aim_memory_add_facts (which adds facts) and aim_memory_unlink (which removes links) by focusing on creating associations. Examples further clarify the intended use.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear usage context: how to structure relations with active voice, required preconditions (entities must exist), and where relations are stored (context database or master). It does not explicitly compare to alternatives or state when not to use, but the examples and structure guide usage effectively.

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

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