Skip to main content
Glama
QuixiAI

AGI MCP Server

by QuixiAI

search_memories_similarity

Find similar memories by comparing vector embeddings to retrieve relevant information from persistent storage for AI systems.

Instructions

Search memories by vector similarity

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
embeddingYesQuery embedding vector
limitNoMaximum number of results
thresholdNoMinimum similarity threshold

Implementation Reference

  • Core handler function implementing vector similarity search using pgvector cosine distance on memory embeddings, filtering active memories above threshold, ordered by similarity.
    async searchMemoriesBySimilarity(queryEmbedding, limit = 10, threshold = 0.7) {
      try {
        const embeddingVector = `[${queryEmbedding.join(',')}]`;
        
        const results = await this.db
          .select({
            id: schema.memories.id,
            type: schema.memories.type,
            content: schema.memories.content,
            importance: schema.memories.importance,
            accessCount: schema.memories.accessCount,
            createdAt: schema.memories.createdAt,
            relevanceScore: schema.memories.relevanceScore,
            similarity: sql`1 - (${schema.memories.embedding} <=> ${embeddingVector}::vector)`.as('similarity')
          })
          .from(schema.memories)
          .where(
            and(
              eq(schema.memories.status, 'active'),
              sql`1 - (${schema.memories.embedding} <=> ${embeddingVector}::vector) >= ${threshold}`
            )
          )
          .orderBy(sql`${schema.memories.embedding} <=> ${embeddingVector}::vector`)
          .limit(limit);
    
        return results;
      } catch (error) {
        const truncatedEmbedding = queryEmbedding.length > 10 
          ? `[${queryEmbedding.slice(0, 5).join(',')}...${queryEmbedding.slice(-5).join(',')}] (${queryEmbedding.length} values)`
          : `[${queryEmbedding.join(',')}]`;
        console.error('Error searching memories by similarity with embedding:', truncatedEmbedding, error.message);
        throw error;
      }
    }
  • mcp.js:546-552 (registration)
    MCP tool registration in CallToolRequestSchema handler switch, calling MemoryManager.searchMemoriesBySimilarity with parsed arguments.
    case "search_memories_similarity":
      const similarMemories = await memoryManager.searchMemoriesBySimilarity(
        args.embedding,
        args.limit || 10,
        args.threshold || 0.7
      );
      return { content: [{ type: "text", text: JSON.stringify(similarMemories, null, 2) }] };
  • Tool schema definition including input validation for embedding vector, optional limit and threshold.
    {
      name: "search_memories_similarity",
      description: "Search memories by vector similarity",
      inputSchema: {
        type: "object",
        properties: {
          embedding: {
            type: "array",
            items: { type: "number" },
            description: "Query embedding vector"
          },
          limit: {
            type: "integer",
            description: "Maximum number of results",
            default: 10
          },
          threshold: {
            type: "number",
            description: "Minimum similarity threshold",
            default: 0.7
          }
        },
        required: ["embedding"]
      }
    },
Behavior2/5

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

With no annotations provided, the description carries full burden but only states the basic operation. It lacks details on behavioral traits such as performance characteristics, rate limits, authentication needs, error handling, or what constitutes a 'memory' in this context.

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?

The description is a single, efficient sentence with zero wasted words. It's front-loaded with the core purpose and uses precise terminology ('vector similarity'), making it highly concise and well-structured.

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?

For a search tool with 3 parameters, no annotations, and no output schema, the description is insufficient. It doesn't cover return format, result structure, pagination, or error cases. Given the complexity of vector similarity searches, more context is needed for effective use.

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?

Schema description coverage is 100%, so parameters are well-documented in the schema. The description adds no additional meaning beyond implying vector similarity is used, but doesn't explain embedding format, similarity metrics, or result ordering. Baseline 3 is appropriate as the schema handles parameter documentation.

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 ('Search') and resource ('memories'), with the specific method 'by vector similarity' distinguishing it from text-based search. However, it doesn't explicitly differentiate from sibling 'search_memories_advanced' or 'find_related_memories', which might also involve similarity searches.

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?

No guidance is provided on when to use this tool versus alternatives like 'search_memories_text' or 'search_memories_advanced'. The description implies it's for vector-based similarity searches but doesn't specify use cases, prerequisites, or exclusions.

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/QuixiAI/agi-mcp-server'

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