Skip to main content
Glama

search_memories_advanced

Read-onlyIdempotent

Search memories using multiple strategies including keyword matching, graph traversal, temporal ordering, priority-based filtering, and context-aware combinations to find relevant information.

Instructions

고급 멀티 전략 메모리 검색을 수행합니다.

키워드: 고급 검색, 찾아, 스마트 검색, advanced search, find memories

검색 전략:

  • keyword: 전통적 키워드 검색

  • graph_traversal: 그래프 기반 관련 메모리 탐색

  • temporal: 시간순 정렬

  • priority: 우선순위 기반

  • context_aware: 복합 전략 (키워드 + 우선순위 + 최근성)

사용 예시:

  • "authentication 관련 메모리 고급 검색"

  • "그래프 탐색으로 project-architecture 관련 메모리 찾기"

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYes검색 쿼리
strategyNo검색 전략
limitNo최대 결과 수 (기본값: 10)
categoryNo카테고리 필터
startKeyNo그래프 탐색 시작 키 (graph_traversal 전략용)
depthNo그래프 탐색 깊이 (기본값: 2)
includeRelationsNo관계 정보 포함 여부

Implementation Reference

  • Main handler function that performs the advanced memory search using MemoryManager.searchAdvanced with various strategies, formats results including previews and relations, handles no results and errors.
    export async function searchMemoriesAdvanced(args: SearchMemoriesAdvancedArgs): Promise<ToolResult> {
      try {
        const {
          query,
          strategy = 'context_aware',
          limit = 10,
          category,
          startKey,
          depth = 2,
          includeRelations = false
        } = args;
    
        const memoryManager = MemoryManager.getInstance();
    
        const results = memoryManager.searchAdvanced(query, strategy, {
          limit,
          category,
          startKey,
          depth,
          includeRelations
        });
    
        if (results.length === 0) {
          return {
            content: [{
              type: 'text',
              text: `✗ "${query}"에 대한 검색 결과가 없습니다.
    
    **사용된 전략**: ${strategy}
    ${category ? `**카테고리 필터**: ${category}` : ''}
    
    다른 검색 전략을 시도해보세요:
    - keyword: 기본 키워드 매칭
    - temporal: 최신 메모리 우선
    - priority: 중요 메모리 우선
    - context_aware: 종합 점수`
            }]
          };
        }
    
        let output = `## 검색 결과: "${query}"\n\n`;
        output += `**전략**: ${getStrategyDescription(strategy)}\n`;
        output += `**결과 수**: ${results.length}개\n\n`;
    
        for (let i = 0; i < results.length; i++) {
          const memory = results[i];
          output += `### ${i + 1}. ${memory.key}\n`;
          output += `- **카테고리**: ${memory.category}\n`;
          output += `- **우선순위**: ${memory.priority || 0}\n`;
          output += `- **생성일**: ${formatDate(memory.timestamp)}\n`;
          output += `- **마지막 접근**: ${formatDate(memory.lastAccessed)}\n`;
    
          // Include relations if requested
          if (includeRelations) {
            const relations = memoryManager.getRelations(memory.key, 'both');
            if (relations.length > 0) {
              output += `- **관계**: ${relations.length}개\n`;
              for (const rel of relations.slice(0, 3)) {
                const other = rel.sourceKey === memory.key ? rel.targetKey : rel.sourceKey;
                output += `  - ${rel.relationType} → ${other}\n`;
              }
              if (relations.length > 3) {
                output += `  - ... 외 ${relations.length - 3}개\n`;
              }
            }
          }
    
          // Show value preview
          const preview = memory.value.length > 200
            ? memory.value.substring(0, 200) + '...'
            : memory.value;
          output += `\n\`\`\`\n${preview}\n\`\`\`\n\n`;
        }
    
        return {
          content: [{
            type: 'text',
            text: output
          }]
        };
      } catch (error) {
        return {
          content: [{
            type: 'text',
            text: `✗ 검색 오류: ${error instanceof Error ? error.message : '알 수 없는 오류'}`
          }]
        };
      }
    }
  • ToolDefinition object defining name, description, inputSchema with parameters like query, strategy, limit etc., and annotations.
    export const searchMemoriesAdvancedDefinition: ToolDefinition = {
      name: 'search_memories_advanced',
      description: `고급 멀티 전략 메모리 검색을 수행합니다.
    
    키워드: 고급 검색, 찾아, 스마트 검색, advanced search, find memories
    
    **검색 전략:**
    - keyword: 전통적 키워드 검색
    - graph_traversal: 그래프 기반 관련 메모리 탐색
    - temporal: 시간순 정렬
    - priority: 우선순위 기반
    - context_aware: 복합 전략 (키워드 + 우선순위 + 최근성)
    
    사용 예시:
    - "authentication 관련 메모리 고급 검색"
    - "그래프 탐색으로 project-architecture 관련 메모리 찾기"`,
      inputSchema: {
        type: 'object',
        properties: {
          query: {
            type: 'string',
            description: '검색 쿼리'
          },
          strategy: {
            type: 'string',
            description: '검색 전략',
            enum: ['keyword', 'graph_traversal', 'temporal', 'priority', 'context_aware']
          },
          limit: {
            type: 'number',
            description: '최대 결과 수 (기본값: 10)'
          },
          category: {
            type: 'string',
            description: '카테고리 필터'
          },
          startKey: {
            type: 'string',
            description: '그래프 탐색 시작 키 (graph_traversal 전략용)'
          },
          depth: {
            type: 'number',
            description: '그래프 탐색 깊이 (기본값: 2)'
          },
          includeRelations: {
            type: 'boolean',
            description: '관계 정보 포함 여부'
          }
        },
        required: ['query']
      },
      annotations: {
        title: 'Search Memories (Advanced)',
        audience: ['user', 'assistant'],
        readOnlyHint: true,
        destructiveHint: false,
        idempotentHint: true,
        openWorldHint: false
      }
    };
  • src/index.ts:171-171 (registration)
    Registers the handler function in the toolHandlers object for dynamic dispatch on tool calls.
    'search_memories_advanced': searchMemoriesAdvanced,
  • src/index.ts:104-104 (registration)
    Includes the tool definition in the tools array served via ListToolsRequest.
    searchMemoriesAdvancedDefinition,
  • Helper function providing Korean descriptions for search strategies used in output formatting.
    function getStrategyDescription(strategy: SearchStrategy): string {
      const descriptions: Record<SearchStrategy, string> = {
        keyword: '키워드 매칭',
        graph_traversal: '그래프 탐색',
        temporal: '시간순 정렬',
        priority: '우선순위 기반',
        context_aware: '복합 전략 (키워드 + 우선순위 + 최근성)'
      };
      return descriptions[strategy] || strategy;
    }
