create_documentation
Generate project documentation for Node.js projects, including READMEs, API references, or component details, using specified directory paths and documentation types with the Node Omnibus MCP Server tool.
Instructions
Generate project documentation
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | No | Component or API name for specific documentation | |
| path | Yes | Project directory path | |
| type | Yes | Documentation type |
Implementation Reference
- src/index.ts:992-1037 (handler)Main handler function for the 'create_documentation' tool. Validates path, generates content based on type ('readme', 'api', 'component'), writes to appropriate MD file, stores in memory, and returns success message.private async handleCreateDocumentation(args: CreateDocumentationArgs) { await this.validatePath(args.path); try { let content = ''; let fileName = ''; switch (args.type) { case 'readme': content = await this.generateProjectDocumentation(args.path); fileName = 'README.md'; break; case 'api': content = await this.generateApiDocumentation(args.path); fileName = 'API.md'; break; case 'component': if (!args.name) { throw new McpError(ErrorCode.InvalidParams, 'Component name is required for component documentation'); } content = await this.generateComponentDoc(args.path, args.name); fileName = `${args.name}.md`; break; } const docPath = path.join(args.path, fileName); await fs.writeFile(docPath, content); // Store in memory for resource access this.projectDocs.set(path.basename(args.path), content); return { content: [ { type: 'text', text: `Documentation created successfully at ${docPath}`, }, ], }; } catch (error) { throw new McpError( ErrorCode.InternalError, `Failed to create documentation: ${error instanceof Error ? error.message : String(error)}` ); } }
- src/index.ts:66-70 (schema)TypeScript interface defining the input arguments for the create_documentation tool.interface CreateDocumentationArgs extends Record<string, unknown> { path: string; type: 'readme' | 'api' | 'component'; name?: string; }
- src/index.ts:365-387 (registration)Tool registration in the ListTools response, including name, description, and JSON inputSchema.{ name: 'create_documentation', description: 'Generate project documentation', inputSchema: { type: 'object', properties: { path: { type: 'string', description: 'Project directory path', }, type: { type: 'string', enum: ['readme', 'api', 'component'], description: 'Documentation type', }, name: { type: 'string', description: 'Component or API name for specific documentation', }, }, required: ['path', 'type'], }, },
- src/index.ts:407-408 (registration)Switch case in CallToolRequest handler that dispatches to the create_documentation handler.case 'create_documentation': return await this.handleCreateDocumentation(args as CreateDocumentationArgs);
- src/index.ts:1039-1069 (helper)Helper function to generate README-style project documentation from package.json.private async generateProjectDocumentation(projectPath: string): Promise<string> { const packageJson = JSON.parse( await fs.readFile(path.join(projectPath, 'package.json'), 'utf-8') ); return `# ${packageJson.name} ## Description ${packageJson.description || 'A Node.js project'} ## Installation \`\`\`bash npm install \`\`\` ## Scripts ${Object.entries(packageJson.scripts || {}) .map(([name, command]) => `- \`npm run ${name}\`: ${command}`) .join('\n')} ## Dependencies ${Object.entries(packageJson.dependencies || {}) .map(([name, version]) => `- \`${name}\`: ${version}`) .join('\n')} ## Dev Dependencies ${Object.entries(packageJson.devDependencies || {}) .map(([name, version]) => `- \`${name}\`: ${version}`) .join('\n')} `; }