Package Exports
- @j0kz/doc-generator-mcp
- @j0kz/doc-generator-mcp/dist/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@j0kz/doc-generator-mcp) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Documentation Generator MCP
Automated documentation generation for TypeScript/JavaScript projects. This MCP (Model Context Protocol) server provides comprehensive tools for generating JSDoc comments, README files, API documentation, and changelogs from your source code.
Table of Contents
Features
- JSDoc Generation: Automatically generate JSDoc comments for functions, classes, and interfaces
- README Generation: Create comprehensive README files from project structure and package.json
- API Documentation: Generate detailed API reference documentation
- Changelog Generation: Create changelogs from git commit history using conventional commits
- TypeScript Support: First-class TypeScript support with type inference
- Multiple Formats: Output in Markdown, HTML, or JSON
- Configurable: Extensive configuration options for all documentation types
- MCP Integration: Full Model Context Protocol integration for AI assistants
Installation
As MCP Server
Add to your MCP settings (e.g., Claude Desktop):
{
"mcpServers": {
"doc-generator": {
"command": "npx",
"args": ["-y", "@my-claude-agents/doc-generator"]
}
}
}
As Library
npm install @my-claude-agents/doc-generator
Usage
As MCP Server
Once configured, the MCP server provides the following tools to AI assistants:
generate_jsdoc
- Generate JSDoc comments for source filesgenerate_readme
- Create README.md filesgenerate_api_docs
- Generate API documentationgenerate_changelog
- Create changelogs from git historygenerate_full_docs
- Generate all documentation at once
As Library
import {
generateJSDoc,
generateReadme,
generateApiDocs,
generateChangelog,
} from '@my-claude-agents/doc-generator';
// Generate JSDoc for a file
const jsdoc = await generateJSDoc('./src/utils.ts', {
style: 'typescript',
inferTypes: true,
addTodoTags: true,
});
console.log(jsdoc.content);
// Generate README
const readme = await generateReadme('./my-project', {
includeBadges: true,
includeInstallation: true,
includeUsage: true,
});
fs.writeFileSync('README.md', readme.content);
// Generate API documentation
const apiDocs = await generateApiDocs('./src', {
groupByCategory: true,
includeTypes: true,
includeInterfaces: true,
});
fs.writeFileSync('API.md', apiDocs.content);
// Generate changelog
const changelog = await generateChangelog('./', {
conventionalCommits: true,
groupByType: true,
includeAuthors: true,
});
fs.writeFileSync('CHANGELOG.md', changelog.content);
MCP Tools
generate_jsdoc
Generate JSDoc comments for TypeScript/JavaScript files.
Parameters:
filePath
(string, required) - Path to source fileconfig
(object, optional):style
('standard' | 'google' | 'typescript') - JSDoc styleaddTodoTags
(boolean) - Add @todo for missing docsinferTypes
(boolean) - Infer types from TypeScriptincludePrivate
(boolean) - Include private members
Example:
{
"filePath": "./src/utils.ts",
"config": {
"style": "typescript",
"addTodoTags": true,
"inferTypes": true
}
}
generate_readme
Generate comprehensive README.md files.
Parameters:
projectPath
(string, required) - Path to project rootconfig
(object, optional):projectName
(string) - Project nameversion
(string) - Version numberauthor
(string) - Author informationlicense
(string) - License typeincludeInstallation
(boolean) - Include installation sectionincludeUsage
(boolean) - Include usage examplesincludeAPI
(boolean) - Include API referenceincludeBadges
(boolean) - Include badgesincludeTOC
(boolean) - Include table of contents
Example:
{
"projectPath": "./my-project",
"config": {
"projectName": "My Awesome Library",
"version": "1.0.0",
"includeBadges": true,
"includeTOC": true
}
}
generate_api_docs
Generate detailed API documentation.
Parameters:
projectPath
(string, required) - Path to source directoryconfig
(object, optional):groupByCategory
(boolean) - Group by categoryincludeTypes
(boolean) - Include type definitionsincludeInterfaces
(boolean) - Include interfacessortAlphabetically
(boolean) - Sort alphabeticallyincludeSourceLinks
(boolean) - Link to source coderepositoryUrl
(string) - Repository URL for links
Example:
{
"projectPath": "./src",
"config": {
"groupByCategory": true,
"includeTypes": true,
"includeSourceLinks": true,
"repositoryUrl": "https://github.com/user/repo"
}
}
generate_changelog
Generate changelog from git history.
Parameters:
projectPath
(string, required) - Path to git repositoryconfig
(object, optional):commitLimit
(number) - Number of commits to includefromTag
(string) - Starting version tagtoTag
(string) - Ending version taggroupByType
(boolean) - Group by commit typeconventionalCommits
(boolean) - Parse conventional commitsincludeAuthors
(boolean) - Include commit authorslinkCommits
(boolean) - Link to commits
Example:
{
"projectPath": "./",
"config": {
"conventionalCommits": true,
"groupByType": true,
"commitLimit": 100,
"includeAuthors": true
}
}
generate_full_docs
Generate complete documentation suite.
Parameters:
projectPath
(string, required) - Project root pathsourceFiles
(string[], optional) - Files for JSDocconfig
(object, optional):projectName
(string) - Project nameversion
(string) - Versionauthor
(string) - Authorlicense
(string) - License typewriteFiles
(boolean) - Write to files (default: true)
Example:
{
"projectPath": "./my-project",
"sourceFiles": ["./src/index.ts", "./src/utils.ts"],
"config": {
"projectName": "My Library",
"version": "1.0.0",
"writeFiles": true
}
}
API Reference
Functions
generateJSDoc
async function generateJSDoc(
filePath: string,
config?: JSDocConfig
): Promise<DocResult>
Generate JSDoc comments for a source file.
Parameters:
filePath
- Path to the source fileconfig
- Optional JSDoc configuration
Returns: Promise resolving to DocResult with generated JSDoc content
Throws: DocError if file cannot be read or parsed
generateReadme
async function generateReadme(
projectPath: string,
config?: ReadmeConfig
): Promise<DocResult>
Generate README.md from source code and package.json.
Parameters:
projectPath
- Path to project root directoryconfig
- Optional README configuration
Returns: Promise resolving to DocResult with README content
Throws: DocError if project path is invalid
generateApiDocs
async function generateApiDocs(
projectPath: string,
config?: ApiDocsConfig
): Promise<DocResult>
Generate comprehensive API documentation.
Parameters:
projectPath
- Path to source directoryconfig
- Optional API docs configuration
Returns: Promise resolving to DocResult with API documentation
Throws: DocError if source directory is invalid
generateChangelog
async function generateChangelog(
projectPath: string,
config?: ChangelogConfig
): Promise<DocResult>
Generate changelog from git commit history.
Parameters:
projectPath
- Path to git repositoryconfig
- Optional changelog configuration
Returns: Promise resolving to DocResult with changelog content
Throws: DocError if not a git repository or git command fails
Configuration
JSDocConfig
interface JSDocConfig {
style?: 'standard' | 'google' | 'typescript';
addTodoTags?: boolean;
inferTypes?: boolean;
includePrivate?: boolean;
}
ReadmeConfig
interface ReadmeConfig {
projectName?: string;
version?: string;
author?: string;
license?: string;
includeInstallation?: boolean;
includeUsage?: boolean;
includeAPI?: boolean;
includeContributing?: boolean;
includeBadges?: boolean;
includeTOC?: boolean;
}
ApiDocsConfig
interface ApiDocsConfig {
groupByCategory?: boolean;
includeTypes?: boolean;
includeInterfaces?: boolean;
includeEnums?: boolean;
sortAlphabetically?: boolean;
includeSourceLinks?: boolean;
repositoryUrl?: string;
}
ChangelogConfig
interface ChangelogConfig {
commitLimit?: number;
fromTag?: string;
toTag?: string;
groupByType?: boolean;
includeMerges?: boolean;
conventionalCommits?: boolean;
includeAuthors?: boolean;
linkCommits?: boolean;
}
Examples
Complete Documentation Suite
import { generateJSDoc, generateReadme, generateApiDocs, generateChangelog } from '@my-claude-agents/doc-generator';
import * as fs from 'fs';
async function generateAllDocs() {
// Generate README
const readme = await generateReadme('./', {
projectName: 'My Library',
version: '1.0.0',
includeBadges: true,
});
fs.writeFileSync('README.md', readme.content);
// Generate API docs
const apiDocs = await generateApiDocs('./src', {
groupByCategory: true,
});
fs.writeFileSync('docs/API.md', apiDocs.content);
// Generate changelog
const changelog = await generateChangelog('./', {
conventionalCommits: true,
groupByType: true,
});
fs.writeFileSync('CHANGELOG.md', changelog.content);
// Generate JSDoc for specific files
const files = ['./src/index.ts', './src/utils.ts'];
for (const file of files) {
const jsdoc = await generateJSDoc(file, {
style: 'typescript',
addTodoTags: true,
});
console.log(`JSDoc for ${file}:\n${jsdoc.content}`);
}
}
generateAllDocs().catch(console.error);
Custom Changelog with Date Range
const changelog = await generateChangelog('./', {
fromTag: 'v1.0.0',
toTag: 'v2.0.0',
conventionalCommits: true,
groupByType: true,
includeAuthors: true,
linkCommits: true,
});
console.log(changelog.content);
TypeScript-Specific JSDoc
const jsdoc = await generateJSDoc('./src/types.ts', {
style: 'typescript',
inferTypes: true,
includePrivate: false,
addTodoTags: true,
});
console.log(jsdoc.content);
console.log('Warnings:', jsdoc.metadata.warnings);
Development
Building
npm run build
Type Checking
npm run typecheck
Development Mode
npm run dev
Project Structure
doc-generator/
├── src/
│ ├── types.ts # Type definitions
│ ├── generator.ts # Core generation logic
│ ├── index.ts # Public API exports
│ └── mcp-server.ts # MCP server implementation
├── dist/ # Compiled output
├── package.json
├── tsconfig.json
├── LICENSE
└── README.md
Error Handling
All functions throw DocError
instances with structured error information:
try {
const result = await generateJSDoc('./nonexistent.ts');
} catch (error) {
if (error instanceof DocError) {
console.error('Error code:', error.code);
console.error('Message:', error.message);
console.error('Details:', error.details);
}
}
License
This project is licensed under the MIT License - see the LICENSE file for details.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Author
j0kz
Support
For issues and questions, please use the GitHub issue tracker.