Skip to main content
Glama

get_related_memories

Retrieve semantically similar memories by specifying a memory ID and optional similarity threshold, enabling efficient meaning-based search and retrieval within the Memory Box MCP Server.

Instructions

Find semantically similar memories to a specific memory

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
memory_idYesThe ID of the memory to find related memories for
min_similarityNoMinimum similarity threshold (0.0-1.0) for related memories (default: 0.7)

Implementation Reference

  • MCP tool handler case that validates input, calls the client method to fetch related memories, formats the results into a text response, and returns it.
    case "get_related_memories": {
      // Validate parameters
      const memoryId = request.params.arguments?.memory_id;
      const minSimilarity = Number(request.params.arguments?.min_similarity) || 0.7;
      
      if (!memoryId) {
        throw new McpError(ErrorCode.InvalidParams, "Memory ID is required");
      }
      
      // Get related memories
      const result = await memoryBoxClient.getRelatedMemories(Number(memoryId), minSimilarity);
      
      // Format the results
      let responseText = `Related memories for memory ID ${memoryId} (min similarity: ${minSimilarity * 100}%):\n\n`;
      
      if (result.items && result.items.length > 0) {
        result.items.forEach((memory: any, index: number) => {
          const similarity = memory.similarity ? ` (${Math.round(memory.similarity * 100)}% similar)` : "";
          responseText += `${index + 1}. [ID: ${memory.id}]${similarity} ${memory.text}\n\n`;
        });
      } else {
        responseText += "No related memories found.";
      }
      
      return {
        content: [{
          type: "text",
          text: responseText
        }]
      };
    }
  • Input schema definition for the get_related_memories tool, including properties for memory_id (required) and optional min_similarity.
    {
      name: "get_related_memories",
      description: "Find semantically similar memories to a specific memory",
      inputSchema: {
        type: "object",
        properties: {
          memory_id: {
            type: "integer",
            description: "The ID of the memory to find related memories for"
          },
          min_similarity: {
            type: "number",
            description: "Minimum similarity threshold (0.0-1.0) for related memories (default: 0.7)"
          }
        },
        required: ["memory_id"]
      }
    },
  • MemoryBoxClient method that performs the actual HTTP GET request to retrieve related memories from the Memory Box API endpoint.
    async getRelatedMemories(memoryId: number, minSimilarity: number = 0.7): Promise<any> {
      try {
        const response = await axios.get(
          `${this.baseUrl}/api/v2/memory/${memoryId}/related`,
          {
            params: { min_similarity: minSimilarity },
            headers: {
              "Authorization": `Bearer ${this.token}`
            }
          }
        );
        return response.data;
      } catch (error) {
        if (axios.isAxiosError(error)) {
          throw new McpError(
            ErrorCode.InternalError,
            `Failed to get related memories: ${error.response?.data?.detail || error.message}`
          );
        }
        throw error;
      }
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions 'semantically similar' but doesn't explain what this entails (e.g., algorithm, performance implications) or other traits like rate limits, error handling, or output format. For a tool with no annotation coverage, this is a significant gap in transparency about how it behaves beyond basic functionality.

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 that directly states the tool's purpose without unnecessary words. It's front-loaded with the core action ('Find semantically similar memories'), making it easy to parse. Every word earns its place, with no redundancy or fluff.

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?

Given the complexity of semantic similarity operations and the lack of annotations and output schema, the description is incomplete. It doesn't cover behavioral aspects like how similarity is computed, what the output looks like (e.g., list of memories with scores), or potential limitations. For a tool with no structured data beyond the input schema, more context is needed to fully understand its 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 the schema already documents both parameters ('memory_id' and 'min_similarity') with clear descriptions. The description adds no additional meaning beyond what the schema provides, such as explaining how similarity is calculated or typical threshold values. Baseline 3 is appropriate when the schema does the 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 verb ('Find') and resource ('semantically similar memories to a specific memory'), making the purpose immediately understandable. It distinguishes from siblings like 'get_all_memories' or 'search_memories' by focusing on similarity to a specific memory rather than listing or keyword-based search. However, it doesn't explicitly mention how 'semantically similar' is determined (e.g., embeddings, content analysis), which prevents a perfect score.

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?

The description provides no guidance on when to use this tool versus alternatives like 'search_memories' or 'get_all_memories'. It doesn't specify scenarios where semantic similarity is preferred over keyword search or list retrieval, nor does it mention prerequisites such as needing an existing memory ID. This leaves the agent to infer usage from context alone.

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

Related 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/amotivv/memory-box-mcp'

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