Skip to main content
Glama

update_existing_documentation

Identify and update outdated or inaccurate documentation by comparing code and existing docs, with options to control aggressiveness and focus areas.

Instructions

Intelligently analyze and update existing documentation using memory insights and code comparison

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
analysisIdYesRepository analysis ID from analyze_repository tool
docsPathYesPath to existing documentation directory
compareModeNoMode of comparison between code and documentationcomprehensive
updateStrategyNoHow aggressively to suggest updatesmoderate
preserveStyleNoPreserve existing documentation style and formatting
focusAreasNoSpecific areas to focus updates on (e.g., "dependencies", "scripts", "api")

Implementation Reference

  • Core handler method 'updateExistingDocumentation' on the DocumentationUpdateEngine class. Orchestrates the update process: loads repository analysis & memory insights, analyzes existing docs, performs code-doc comparison, generates recommendations, calculates metrics, and returns the UpdateResult.
    async updateExistingDocumentation(
      options: UpdateOptions,
    ): Promise<UpdateResult> {
      // 1. Load repository analysis and memory insights
      const analysis = await this.getRepositoryAnalysis(options.analysisId);
      this.codeAnalysis = analysis;
    
      // 2. Load memory insights for intelligent comparison
      await this.loadMemoryInsights(analysis, options);
    
      // 3. Analyze existing documentation structure and content
      const existingDocs = await this.analyzeExistingDocumentation(
        options.docsPath,
      );
      this.existingDocs = existingDocs;
    
      // 4. Perform comprehensive code-documentation comparison
      const comparison = await this.performCodeDocumentationComparison(
        analysis,
        existingDocs,
        options,
      );
    
      // 5. Generate memory-informed update recommendations
      const recommendations = await this.generateUpdateRecommendations(
        comparison,
        options,
      );
    
      // 6. Calculate metrics and confidence scores
      const updateMetrics = this.calculateUpdateMetrics(
        comparison,
        recommendations,
      );
    
      return {
        success: true,
        analysisPerformed: comparison,
        recommendations,
        memoryInsights: this.memoryInsights,
        updateMetrics,
        nextSteps: this.generateMemoryInformedNextSteps(
          comparison,
          recommendations,
        ),
      };
    }
  • Exported async function 'handleUpdateExistingDocumentation' that instantiates DocumentationUpdateEngine and calls its updateExistingDocumentation method.
    export async function handleUpdateExistingDocumentation(
      args: any,
    ): Promise<UpdateResult> {
      const engine = new DocumentationUpdateEngine();
      return await engine.updateExistingDocumentation(args);
    }
  • Tool definition export 'updateExistingDocumentation' of type Tool from MCP SDK, with name 'update_existing_documentation', description, and inputSchema (analysisId, docsPath, compareMode, updateStrategy, preserveStyle, focusAreas).
    export const updateExistingDocumentation: Tool = {
      name: "update_existing_documentation",
      description:
        "Intelligently analyze and update existing documentation using memory insights and code comparison",
      inputSchema: {
        type: "object",
        properties: {
          analysisId: {
            type: "string",
            description: "Repository analysis ID from analyze_repository tool",
          },
          docsPath: {
            type: "string",
            description: "Path to existing documentation directory",
          },
          compareMode: {
            type: "string",
            enum: ["comprehensive", "gap-detection", "accuracy-check"],
            default: "comprehensive",
            description: "Mode of comparison between code and documentation",
          },
          updateStrategy: {
            type: "string",
            enum: ["conservative", "moderate", "aggressive"],
            default: "moderate",
            description: "How aggressively to suggest updates",
          },
          preserveStyle: {
            type: "boolean",
            default: true,
            description: "Preserve existing documentation style and formatting",
          },
          focusAreas: {
            type: "array",
            items: { type: "string" },
            description:
              'Specific areas to focus updates on (e.g., "dependencies", "scripts", "api")',
          },
        },
        required: ["analysisId", "docsPath"],
      },
    };
  • Tool metadata registration for 'update_existing_documentation' in the tool-metadata lookup, categorizing it as 'optimization' with complexity 'complex', dependencies on 'analyze_repository', and large-result return indicator.
    update_existing_documentation: {
      category: "optimization",
      complexity: "complex",
      estimatedTokens: 460,
      suggestedUse:
        "Intelligently update existing documentation with memory insights",
      typicalExecutionMs: 2500,
      returnsLargeResults: true,
      dependencies: ["analyze_repository"],
      parallelizable: false,
    },
  • Private helper 'loadMemoryInsights' that loads similar projects, update patterns, enhanced analysis, and enhanced recommendations from the memory system to inform documentation updates.
    private async loadMemoryInsights(
      analysis: any,
      options: UpdateOptions,
    ): Promise<void> {
      try {
        // Get similar projects that had successful documentation updates
        const similarProjectsQuery = `${
          analysis.metadata?.primaryLanguage || ""
        } ${analysis.metadata?.ecosystem || ""} documentation update`;
        const similarProjects = await handleMemoryRecall({
          query: similarProjectsQuery,
          type: "recommendation",
          limit: 10,
        });
    
        // Get patterns for successful documentation updates
        const updatePatternsQuery =
          "documentation update successful patterns gaps outdated";
        const updatePatterns = await handleMemoryRecall({
          query: updatePatternsQuery,
          type: "configuration",
          limit: 5,
        });
    
        // Get memory-enhanced analysis for this specific update task
        const enhancedAnalysis = await handleMemoryIntelligentAnalysis({
          projectPath: analysis.projectPath || "",
          baseAnalysis: analysis,
        });
    
        // Get memory-enhanced recommendations for update strategy
        const enhancedRecommendations = await handleMemoryEnhancedRecommendation({
          projectPath: analysis.projectPath || "",
          baseRecommendation: {
            updateStrategy: options.updateStrategy,
            compareMode: options.compareMode,
            focusAreas: options.focusAreas || [],
          },
          projectFeatures: {
            ecosystem: analysis.metadata?.ecosystem || "unknown",
            primaryLanguage: analysis.metadata?.primaryLanguage || "unknown",
            complexity: analysis.complexity || "medium",
            hasTests: analysis.structure?.hasTests || false,
            hasCI: analysis.structure?.hasCI || false,
            docStructure: "existing", // Indicates we're updating existing docs
          },
        });
    
        this.memoryInsights = {
          similarProjects: similarProjects.memories || [],
          updatePatterns: updatePatterns.memories || [],
          enhancedAnalysis: enhancedAnalysis,
          enhancedRecommendations: enhancedRecommendations,
          successfulUpdatePatterns: this.extractUpdatePatterns(
            similarProjects.memories || [],
          ),
          commonGapTypes: this.extractCommonGapTypes(
            similarProjects.memories || [],
          ),
        };
Behavior2/5

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

No annotations are provided, so the description must fully disclose behavior. It only mentions 'analyze and update' but does not explain side effects (e.g., file modification vs suggestion), error states, or idempotency. Lacks behavioral detail.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Single, clear sentence that conveys core function. Could be improved by listing key parameters, but it is appropriately concise without verbosity.

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?

Tool is moderately complex with 6 parameters, enums, and no output schema. The description lacks explanation of return values, success criteria, or potential side effects. Additional context on workflow would improve completeness.

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 covers 100% of parameters with descriptions. The description adds high-level context ('memory insights and code comparison') but does not provide additional meaning per parameter beyond what schema offers. Baseline 3 is appropriate.

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 updates documentation using memory and code comparison, but it does not differentiate from siblings like 'sync_code_to_docs' or 'detect_documentation_gaps'. The verb 'analyze and update' and resource 'existing documentation' are specific.

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?

No guidance on when to use this tool versus alternatives. Does not mention prerequisites, exclusions, or context for selection among many documentation tools.

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/documcp'

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