Behavior4/5

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

The description adds valuable behavioral context beyond annotations by explaining the five different search strategies and their purposes. Annotations already declare readOnlyHint=true, destructiveHint=false, idempotentHint=true, and openWorldHint=false, but the description provides operational details about how searches work differently based on strategy. No contradiction with annotations exists.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is reasonably structured with strategy explanations and usage examples, but includes redundant keywords ('고급 검색, 찾아, 스마트 검색, advanced search, find memories') that don't add value. The content is front-loaded with the core purpose, but could be more concise by removing the keyword list.

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?

For a complex search tool with 7 parameters and no output schema, the description provides good context about search strategies and usage. However, it doesn't explain what the tool returns (memory objects, summaries, etc.) or any limitations like pagination or performance characteristics. The strategy explanations help compensate for the missing output schema.

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?

With 100% schema description coverage, the schema already documents all 7 parameters thoroughly. The description adds some value by explaining the purpose of different 'strategy' enum values, but doesn't provide additional semantic context for other parameters like 'query', 'limit', or 'category' beyond what's in the schema. Baseline 3 is appropriate when schema does heavy lifting.

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 tool performs 'advanced multi-strategy memory search' which is a specific verb+resource combination. However, it doesn't explicitly differentiate itself from sibling tools like 'list_memories' or 'recall_memory', which might also retrieve memories. The purpose is clear but sibling differentiation is missing.

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 context about when to use different strategies (keyword for traditional search, graph_traversal for related memories, etc.) and includes usage examples. However, it doesn't explicitly state when NOT to use this tool versus alternatives like 'list_memories' or 'recall_memory' from the sibling list.

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/su-record/hi-ai'

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