Skip to main content
Glama
shaneholloman

mcp-knowledge-graph

aim_memory_search

Search memories by keyword matching names, types, and observation content. Use fuzzy matching to find memories when the exact name is unknown.

Instructions

Search memories by keyword. Use this when you don't know the exact name of what you're looking for.

WHAT IT SEARCHES: Matches query (case-insensitive) against:

  • Memory names (e.g., "John" matches "John_Smith")

  • Memory types (e.g., "person" matches all person memories)

  • Facts/observations (e.g., "Seattle" matches memories mentioning Seattle)

VS aim_memory_get: Use aim_memory_search for fuzzy matching. Use aim_memory_get when you know exact names.

FORMAT OPTIONS:

  • "json" (default): Structured JSON for programmatic use

  • "pretty": Human-readable text format

EXAMPLES:

  • aim_memory_search({query: "John"}) - JSON format

  • aim_memory_search({query: "project", format: "pretty"}) - Human-readable

  • aim_memory_search({context: "work", query: "Shane", format: "pretty"})

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contextNoOptional database name. Searches within this database or master database if not specified.
locationNoOptional storage location override. 'project' for .aim directory, 'global' for configured directory.
queryYesSearch text to match against entity names, entity types, and observation content (case-insensitive)
formatNoOutput format. 'json' (default) for structured data, 'pretty' for human-readable text.

Implementation Reference

  • The tool handler for aim_memory_search in the CallToolRequestSchema switch statement. Calls knowledgeGraphManager.searchNodes() and formats output as JSON or pretty text.
    case "aim_memory_search": {
      const graph = await knowledgeGraphManager.searchNodes(args.query as string, args.context as string, args.location as 'project' | 'global');
      const output = args.format === 'pretty'
        ? formatGraphPretty(graph, args.context as string)
        : JSON.stringify(graph, null, 2);
      return { content: [{ type: "text", text: output }] };
  • Input schema for aim_memory_search defining properties: context (optional database name), location (project/global), query (search text), and format (json/pretty). 'query' is required.
    inputSchema: {
      type: "object",
      properties: {
        context: {
          type: "string",
          description: "Optional database name. Searches within this database or master database if not specified."
        },
        location: {
          type: "string",
          enum: ["project", "global"],
          description: "Optional storage location override. 'project' for .aim directory, 'global' for configured directory."
        },
        query: { type: "string", description: "Search text to match against entity names, entity types, and observation content (case-insensitive)" },
        format: {
          type: "string",
          enum: ["json", "pretty"],
          description: "Output format. 'json' (default) for structured data, 'pretty' for human-readable text."
        }
      },
      required: ["query"],
    },
  • The searchNodes method in KnowledgeGraphManager. Loads the graph, filters entities by case-insensitive matching against name, entityType, and observations, then returns a filtered graph with only relations between matched entities.
    async searchNodes(query: string, context?: string, location?: 'project' | 'global'): Promise<KnowledgeGraph> {
      const graph = await this.loadGraph(context, location);
    
      // Filter entities
      const filteredEntities = graph.entities.filter(e =>
        e.name.toLowerCase().includes(query.toLowerCase()) ||
        e.entityType.toLowerCase().includes(query.toLowerCase()) ||
        e.observations.some(o => o.toLowerCase().includes(query.toLowerCase()))
      );
    
      // Create a Set of filtered entity names for quick lookup
      const filteredEntityNames = new Set(filteredEntities.map(e => e.name));
    
      // Filter relations to only include those between filtered entities
      const filteredRelations = graph.relations.filter(r =>
        filteredEntityNames.has(r.from) && filteredEntityNames.has(r.to)
      );
    
      const filteredGraph: KnowledgeGraph = {
        entities: filteredEntities,
        relations: filteredRelations,
      };
    
      return filteredGraph;
    }
  • index.ts:699-739 (registration)
    Tool registration in the ListToolsRequestSchema handler. Defines the tool name 'aim_memory_search' with its description and input schema.
          {
            name: "aim_memory_search",
            description: `Search memories by keyword. Use this when you don't know the exact name of what you're looking for.
    
    WHAT IT SEARCHES: Matches query (case-insensitive) against:
    - Memory names (e.g., "John" matches "John_Smith")
    - Memory types (e.g., "person" matches all person memories)
    - Facts/observations (e.g., "Seattle" matches memories mentioning Seattle)
    
    VS aim_memory_get: Use aim_memory_search for fuzzy matching. Use aim_memory_get when you know exact names.
    
    FORMAT OPTIONS:
    - "json" (default): Structured JSON for programmatic use
    - "pretty": Human-readable text format
    
    EXAMPLES:
    - aim_memory_search({query: "John"}) - JSON format
    - aim_memory_search({query: "project", format: "pretty"}) - Human-readable
    - aim_memory_search({context: "work", query: "Shane", format: "pretty"})`,
            inputSchema: {
              type: "object",
              properties: {
                context: {
                  type: "string",
                  description: "Optional database name. Searches within this database or master database if not specified."
                },
                location: {
                  type: "string",
                  enum: ["project", "global"],
                  description: "Optional storage location override. 'project' for .aim directory, 'global' for configured directory."
                },
                query: { type: "string", description: "Search text to match against entity names, entity types, and observation content (case-insensitive)" },
                format: {
                  type: "string",
                  enum: ["json", "pretty"],
                  description: "Output format. 'json' (default) for structured data, 'pretty' for human-readable text."
                }
              },
              required: ["query"],
            },
          },
Behavior5/5

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

No annotations provided, but description fully covers behavioral traits: case-insensitive matching, fields searched, format options. No destructive hints needed.

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?

Well-structured with headings (WHAT IT SEARCHES, VS, FORMAT OPTIONS, EXAMPLES). Informative but could be slightly more concise; however, organization is excellent.

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?

No output schema, but description covers purpose, usage, parameter semantics, and examples adequately. For a search tool with 4 parameters (100% schema coverage), it is complete.

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 100%, baseline 3. Description adds examples and clarifies search behavior beyond schema, e.g., how context and location work. Adds significant value.

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 it searches memories by keyword, specifies what it matches (names, types, facts), and distinguishes from sibling tool aim_memory_get for exact name matching.

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 when to use ('when you don't know the exact name') and contrasts with aim_memory_get. Provides examples and format options for different use cases.

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