Skip to main content
Glama
shaneholloman

mcp-knowledge-graph

aim_memory_add_facts

Add new observations to an existing entity in a knowledge graph memory. Append facts like 'Lives in Seattle' to a person or project, with optional context and location settings.

Instructions

Add new facts to an existing memory. Use this to append information to something already stored.

IMPORTANT: Memory must already exist - use aim_memory_store first. Throws error if not found.

RETURNS: Array of {entityName, addedObservations} showing what was added (duplicates are ignored).

DATABASE: Adds to entities in the specified 'context' database, or master database if not specified.

EXAMPLES:

  • aim_memory_add_facts({observations: [{entityName: "John", contents: ["Lives in Seattle", "Works in tech"]}]})

  • aim_memory_add_facts({context: "work", observations: [{entityName: "Q4_Project", contents: ["Behind schedule", "Need more resources"]}]})

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contextNoOptional memory context. Observations will be added to entities 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.
observationsYes

Implementation Reference

  • index.ts:501-543 (registration)
    Tool registration for 'aim_memory_add_facts' in the ListToolsRequestSchema handler. Defines name, description, and inputSchema (accepts context, location, observations).
          {
            name: "aim_memory_add_facts",
            description: `Add new facts to an existing memory. Use this to append information to something already stored.
    
    IMPORTANT: Memory must already exist - use aim_memory_store first. Throws error if not found.
    
    RETURNS: Array of {entityName, addedObservations} showing what was added (duplicates are ignored).
    
    DATABASE: Adds to entities in the specified 'context' database, or master database if not specified.
    
    EXAMPLES:
    - aim_memory_add_facts({observations: [{entityName: "John", contents: ["Lives in Seattle", "Works in tech"]}]})
    - aim_memory_add_facts({context: "work", observations: [{entityName: "Q4_Project", contents: ["Behind schedule", "Need more resources"]}]})`,
            inputSchema: {
              type: "object",
              properties: {
                context: {
                  type: "string",
                  description: "Optional memory context. Observations will be added to entities 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."
                },
                observations: {
                  type: "array",
                  items: {
                    type: "object",
                    properties: {
                      entityName: { type: "string", description: "The name of the entity to add the observations to" },
                      contents: {
                        type: "array",
                        items: { type: "string" },
                        description: "An array of observation contents to add"
                      },
                    },
                    required: ["entityName", "contents"],
                  },
                },
              },
              required: ["observations"],
            },
  • The CallToolRequestSchema handler case for 'aim_memory_add_facts'. Calls knowledgeGraphManager.addObservations() with the args and returns JSON result.
    case "aim_memory_add_facts":
      return { content: [{ type: "text", text: JSON.stringify(await knowledgeGraphManager.addObservations(args.observations as { entityName: string; contents: string[] }[], args.context as string, args.location as 'project' | 'global'), null, 2) }] };
  • The addObservations method on KnowledgeGraphManager. Loads the graph, finds each entity by name (throws if not found), filters out duplicate observations, adds new ones, saves, and returns results.
    async addObservations(observations: { entityName: string; contents: string[] }[], context?: string, location?: 'project' | 'global'): Promise<{ entityName: string; addedObservations: string[] }[]> {
      const graph = await this.loadGraph(context, location);
      const results = observations.map(o => {
        const entity = graph.entities.find(e => e.name === o.entityName);
        if (!entity) {
          throw new Error(`Entity with name ${o.entityName} not found`);
        }
        const newObservations = o.contents.filter(content => !entity.observations.includes(content));
        entity.observations.push(...newObservations);
        return { entityName: o.entityName, addedObservations: newObservations };
      });
      await this.saveGraph(graph, context, location);
      return results;
    }
  • Input schema for aim_memory_add_facts: requires 'observations' array of {entityName, contents[]}, optional 'context' string and 'location' enum.
    inputSchema: {
      type: "object",
      properties: {
        context: {
          type: "string",
          description: "Optional memory context. Observations will be added to entities 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."
        },
        observations: {
          type: "array",
          items: {
            type: "object",
            properties: {
              entityName: { type: "string", description: "The name of the entity to add the observations to" },
              contents: {
                type: "array",
                items: { type: "string" },
                description: "An array of observation contents to add"
              },
            },
            required: ["entityName", "contents"],
          },
        },
      },
      required: ["observations"],
Behavior5/5

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

Despite no annotations, the description discloses key behaviors: duplicates are ignored, returns an array of {entityName, addedObservations}, and database context (adds to specified or master database). No contradictions.

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?

Description is concise with a clear structure: purpose, important note, return value, database context, and examples. Every sentence adds value without redundancy.

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

Completeness5/5

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

Given no output schema, the description adequately explains return format and behavior. It covers error handling, database context, and duplicate handling. Sufficient for correct invocation.

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% with descriptions, but the description adds value by explaining the return format for observations and providing examples that clarify parameter usage. The baseline is 3 due to schema coverage, but examples elevate it to 4.

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 clearly states the tool adds new facts to an existing memory, distinguishing it from sibling tools like aim_memory_store (creates new memory) and aim_memory_remove_facts (removes facts). The verb 'add' and resource 'facts' are specific.

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

Usage Guidelines5/5

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

Explicitly states that memory must already exist and to use aim_memory_store first, plus that it throws an error if not found. Provides clear when-to-use and preconditions. Examples further guide usage.

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