Skip to main content
Glama

discover_existing_adrs

Find and catalog existing architectural decision records in your project directory to maintain documentation integrity.

Instructions

Discover and catalog existing ADRs in the project

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
adrDirectoryNoDirectory to search for ADRsdocs/adrs
includeContentNoWhether to include ADR content in analysis

Implementation Reference

  • The main handler function for the 'discover_existing_adrs' MCP tool. It initializes the .mcp-adr-cache infrastructure, scans the ADR directory for existing ADRs using discoverAdrsInDirectory helper, formats a comprehensive MCP response with ADR catalog, statistics, recommendations, and example next-step commands.
    export async function discoverExistingAdrs(args: {
      adrDirectory?: string;
      includeContent?: boolean;
      projectPath?: string;
    }): Promise<any> {
      const { adrDirectory = 'docs/adrs', includeContent = false, projectPath = process.cwd() } = args;
    
      try {
        // INITIALIZE COMPLETE CACHE INFRASTRUCTURE (since this is typically the first command)
        // NOTE: All console output goes to stderr to preserve stdout for MCP JSON-RPC
        console.error('[ADR-Suggestion] Initializing complete cache infrastructure...');
    
        // 1. TodoJsonManager removed - use mcp-shrimp-task-manager for task management
        console.error(
          '[ADR-Suggestion] TodoJsonManager is deprecated and was removed in memory-centric transformation'
        );
        // Skip todo initialization - TodoJsonManager removed
        console.error('[ADR-Suggestion] Initialized todo-data.json and cache directory');
    
        // 2. ProjectHealthScoring removed - use relationship-based importance instead
        console.error(
          '[ADR-Suggestion] ProjectHealthScoring is deprecated and was removed in memory-centric transformation'
        );
        // Skip health scoring initialization - ProjectHealthScoring removed
        console.error('[ADR-Suggestion] Initialized project-health-scores.json');
    
        // 3. Initialize KnowledgeGraphManager (creates knowledge-graph-snapshots.json and todo-sync-state.json)
        // Set PROJECT_PATH temporarily for proper initialization
        const originalConfig = process.env['PROJECT_PATH'];
        process.env['PROJECT_PATH'] = projectPath;
    
        const { KnowledgeGraphManager } = await import('../utils/knowledge-graph-manager.js');
        const kgManager = new KnowledgeGraphManager();
        await kgManager.loadKnowledgeGraph(); // Creates knowledge-graph-snapshots.json and todo-sync-state.json
        console.error(
          '[ADR-Suggestion] Initialized knowledge-graph-snapshots.json and todo-sync-state.json'
        );
    
        // Restore original config
        if (originalConfig !== undefined) {
          process.env['PROJECT_PATH'] = originalConfig;
        } else {
          delete process.env['PROJECT_PATH'];
        }
    
        console.error('[ADR-Suggestion] Complete cache infrastructure ready!');
    
        // Use the new ADR discovery utility
        const { discoverAdrsInDirectory } = await import('../utils/adr-discovery.js');
    
        const discoveryResult = await discoverAdrsInDirectory(adrDirectory, projectPath, {
          includeContent,
          includeTimeline: false,
        });
    
        // Format the results for MCP response
        return {
          content: [
            {
              type: 'text',
              text: `# šŸŽÆ Complete ADR Discovery & Cache Infrastructure Initialized
    
    ## Cache Infrastructure Status
    āœ… **todo-data.json** - JSON-first TODO system initialized  
    āœ… **project-health-scores.json** - Multi-component project health scoring  
    āœ… **knowledge-graph-snapshots.json** - Knowledge graph system & intent tracking  
    āœ… **todo-sync-state.json** - TODO synchronization state  
    āœ… **Cache Directory** - Complete infrastructure ready at \`.mcp-adr-cache/\`
    
    ## ADR Discovery Results
    
    ### Discovery Summary
    - **Directory**: ${discoveryResult.directory}
    - **Total ADRs Found**: ${discoveryResult.totalAdrs}
    - **Include Content**: ${includeContent ? 'Yes' : 'No (metadata only)'}
    
    ## Discovered ADRs
    
    ${
      discoveryResult.adrs.length > 0
        ? discoveryResult.adrs
            .map(
              adr => `
    ### ${adr.title}
    - **File**: ${adr.filename}
    - **Status**: ${adr.status}
    - **Date**: ${adr.date || 'Not specified'}
    - **Path**: ${adr.path}
    ${adr.metadata?.number ? `- **Number**: ${adr.metadata.number}` : ''}
    ${adr.metadata?.category ? `- **Category**: ${adr.metadata.category}` : ''}
    ${adr.metadata?.tags?.length ? `- **Tags**: ${adr.metadata.tags.join(', ')}` : ''}
    ${
      includeContent && adr.content
        ? `
    
    #### Content Preview
    \`\`\`markdown
    ${adr.content.slice(0, 500)}${adr.content.length > 500 ? '...' : ''}
    \`\`\`
    `
        : ''
    }
    `
            )
            .join('\n')
        : 'No ADRs found in the specified directory.'
    }
    
    ## Summary Statistics
    
    ### By Status
    ${
      Object.entries(discoveryResult.summary.byStatus)
        .map(([status, count]) => `- **${status}**: ${count}`)
        .join('\n') || 'No status information available'
    }
    
    ### By Category
    ${
      Object.entries(discoveryResult.summary.byCategory)
        .map(([category, count]) => `- **${category}**: ${count}`)
        .join('\n') || 'No category information available'
    }
    
    ## Recommendations
    
    ${discoveryResult.recommendations.map(rec => `- ${rec}`).join('\n')}
    
    ## Next Steps
    
    Based on the discovered ADRs, you can:
    
    1. **Analyze for Missing Decisions**: Use the \`suggest_adrs\` tool with the discovered ADR titles
    2. **Generate Implementation TODOs**: Use the \`generate_adr_todo\` tool
    3. **Create New ADRs**: Use the \`generate_adr_from_decision\` tool for new decisions
    
    ### Example Commands
    
    To suggest new ADRs based on discovered ones:
    \`\`\`json
    {
      "tool": "suggest_adrs",
      "args": {
        "existingAdrs": ${JSON.stringify(discoveryResult.adrs.map(adr => adr.title))},
        "analysisType": "comprehensive"
      }
    }
    \`\`\`
    
    To generate a todo list from discovered ADRs:
    \`\`\`json
    {
      "tool": "generate_adr_todo",
      "args": {
        "adrDirectory": "${adrDirectory}",
        "scope": "all"
      }
    }
    \`\`\`
    
    ## Raw Discovery Data
    
    For programmatic use, the raw discovery data is:
    
    \`\`\`json
    ${JSON.stringify(discoveryResult, null, 2)}
    \`\`\`
    `,
            },
          ],
        };
      } catch (error) {
        throw new McpAdrError(
          `Failed to discover ADRs: ${error instanceof Error ? error.message : String(error)}`,
          'DISCOVERY_ERROR'
        );
      }
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden for behavioral disclosure. It mentions 'discover and catalog' but doesn't specify what 'catalog' entails (e.g., returns a list, creates metadata, or modifies data), whether it's read-only or has side effects, or any performance considerations like rate limits. This leaves significant gaps for an agent to understand the tool's 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 a single, efficient sentence that directly states the tool's purpose without unnecessary words. It's front-loaded with the core action and resource, making it easy to parse quickly, and every part of the sentence contributes meaningfully.

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 (2 parameters, no output schema, no annotations), the description is minimally adequate but lacks completeness. It states what the tool does but misses behavioral details (e.g., output format, side effects) and usage context relative to siblings, which are important for an agent to use it effectively without trial and error.

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?

Schema description coverage is 100%, with both parameters ('adrDirectory', 'includeContent') well-documented in the input schema. The description adds no additional parameter information beyond what the schema provides, so it meets the baseline score of 3 for high schema coverage without compensating value.

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 tool's purpose with specific verbs ('discover and catalog') and resource ('existing ADRs in the project'), making it easy to understand what the tool does. However, it doesn't explicitly differentiate from sibling tools like 'review_existing_adrs' or 'validate_all_adrs', which might have overlapping functionality.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. With multiple sibling tools related to ADRs (e.g., 'review_existing_adrs', 'validate_all_adrs', 'analyze_adr_timeline'), there's no indication of context, prerequisites, or exclusions for choosing this tool over others.

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