Skip to main content
Glama

mcp-adr-analysis-server

by tosin2013
expand-analysis-tool.tsโ€ข3.92 kB
/** * Expand Analysis Tool * * Retrieves full analysis content from tiered responses stored in memory. * Supports expanding entire analysis or specific sections. */ import { TieredResponseManager } from '../utils/tiered-response-manager.js'; import { MemoryEntityManager } from '../utils/memory-entity-manager.js'; import { McpAdrError } from '../types/index.js'; interface ExpandAnalysisParams { /** ID of the expandable analysis */ expandableId: string; /** Optional: Specific section to expand (if omitted, returns full analysis) */ section?: string; /** Format of the output */ format?: 'markdown' | 'json'; } export async function expandAnalysisSection( params: ExpandAnalysisParams ): Promise<{ content: Array<{ type: 'text'; text: string }>; isError?: boolean }> { const { expandableId, section, format = 'markdown' } = params; try { const memoryManager = new MemoryEntityManager(); const tieredManager = new TieredResponseManager(memoryManager); await tieredManager.initialize(); // Retrieve expandable content const expandableContent = await tieredManager.getExpandableContent(expandableId); if (!expandableContent) { throw new McpAdrError( `No expandable content found for ID: ${expandableId}. It may have been deleted or expired.`, 'NOT_FOUND' ); } // Determine what to return let outputContent: string; let title: string; if (section) { // Expand specific section if (!expandableContent.sections[section]) { const availableSections = Object.keys(expandableContent.sections).join(', '); throw new McpAdrError( `Section "${section}" not found. Available sections: ${availableSections}`, 'INVALID_INPUT' ); } outputContent = expandableContent.sections[section]; title = `${expandableContent.metadata.toolName} - ${section}`; } else { // Expand full analysis outputContent = expandableContent.content; title = `${expandableContent.metadata.toolName} - Full Analysis`; } // Format output if (format === 'json') { return { content: [ { type: 'text', text: JSON.stringify( { expandableId, section: section || 'full', metadata: expandableContent.metadata, content: outputContent, }, null, 2 ), }, ], }; } // Markdown format (default) const formattedOutput = `# ${title} ## ๐Ÿ“‹ Analysis Details **Tool:** ${expandableContent.metadata.toolName} **Generated:** ${new Date(expandableContent.metadata.timestamp).toLocaleString()} **Token Count:** ~${expandableContent.metadata.tokenCount} tokens **Expandable ID:** \`${expandableId}\` ${section ? `**Section:** ${section}` : '**Scope:** Complete Analysis'} --- ## ๐Ÿ“– Content ${outputContent} --- ## ๐Ÿ”„ Related Actions ${ !section && Object.keys(expandableContent.sections).length > 0 ? ` ### Available Sections You can expand specific sections for focused analysis: ${Object.keys(expandableContent.sections) .map( s => `- **${s}**: \`expand_analysis_section\` with \`expandableId: "${expandableId}", section: "${s}"\`` ) .join('\n')} ` : '' } ### Tool Arguments Used \`\`\`json ${JSON.stringify(expandableContent.metadata.toolArgs || {}, null, 2)} \`\`\` ๐Ÿ’ก **Tip:** You can reference this analysis using expandable ID \`${expandableId}\` in future conversations. `; return { content: [{ type: 'text', text: formattedOutput }], }; } catch (error) { if (error instanceof McpAdrError) { throw error; } throw new McpAdrError( `Failed to expand analysis: ${error instanceof Error ? error.message : String(error)}`, 'EXPANSION_ERROR' ); } }

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