Skip to main content
Glama

expand_memory

Retrieve and expand stored content from tiered responses using expandable IDs to access detailed architectural decision records and related context.

Instructions

Phase 3: Retrieve and expand stored content from a tiered response using its expandable ID

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
expandableIdYesExpandable ID from a tiered response
sectionNoOptional: specific section to expand
includeContextNoInclude related conversation context and knowledge graph state

Implementation Reference

  • The core handler function for the 'expand_memory' tool. Retrieves full analysis content from a tiered response expandable ID using ConversationMemoryManager, formats it with metadata, related turns, and knowledge graph context.
    export async function expandMemory( args: { expandableId: string; section?: string; includeContext?: boolean; }, memoryManager: ConversationMemoryManager ): Promise<CallToolResult> { try { const request: MemoryExpansionRequest = { expandableId: args.expandableId, ...(args.section ? { section: args.section } : {}), includeContext: args.includeContext ?? true, }; const result = await memoryManager.expandContent(request); // Format the expanded content let output = `# Expanded Content: ${args.expandableId}\n\n`; // Show section or full content if (args.section && result.content.sections[args.section]) { output += `## Section: ${args.section}\n\n`; output += result.content.sections[args.section]; } else { output += `## Full Analysis\n\n`; output += result.content.content; } // Add metadata output += `\n\n---\n\n`; output += `**Tool**: ${result.content.metadata.toolName}\n`; output += `**Timestamp**: ${result.content.metadata.timestamp}\n`; output += `**Token Count**: ${result.content.metadata.tokenCount}\n`; // Add related turns if included if (result.relatedTurns && result.relatedTurns.length > 0) { output += `\n## Related Conversation Turns\n\n`; result.relatedTurns.forEach(turn => { output += `- **Turn ${turn.turnNumber}** (${turn.timestamp}): `; output += `${turn.request.toolName || 'message'}\n`; }); } // Add knowledge graph context if included if (result.knowledgeGraphContext && result.knowledgeGraphContext.length > 0) { output += `\n## Knowledge Graph Context\n\n`; result.knowledgeGraphContext.forEach(context => { output += `- **${context.intent}**: ${context.outcome} (${context.timestamp})\n`; }); } return { content: [ { type: 'text', text: output, }, ], }; } catch (error) { return { content: [ { type: 'text', text: `❌ Failed to expand content: ${error instanceof Error ? error.message : String(error)}`, }, ], isError: true, }; } }
  • Type definition for MemoryExpansionRequest, which defines the input parameters for the expandMemory handler (expandableId, section, includeContext).
    export interface MemoryExpansionRequest { /** Expandable ID from tiered response */ expandableId: string; /** Optional: specific section to expand */ section?: string;
  • Metadata and approximate schema registration for the 'expand_memory' tool in the central tool catalog used for discovery and ListTools responses.
    TOOL_CATALOG.set('expand_memory', { name: 'expand_memory', shortDescription: 'Expand memory with new context', fullDescription: 'Expands memory with additional context information.', category: 'memory', complexity: 'simple', tokenCost: { min: 300, max: 800 }, hasCEMCPDirective: true, // Phase 4.3: Simple tool - memory storage relatedTools: ['memory_loading', 'get_memory_stats'], keywords: ['memory', 'expand', 'add', 'context'], requiresAI: false, inputSchema: { type: 'object', properties: { key: { type: 'string' }, value: { type: 'object' }, }, required: ['key', 'value'], }, });
  • Function signature and dependencies showing integration with ConversationMemoryManager.
    export async function expandMemory( args: { expandableId: string; section?: string; includeContext?: boolean; }, memoryManager: ConversationMemoryManager ): Promise<CallToolResult> { try { const request: MemoryExpansionRequest = { expandableId: args.expandableId, ...(args.section ? { section: args.section } : {}), includeContext: args.includeContext ?? true, }; const result = await memoryManager.expandContent(request); // Format the expanded content let output = `# Expanded Content: ${args.expandableId}\n\n`; // Show section or full content if (args.section && result.content.sections[args.section]) { output += `## Section: ${args.section}\n\n`; output += result.content.sections[args.section]; } else { output += `## Full Analysis\n\n`; output += result.content.content; } // Add metadata output += `\n\n---\n\n`; output += `**Tool**: ${result.content.metadata.toolName}\n`; output += `**Timestamp**: ${result.content.metadata.timestamp}\n`; output += `**Token Count**: ${result.content.metadata.tokenCount}\n`; // Add related turns if included if (result.relatedTurns && result.relatedTurns.length > 0) { output += `\n## Related Conversation Turns\n\n`; result.relatedTurns.forEach(turn => { output += `- **Turn ${turn.turnNumber}** (${turn.timestamp}): `; output += `${turn.request.toolName || 'message'}\n`; }); } // Add knowledge graph context if included if (result.knowledgeGraphContext && result.knowledgeGraphContext.length > 0) { output += `\n## Knowledge Graph Context\n\n`; result.knowledgeGraphContext.forEach(context => { output += `- **${context.intent}**: ${context.outcome} (${context.timestamp})\n`; }); } return { content: [ { type: 'text', text: output, }, ], }; } catch (error) { return { content: [ { type: 'text', text: `❌ Failed to expand content: ${error instanceof Error ? error.message : String(error)}`, }, ], isError: true, }; } }
  • Reference listing of the tool in server context generator with accurate description matching handler purpose.
    { name: 'expand_memory', description: 'Retrieve and expand stored content from tiered responses',

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/tosin2013/mcp-adr-analysis-server'

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