generate-docs
Create structured documentation in markdown, API-docs, comments, or readme formats for tasks like API endpoints or code comments using specified AI providers. Simplify documentation workflows with Ultra MCP server.
Instructions
Generate documentation in various formats
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| files | No | File paths to document (optional) | |
| format | No | Documentation format | markdown |
| provider | No | AI provider to use | gemini |
| task | Yes | What to document (e.g., 'API endpoints', 'setup instructions', 'code comments') |
Implementation Reference
- src/handlers/ai-tools.ts:503-554 (handler)The main handler function for the generate-docs tool. It selects a provider, constructs a specialized system prompt based on the requested documentation format, generates a prompt with task and files, calls the AI provider to generate the documentation, and returns the response with metadata.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, }, }; }
- src/handlers/ai-tools.ts:63-68 (schema)Zod schema defining the input parameters for the generate-docs tool: task (required), files (optional array), format (markdown/comments/api-docs/readme, default markdown), provider (openai/gemini/azure/grok, default gemini).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)Registration of the generate-docs tool with MCP server, including title, description, input schema, and handler that instantiates AIToolHandlers via getHandlers() and calls handleGenerateDocs.// 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); });