Skip to main content
Glama

expand_analysis_section

Retrieve complete architectural decision analysis content from tiered responses. Expand entire analysis or specific sections stored in memory when a tool returns a summary with an expandable ID.

Instructions

Retrieve full analysis content from tiered responses. Expand entire analysis or specific sections stored in memory. Use this when a tool returns a summary with an expandable ID.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
expandableIdYesID of the expandable analysis (provided in tiered response)
sectionNoOptional: Specific section to expand (omit to get full analysis). Available sections are listed in the tiered response.
formatNoOutput format (default: markdown)markdown

Implementation Reference

  • The main handler function that executes the tool logic: retrieves expandable analysis content from tiered response manager, handles full or section expansion, formats output in markdown or 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'
        );
      }
    }
  • TypeScript interface defining the input parameters for the expandAnalysisSection handler.
    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';
    }
  • Registration of the tool in the central TOOL_CATALOG with metadata, category, estimated costs, and JSON input schema for MCP tool discovery.
    TOOL_CATALOG.set('expand_analysis_section', {
      name: 'expand_analysis_section',
      shortDescription: 'Expand analysis section',
      fullDescription: 'Expands a specific section of analysis with more detail.',
      category: 'memory',
      complexity: 'moderate',
      tokenCost: { min: 1500, max: 3000 },
      hasCEMCPDirective: true, // Phase 4.3: Moderate tool - section expansion
      relatedTools: ['analyze_project_ecosystem', 'memory_loading'],
      keywords: ['expand', 'analysis', 'section', 'detail'],
      requiresAI: true,
      inputSchema: {
        type: 'object',
        properties: {
          sectionId: { type: 'string' },
          depth: { type: 'string', enum: ['summary', 'detailed', 'comprehensive'] },
        },
        required: ['sectionId'],
      },
    });
  • Usage in TieredResponseManager's formatTieredResponse method, which generates instructions referencing the expand_analysis_section tool.
        'šŸ’” **To view full analysis:** Use `expand_analysis_section` tool with `expandableId: "' +
          response.expandableId +
          '"`'
      );
    
      return parts.join('\n');
    }
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 mentions retrieving content 'stored in memory' which hints at data source, but doesn't describe important behavioral aspects: whether this is a read-only operation, potential rate limits, authentication requirements, error conditions, or what happens if the expandableId doesn't exist. For a retrieval tool with zero annotation coverage, this leaves significant gaps in understanding its behavior.

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 efficiently structured in two sentences: the first states what the tool does, the second provides usage guidance. Every word serves a purpose with zero waste. It's appropriately sized for the tool's complexity and gets straight to the point without unnecessary elaboration.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (3 parameters, no output schema, no annotations), the description provides adequate but incomplete context. It explains the basic purpose and triggering condition well, but lacks information about return values, error handling, and behavioral constraints. Without annotations or output schema, the agent must infer too much about how this tool actually behaves in practice.

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, so parameters are well-documented in the structured fields. The description adds some context by mentioning that sections are 'listed in the tiered response' and that omitting section returns 'full analysis,' but these are essentially restatements of what the schema descriptions imply. The description doesn't provide additional syntax examples, constraints, or usage patterns beyond what the schema already covers.

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 ('Retrieve', 'Expand') and resource ('full analysis content', 'specific sections'), making the purpose understandable. However, it doesn't explicitly differentiate this tool from sibling tools like 'expand_memory' or 'get_conversation_snapshot', which might also retrieve stored content. The description is specific about working with 'tiered responses' and 'expandable IDs', but lacks sibling comparison.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context on when to use this tool: 'when a tool returns a summary with an expandable ID.' This gives practical guidance for triggering usage. However, it doesn't mention when NOT to use it or explicitly name alternative tools for similar retrieval operations, which prevents a perfect score.

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

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