Skip to main content
Glama

Generate Documentation

generate-docs

Create documentation in multiple formats like markdown, API docs, and README files for tasks including code comments and setup instructions using AI providers.

Instructions

Generate documentation in various formats

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
taskYesWhat to document (e.g., 'API endpoints', 'setup instructions', 'code comments')
filesNoFile paths to document (optional)
formatNoDocumentation formatmarkdown
providerNoAI provider to usegemini

Implementation Reference

  • Main handler function that executes the generate-docs tool by calling an AI provider to generate documentation based on task, files, and format.
    async handleGenerateDocs(params: z.infer<typeof GenerateDocsSchema>) {
      // Use provided provider or get the preferred one (Azure if configured)
      const providerName = params.provider || (await this.providerManager.getPreferredProvider(['openai', 'gemini', 'azure', 'grok']));
      const provider = await this.providerManager.getProvider(providerName);
      
      const formatPrompts = {
        markdown: "Generate documentation in markdown format with proper structure and formatting",
        comments: "Generate inline code comments and docstrings for the specified code",
        "api-docs": "Generate API documentation with endpoints, parameters, responses, and examples",
        readme: "Generate README documentation with setup, usage, and project information"
      };
    
      const systemPrompt = `You are an expert technical writer and documentation specialist.
      ${formatPrompts[params.format]}
      
      Create comprehensive documentation that:
      - Is clear and easy to understand
      - Follows proper formatting and structure
      - Includes relevant examples and usage
      - Covers all important aspects
      - Is practical and actionable
      
      Ensure documentation is professional and user-friendly.`;
    
      let prompt = `Generate documentation for: ${params.task}`;
      if (params.files) {
        prompt += `\n\nFiles to document: ${params.files.join(", ")}`;
      }
    
      const response = await provider.generateText({
        prompt,
        systemPrompt,
        temperature: 0.5, // Balanced temperature for documentation clarity
        useSearchGrounding: providerName === "gemini",
      });
    
      return {
        content: [
          {
            type: "text",
            text: response.text,
          },
        ],
        metadata: {
          provider: providerName,
          model: response.model,
          format: params.format,
          usage: response.usage,
          ...response.metadata,
        },
      };
    }
  • Zod input schema defining parameters for the generate-docs tool: task, files, format, and provider.
    const GenerateDocsSchema = z.object({
      task: z.string().describe("What to document (e.g., 'API endpoints', 'setup instructions', 'code comments')"),
      files: z.array(z.string()).optional().describe("File paths to document (optional)"),
      format: z.enum(["markdown", "comments", "api-docs", "readme"]).default("markdown").describe("Documentation format"),
      provider: z.enum(["openai", "gemini", "azure", "grok"]).optional().default("gemini").describe("AI provider to use"),
    });
  • src/server.ts:324-332 (registration)
    MCP server registration of the generate-docs tool, linking schema and handler implementation.
    // Register generate-docs tool
    server.registerTool("generate-docs", {
      title: "Generate Documentation",
      description: "Generate documentation in various formats",
      inputSchema: GenerateDocsSchema.shape,
    }, async (args) => {
      const aiHandlers = await getHandlers();
      return await aiHandlers.handleGenerateDocs(args);
    });
Behavior2/5

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

With no annotations provided, the description carries full burden but offers minimal behavioral insight. It mentions 'various formats' but doesn't disclose whether this is a read-only operation, if it modifies files, what permissions are needed, rate limits, or what the output looks like. For a tool with 4 parameters and no annotations, this is inadequate disclosure.

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?

Extremely concise single sentence with zero wasted words. The description is front-loaded and efficiently communicates the core function without unnecessary elaboration.

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?

For a 4-parameter tool with no annotations and no output schema, the description is insufficiently complete. It doesn't explain what the tool actually produces, how it interacts with files, whether it's a generation or analysis tool, or how it differs from similar documentation-related siblings. The agent lacks critical context for proper tool selection and invocation.

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%, so the schema fully documents all 4 parameters. The description adds no additional parameter semantics beyond implying format variety through 'various formats'. This meets the baseline of 3 when schema coverage is complete.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'Generate documentation in various formats' states a general purpose but lacks specificity about what resources are documented or how it differs from siblings like 'ultra-docs'. It mentions 'various formats' which provides some scope, but doesn't specify the verb's target beyond 'documentation'.

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 like 'ultra-docs' or 'review-code'. The description provides no context about appropriate use cases, prerequisites, or exclusions. The agent must infer usage solely from the tool name and parameters.

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/RealMikeChong/ultra-mcp'

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