Skip to main content
Glama

retrieve_relevant_thoughts

Finds related thoughts from long-term storage by matching tags with a specified thought, enabling exploration of connected ideas in structured thinking systems.

Instructions

Finds thoughts from long-term storage that share tags with the specified thought.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
thought_idYesThe ID of the thought to find related thoughts for

Implementation Reference

  • MCP server request handler for the 'retrieve_relevant_thoughts' tool call. Validates arguments, extracts thought_id, and delegates to EnhancedSequentialThinkingServer.retrieveRelevantThoughts.
    case "retrieve_relevant_thoughts": {        
      if (!params.arguments) {
        console.error("ERROR: params.arguments object is undefined in retrieve_relevant_thoughts request");
        return {
          content: [{
            type: "text",
            text: JSON.stringify({
              error: "Invalid request: params.arguments object is undefined",
              status: "failed"
            })
          }],
          isError: true
        };
      }
      
      const { thought_id } = params.arguments as { thought_id: number };
      return thinkingServer.retrieveRelevantThoughts({ thought_id });
    }
  • EnhancedSequentialThinkingServer.retrieveRelevantThoughts: Finds the specified thought by ID, retrieves related thoughts via memoryManager, and returns formatted response.
    retrieveRelevantThoughts(input: { thought_id: number }): any {
      try {
        // Find the thought
        const thought = this.findThoughtById(input.thought_id);
        if (!thought) {
          throw new Error(`Thought with ID ${input.thought_id} not found`);
        }
        
        // Get related thoughts
        const relatedThoughts = this.memoryManager.retrieveRelevantThoughts(thought);
        
        return {
          content: [{
            type: "text",
            text: JSON.stringify({
              status: "success",
              retrieval: {
                thoughtNumber: thought.thoughtNumber,
                relatedThoughtsCount: relatedThoughts.length,
                relatedThoughts: relatedThoughts.map(t => ({
                  thoughtNumber: t.thoughtNumber,
                  stage: t.stage,
                  tags: t.tags
                }))
              }
            }, null, 2)
          }]
        };
        
      } catch (e) {
        return this.handleError(e);
      }
    }
  • MemoryManager.retrieveRelevantThoughts: Core logic that scans long-term storage for thoughts sharing any tags with the input thought.
    retrieveRelevantThoughts(currentThought: ThoughtData): ThoughtData[] {
      const relevant: ThoughtData[] = [];
      for (const thoughts of Object.values(this.longTermStorage)) {
        for (const thought of thoughts) {
          if (thought.tags.some(tag => currentThought.tags.includes(tag))) {
            relevant.push(thought);
          }
        }
      }
      return relevant;
    }
  • Zod schema for tool input parameters: requires positive integer thought_id.
    export const retrieveRelevantThoughtsSchema = z.object({
      thought_id: z.number().int().positive().describe("The ID of the thought to find related thoughts for")
    });
  • src/tools.ts:59-64 (registration)
    Tool definition object registered in toolDefinitions array used by MCP server's ListTools handler.
    export const retrieveRelevantThoughtsTool: Tool = {
      name: "retrieve_relevant_thoughts",
      description: "Finds thoughts from long-term storage that share tags with the specified thought.",
      parameters: retrieveRelevantThoughtsSchema,
      inputSchema: zodToInputSchema(retrieveRelevantThoughtsSchema)
    };
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It states the tool 'finds thoughts' but doesn't specify whether this is a read-only operation, what permissions are needed, how results are returned (e.g., list format, pagination), or any rate limits. For a retrieval tool with zero annotation coverage, this is a significant gap in transparency.

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 front-loads the core purpose ('Finds thoughts from long-term storage') and adds necessary detail ('that share tags with the specified thought'). There is zero wasted text, making it highly concise and well-structured for quick understanding.

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 tool's complexity (retrieval based on tag matching), lack of annotations, and no output schema, the description is incomplete. It doesn't explain what 'relevant' means beyond tag sharing, how results are ordered or limited, or what the return format is. For a tool with no structured behavioral or output data, the description should provide more context to be fully helpful.

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?

The input schema has 100% description coverage, with the single parameter 'thought_id' clearly documented as 'The ID of the thought to find related thoughts for.' The description adds no additional parameter semantics beyond what the schema provides, such as format examples or constraints. With high schema coverage, the baseline score of 3 is appropriate.

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 'finds' and the resource 'thoughts from long-term storage' with the specific mechanism 'that share tags with the specified thought.' It distinguishes from siblings like 'capture_thought' (create) and 'clear_thinking_history' (delete) by focusing on retrieval based on tag similarity. However, it doesn't explicitly differentiate from 'get_thinking_summary' (which might summarize rather than retrieve) or 'revise_thought' (modify), keeping it at 4 rather than 5.

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 'get_thinking_summary' or 'revise_thought.' It implies usage for finding related thoughts based on tags, but lacks explicit when/when-not instructions or prerequisites. This leaves the agent with minimal context for tool selection among siblings.

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/Promptly-Technologies-LLC/mcp-structured-thinking'

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