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) };

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