Skip to main content
Glama
Njengah
by Njengah

generate_documentation

Create comprehensive markdown documentation for codebases or files, detailing code elements and existing documentation to improve project understanding.

Instructions

Generate comprehensive markdown documentation for a codebase or file, including all code elements and their existing documentation.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathNoPath to file or directory to document
formatNoOutput format for documentation

Implementation Reference

  • Main tool handler function that analyzes the specified path, generates analysis results, uses MarkdownGenerator to create documentation, and returns success/error with stats.
    export async function generateDocumentation(input: GenerateDocumentationInput) {
      try {
        const analyzer = new CodebaseAnalyzer();
        const results = await analyzer.analyzePath(input.path);
    
        if (results.length === 0) {
          return {
            success: false,
            error: 'No supported source files found in the specified path'
          };
        }
    
        const generator = new MarkdownGenerator();
        const documentation = generator.generateDocumentation(results);
    
        return {
          success: true,
          documentation,
          stats: {
            filesProcessed: results.length,
            totalElements: results.reduce((sum, r) => sum + r.totalElements, 0),
            documentationCoverage: (results.reduce((sum, r) => sum + r.documentationCoverage, 0) / results.length).toFixed(2) + '%'
          }
        };
      } catch (error) {
        return {
          success: false,
          error: (error as Error).message
        };
      }
    }
  • Zod schema defining the input for the generate_documentation tool: path (required) and format (markdown default).
    export const GenerateDocumentationSchema = z.object({
      path: z.string().describe('Path to file or directory to document'),
      format: z.enum(['markdown']).default('markdown').describe('Output format for documentation')
    });
  • src/index.ts:52-56 (registration)
    Tool registration in the TOOLS array, specifying name, description, and input schema.
    {
      name: 'generate_documentation',
      description: 'Generate comprehensive markdown documentation for a codebase or file, including all code elements and their existing documentation.',
      inputSchema: GenerateDocumentationSchema
    },
  • src/index.ts:108-119 (registration)
    Dispatch handler in the MCP server that validates input, calls the generateDocumentation function, and formats the response as MCP content.
    case 'generate_documentation': {
      const validated = GenerateDocumentationSchema.parse(args);
      const result = await generateDocumentation(validated);
      return {
        content: [
          {
            type: 'text',
            text: result.success ? result.documentation : JSON.stringify(result, null, 2)
          }
        ]
      };
    }
  • Core helper method in MarkdownGenerator that orchestrates the creation of markdown documentation from analysis results, including summary and per-file sections.
    generateDocumentation(results: AnalysisResult[]): string {
      const sections: string[] = [];
    
      sections.push('# Codebase Documentation\n');
      sections.push(this.generateSummary(results));
      
      for (const result of results) {
        sections.push(this.generateFileDocumentation(result));
      }
    
      return sections.join('\n\n');
    }
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool generates documentation but doesn't cover critical aspects like whether it's read-only or destructive, permission requirements, rate limits, output handling, or error conditions. This leaves significant gaps for an agent to understand how to invoke it safely and effectively.

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, well-structured sentence that efficiently conveys the core functionality without unnecessary details. It's front-loaded with the main purpose and avoids redundancy, making it easy for an agent to parse quickly.

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

Completeness2/5

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

Given the lack of annotations and output schema, the description is incomplete. It doesn't address behavioral traits, return values, or error handling, which are crucial for a tool that processes codebases. While concise, it fails to provide enough context for reliable agent use beyond the basic purpose.

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 description adds no parameter-specific information beyond what's in the schema, which has 100% coverage for its two parameters ('path' and 'format'). The baseline is 3 because the schema adequately documents the parameters, but the description doesn't enhance understanding with examples, constraints, or usage notes.

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: 'Generate comprehensive markdown documentation for a codebase or file, including all code elements and their existing documentation.' It specifies the verb ('generate'), resource ('markdown documentation'), and scope ('codebase or file'), though it doesn't explicitly differentiate from sibling tools like 'analyze_codebase' or 'detect_missing_docs'.

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 is provided on when to use this tool versus alternatives. The description doesn't mention sibling tools like 'detect_missing_docs' or 'suggest_improvements', nor does it specify prerequisites, constraints, or typical use cases for documentation generation.

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/Njengah/claude-4.5-mcp-tutorial'

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