Skip to main content
Glama

Ultra Docs

ultra-docs

Generate comprehensive documentation with step-by-step workflows for APIs, setup instructions, and code files using multiple AI providers.

Instructions

Generate comprehensive documentation with step-by-step workflow

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
taskYesWhat to document (e.g., "API endpoints", "setup instructions")
filesNoFile paths to document (optional)
formatNoDocumentation formatmarkdown
providerNoAI provider to use
modelNoSpecific model to use
stepNumberNoCurrent step in the documentation workflow
totalStepsNoEstimated total steps needed
findingsNoAccumulated documentation content
nextStepRequiredNoWhether another step is needed
includeExamplesNoInclude code examples in documentation
includeTypesNoInclude type information for TypeScript/Flow

Implementation Reference

  • Main execution logic for the 'ultra-docs' tool. Handles multi-step documentation generation workflow: parses input with DocsSchema, selects AI provider, constructs step-specific prompts based on step number, generates documentation text using the provider, formats the response with workflow metadata, and supports continuation across steps.
      async handleDocs(args: unknown): Promise<HandlerResponse> {
        const params = DocsSchema.parse(args);
        const { provider: requestedProvider, model: requestedModel, stepNumber, totalSteps, nextStepRequired, task, files, format, findings, includeExamples, includeTypes } = params;
        
        const config = await this.configManager.getConfig();
        const providerName = requestedProvider || await this.providerManager.getPreferredProvider();
        const provider = await this.providerManager.getProvider(providerName);
        
        if (!provider) {
          throw new Error('No AI provider configured. Please run: bunx ultra-mcp config');
        }
    
        try {
          let context = '';
          let requiredActions: string[] = [];
          
          if (stepNumber === 1) {
            const formatInstructions = {
              markdown: 'Use clear Markdown formatting with headers, lists, and code blocks',
              comments: 'Generate inline code comments following language conventions',
              'api-docs': 'Create API documentation with endpoints, parameters, and responses',
              readme: 'Write a comprehensive README with setup, usage, and examples',
              jsdoc: 'Generate JSDoc comments for functions and classes',
            };
            
            context = `You are generating ${format} documentation.
            
    Task: ${task}
    ${files ? `Files to document: ${files.join(', ')}` : ''}
    
    Requirements:
    - ${formatInstructions[format]}
    - ${includeExamples ? 'Include practical code examples' : 'Focus on descriptions without examples'}
    - ${includeTypes ? 'Include type information and signatures' : 'Omit type details'}
    
    Begin by:
    1. Understanding what needs to be documented
    2. Analyzing the code structure and purpose
    3. Planning the documentation structure`;
    
            requiredActions = [
              'Analyze the code or system to document',
              'Understand the target audience',
              'Plan documentation structure and sections',
              'Identify key concepts to explain',
              'Gather examples if needed',
            ];
          } else {
            context = `Complete the documentation based on your analysis:
    
    ${findings}
    
    Finalize by:
    - Ensuring completeness and accuracy
    - Adding examples and use cases
    - Checking formatting and readability
    - Including any necessary warnings or notes`;
    
            requiredActions = [
              'Review documentation for completeness',
              'Add missing sections or details',
              'Ensure examples are working and clear',
              'Check for consistency in style',
              'Add helpful notes and tips',
            ];
          }
    
          const prompt = `${context}\n\nGenerate documentation for step ${stepNumber} of ${totalSteps}.`;
          
          const fullResponse = await provider.generateText({
            prompt,
            model: requestedModel,
            temperature: 0.3,
            systemPrompt: `Generate high-quality ${format} documentation that is clear, accurate, and helpful.`,
            useSearchGrounding: false,
          });
    
          // TODO: Implement tracking
          // await trackUsage({
          //   tool: 'ultra-docs',
          //   model: provider.getActiveModel(),
          //   provider: provider.getName(),
          //   input_tokens: 0,
          //   output_tokens: 0,
          //   cache_tokens: 0,
          //   total_tokens: 0,
          //   has_credentials: true,
          // });
    
          const formattedResponse = formatWorkflowResponse(
            stepNumber,
            totalSteps,
            nextStepRequired,
            fullResponse.text,
            requiredActions
          );
    
          return {
            content: [{ type: 'text', text: formattedResponse }],
          };
        } catch (error) {
          logger.error('Documentation generation failed:', error);
          throw error;
        }
      }
  • Zod validation schema for 'ultra-docs' tool inputs, defining parameters like task, files, format (markdown/comments/etc.), provider/model, workflow steps (stepNumber, totalSteps, findings), and doc-specific options (includeExamples, includeTypes).
    // Documentation Tool Schema
    export const DocsSchema = z.object({
      task: z.string().describe('What to document (e.g., "API endpoints", "setup instructions")'),
      files: z.array(z.string()).optional().describe('File paths to document (optional)'),
      format: z.enum(['markdown', 'comments', 'api-docs', 'readme', 'jsdoc']).default('markdown')
        .describe('Documentation format'),
      provider: z.enum(['openai', 'gemini', 'azure', 'grok']).optional()
        .describe('AI provider to use'),
      model: z.string().optional().describe('Specific model to use'),
      
      // Workflow fields
      stepNumber: z.number().min(1).default(1).describe('Current step in the documentation workflow'),
      totalSteps: z.number().min(1).default(2).describe('Estimated total steps needed'),
      findings: z.string().default('').describe('Accumulated documentation content'),
      nextStepRequired: z.boolean().default(true).describe('Whether another step is needed'),
      
      // Doc-specific fields
      includeExamples: z.boolean().default(true).describe('Include code examples in documentation'),
      includeTypes: z.boolean().default(true).describe('Include type information for TypeScript/Flow'),
    });
  • src/server.ts:435-443 (registration)
    Registers the 'ultra-docs' MCP tool on the server, providing metadata (title, description), input schema from DocsSchema, and execution handler that dynamically imports and instantiates AdvancedToolsHandler to call handleDocs.
    server.registerTool("ultra-docs", {
      title: "Ultra Docs",
      description: "Generate comprehensive documentation with step-by-step workflow",
      inputSchema: DocsSchema.shape,
    }, async (args) => {
      const { AdvancedToolsHandler } = await import("./handlers/advanced-tools");
      const handler = new AdvancedToolsHandler();
      return await handler.handleDocs(args);
    });
  • Utility function used by all advanced tools (including ultra-docs) to format multi-step workflow responses with step headers, status, required actions list, and instructions for next step.
    function formatWorkflowResponse(
      stepNumber: number,
      totalSteps: number,
      nextStepRequired: boolean,
      content: string,
      requiredActions?: string[]
    ): string {
      const header = `## Step ${stepNumber} of ${totalSteps}`;
      const status = nextStepRequired 
        ? `\n**Status**: Investigation in progress - more analysis needed`
        : `\n**Status**: Investigation complete - ready for final analysis`;
      
      const actions = requiredActions && requiredActions.length > 0
        ? `\n\n### Required Actions Before Next Step:\n${requiredActions.map(a => `- ${a}`).join('\n')}`
        : '';
      
      const nextStep = nextStepRequired
        ? `\n\n**Next Step**: Call this tool again with step_number=${stepNumber + 1} after completing the required actions.`
        : '';
      
      return `${header}${status}\n\n${content}${actions}${nextStep}`;
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. While 'Generate comprehensive documentation' implies a creation/write operation, it doesn't specify whether this is a one-time generation or iterative process, what permissions might be required, whether it modifies existing files, or what happens to the 'findings' parameter. The 'step-by-step workflow' hint suggests iteration but lacks concrete behavioral details.

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?

The description is a single, efficient sentence that clearly states the core function. It's appropriately sized for a tool with this complexity level. While it could be more specific, there's no wasted language or unnecessary elaboration. The structure is straightforward and front-loaded with the main purpose.

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 complex tool with 11 parameters, no annotations, and no output schema, the description is insufficient. It doesn't explain the iterative nature implied by parameters like 'stepNumber', 'totalSteps', and 'findings', nor does it clarify the relationship between 'task' and 'files'. The description leaves too much behavioral ambiguity for a tool of this complexity with no structured safety or output information.

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 provides no parameter-specific information beyond the general purpose. However, with 100% schema description coverage, all 11 parameters are well-documented in the schema itself. The description doesn't add meaning beyond what the schema provides, but the schema does the heavy lifting, justifying the baseline score of 3.

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 states the tool 'Generate comprehensive documentation with step-by-step workflow' which provides a clear verb ('Generate') and resource ('documentation'), but it's somewhat vague about what specifically is being documented. It doesn't distinguish from sibling tools like 'generate-docs' or 'ultra-analyze' that might have overlapping functionality. The description is adequate but lacks specificity about scope and differentiation.

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 sibling tools like 'generate-docs', 'analyze-code', and 'research' available, there's no indication of what makes this tool distinct or when it should be preferred. The description implies a workflow approach but doesn't specify use cases or exclusions.

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