Skip to main content
Glama

query_reasoning_memory

Search memory to retrieve related insights, hypotheses, and evidence from previous reasoning sessions, helping build on established connections and solutions.

Instructions

Query the integrated memory system to find related insights, hypotheses, and evidence.

Useful for:

  • Finding similar problems solved before

  • Retrieving relevant hypotheses and evidence

  • Understanding connections between ideas

  • Building on previous reasoning sessions

Parameters:

  • session_id: The reasoning session to query within (required)

  • query: What to search for in memory (required)

Returns related memories with confidence scores and connection information.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
session_idYesReasoning session identifier
queryYesWhat to search for in memory

Implementation Reference

  • The main handler function for the 'query_reasoning_memory' tool. It queries the cognitive memory for related nodes using the provided query and session ID, then returns the results including session context and memory stats.
    public queryMemory(sessionId: string, query: string): { content: Array<{ type: string; text: string }>; isError?: boolean } { try { const relatedNodes = this.memory.queryRelated(query, 10); const session = this.memory.getSession(sessionId); return { content: [{ type: "text", text: JSON.stringify({ query, sessionContext: session, relatedMemories: relatedNodes.map(node => ({ content: node.content, type: node.type, confidence: node.confidence, connections: node.connections.length })), memoryStats: this.memory.getMemoryStats() }, null, 2) }] }; } catch (error) { return { content: [{ type: "text", text: JSON.stringify({ error: error instanceof Error ? error.message : String(error), status: 'failed' }, null, 2) }], isError: true }; } }
  • Tool definition including name, description, and input schema specifying required parameters 'session_id' and 'query'.
    const QUERY_MEMORY_TOOL: Tool = { name: "query_reasoning_memory", description: `Query the integrated memory system to find related insights, hypotheses, and evidence. Useful for: - Finding similar problems solved before - Retrieving relevant hypotheses and evidence - Understanding connections between ideas - Building on previous reasoning sessions Parameters: - session_id: The reasoning session to query within (required) - query: What to search for in memory (required) Returns related memories with confidence scores and connection information.`, inputSchema: { type: "object", properties: { session_id: { type: "string", description: "Reasoning session identifier" }, query: { type: "string", description: "What to search for in memory" } }, required: ["session_id", "query"] } };
  • src/index.ts:1416-1418 (registration)
    Registration in the tool dispatcher switch statement. Extracts arguments and delegates to the queryMemory handler method.
    case "query_reasoning_memory": const { session_id, query } = args as { session_id: string; query: string }; return reasoningServer.queryMemory(session_id, query);
  • src/index.ts:1394-1407 (registration)
    Tool registration in the ListToolsRequestSchema handler by including QUERY_MEMORY_TOOL in the returned tools array.
    server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: [ ADVANCED_REASONING_TOOL, QUERY_MEMORY_TOOL, CREATE_LIBRARY_TOOL, LIST_LIBRARIES_TOOL, SWITCH_LIBRARY_TOOL, GET_LIBRARY_INFO_TOOL, CREATE_SYSTEM_JSON_TOOL, GET_SYSTEM_JSON_TOOL, SEARCH_SYSTEM_JSON_TOOL, LIST_SYSTEM_JSON_TOOL ], }));
  • Core helper method in CognitiveMemory class that performs TF-IDF based relevance search to find related memory nodes, used by the tool handler.
    queryRelated(content: string, maxResults: number = 5): MemoryNode[] { const results: Array<{ node: MemoryNode; relevance: number }> = []; for (const node of this.nodes.values()) { const relevance = this.calculateRelevance(content, node.content); if (relevance > 0.1) { // Threshold results.push({ node, relevance }); } } return results .sort((a, b) => b.relevance - a.relevance) .slice(0, maxResults) .map(r => r.node); }

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/angrysky56/advanced-reasoning-mcp'

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