自主文档MCP
](https://www.npmjs.com/package/autonomous-docs-mcp)    
由模型上下文协议(MCP)驱动的自主文档生成工具,具有Mintlify风格的代码库表示。自动分析、生成和维护与代码保持同步的精美文档。
概述
自主文档MCP是一个智能文档系统,可以理解您的代码库并自动生成专业级文档。基于模型上下文协议,它为AI代理提供了强大的工具来分析代码结构、提取API,并创建全面的文档,无需手动配置。
graph LR
subgraph "Documentation Workflow"
CODE[Codebase] --> ANALYZE[Analyze
analyze_codebase]
ANALYZE --> GENERATE[Generate
generate_documentation]
GENERATE --> VALIDATE[Validate
validate_documentation]
VALIDATE --> SYNC[Sync
sync_documentation]
CODE --> API[API Reference
generate_api_reference]
CODE --> EXAMPLES[Extract Examples
extract_code_examples]
CODE --> CHANGELOG[Generate Changelog
generate_changelog]
API --> DOCS[Mintlify Docs]
EXAMPLES --> DOCS
CHANGELOG --> DOCS
GENERATE --> DOCS
end
style CODE fill:#667eea
style ANALYZE fill:#4ecdc4
style GENERATE fill:#95e1d3
style VALIDATE fill:#ffd93d
style SYNC fill:#6bcf7f
style DOCS fill:#764ba2为什么选择自主文档MCP?
- 零配置:使用智能默认值开箱即用
- 人工智能原生:专为通过MCP消费AI代理而构建
- 明特利风格:生成美观、现代的文档
- 多语言:支持TypeScript、JavaScript、Python、Go、Rust、Java等
- 连续同步:随着代码的发展不断更新文档
- 质量验证:内置链接、示例和完整性检查
特性
核心能力
- 自主代码库分析:自动扫描并理解整个代码库结构
- Mintlify风格生成:使用MDX和Mintlify组件生成美观、现代的文档
- API参考自动生成:从代码注释、JSDoc和docstring中提取API定义
- 智能导航:使用智能导航结构自动组织文档
- 文件验证:通过内置的链接、示例和前台验证确保质量
- 与源同步:使用自动更改检测功能,在代码更改时更新文档
- 多语言支持:对TypeScript、JavaScript、Python、Go、Rust、Java的一流支持
- 变更日志生成:使用语义版本控制从git历史自动生成更改日志
- 代码示例提取:从测试、演示和源文件中提取和组织代码示例
MCP工具
服务器通过模型上下文协议公开了8个强大的工具:
- 分析_贬值 -自主分析整个代码库结构
- 生成文档 -生成完整的Mintlify风格文档
- generate_api_reference -从代码注释生成API引用
- create_docs_config -生成docs.json配置
- validate_documentation -验证MDX文件、链接和代码示例
- 同步文档 -将文档与代码库更改同步
- generate_changelog -从git历史生成更改日志
- 提取代码示例 -从源代码中提取代码示例
安装
先决条件
- Node.js 18+
- npm或纱线
- Git(用于生成变更日志)
快速安装
# Clone the repository
git clone https://github.com/perryjr1444/autonomous-docs-mcp.git
cd autonomous-docs-mcp
# Install dependencies
npm install
# Build the project
npm run build开发环境设置
# Install dependencies
npm install
# Run in development mode with hot reload
npm run dev
# Run tests
npm test
# Lint code
npm run lint配置
MCP服务器配置
添加到您的 .claude.json 或MCP客户端配置:
{
"mcpServers": {
"autonomous-docs": {
"command": "node",
"args": ["/path/to/autonomous-docs-mcp/dist/index.js"],
"env": {}
}
}
}项目配置(可选)
创建一个 .autodocs.json 在自定义设置的项目根目录中:
{
"includePatterns": ["**/*.ts", "**/*.js", "**/*.py"],
"excludePatterns": ["node_modules/**", "dist/**", "*.test.*"],
"theme": "modern",
"outputDir": "./docs",
"apiReference": {
"format": "mintlify",
"includePrivate": false
},
"validation": {
"strict": true,
"checkLinks": true,
"checkCodeExamples": true
}
}用法
快速开始
// 1. Analyze your codebase
const analysis = await analyze_codebase({
path: "/Users/you/my-project",
depth: "comprehensive",
include_patterns: ["**/*.ts", "**/*.py"],
exclude_patterns: ["node_modules/**", "dist/**"]
});
// 2. Generate documentation
const docs = await generate_documentation({
analysis_result: JSON.stringify(analysis),
output_dir: "./docs",
theme: "modern",
include_api_reference: true,
include_examples: true
});
// 3. Validate generated docs
const validation = await validate_documentation({
docs_path: "./docs",
strict: false,
check_links: true,
check_code_examples: true
});API 参考
分析_贬值
分析整个代码库结构并确定文档需求。
analyze_codebase({
path: string, // Root path (defaults to current directory)
include_patterns?: string[], // Glob patterns to include
exclude_patterns?: string[], // Glob patterns to exclude
depth?: "quick" | "standard" | "comprehensive" // Analysis depth
})退货JSON分析结果:
- 项目结构
- 已识别的组件和API
- 文件建议
- 文件分类
生成文档
使用MDX文件、frontmatter和导航生成完整的Mintlify风格文档。
generate_documentation({
analysis_result: string, // JSON from analyze_codebase
output_dir?: string, // Output directory (default: "./docs")
theme?: "default" | "minimal" | "technical" | "modern",
include_api_reference?: boolean, // Auto-generate API reference
include_examples?: boolean // Generate code examples
})退货:生成报告,包括:
- 已创建的文件
- 导航结构
- 主题配置
- 验证摘要
generate_api_reference
从代码注释生成API参考文档。
generate_api_reference({
source_path: string, // Path to source code
output_path?: string, // Output path for API reference
format?: "mintlify" | "openapi" | "markdown",
include_private?: boolean // Include private/internal APIs
})create_docs_config
生成带有导航和主题设置的docs.json配置。
create_docs_config({
project_name: string, // Project name
structure: string, // JSON string of doc structure
theme_config?: object, // Theme customization
integrations?: string[] // Integrations (e.g., ['github', 'slack'])
})validate_documentation
验证MDX文件、frontmatter、内部链接和代码示例。
validate_documentation({
docs_path: string, // Path to documentation directory
strict?: boolean, // Enable strict validation mode
check_links?: boolean, // Validate all internal links
check_code_examples?: boolean // Validate code examples syntax
})退货:验证报告,包括:
- 错误和警告
- 断开的链接
- 无效的代码示例
- 前部缺失
同步文档
将文档与代码库更改同步,并检测过时的内容。
sync_documentation({
docs_path: string, // Path to documentation directory
source_path: string, // Path to source code
auto_update?: boolean // Automatically update outdated docs
})退货:将报告与以下内容同步:
- 过时的文件
- 检测到新的API
- 已删除组件
- 更新建议
generate_changelog
使用语义版本控制从git历史生成更改日志。
generate_changelog({
repo_path: string, // Path to git repository
from_version?: string, // Starting version/tag
to_version?: string, // Ending version/tag (defaults to HEAD)
format?: "mintlify" | "keep-a-changelog" | "conventional"
})提取代码示例
从测试、演示和源文件中提取和组织代码示例。
extract_code_examples({
source_path: string, // Path to source code
output_path?: string, // Output path for examples
categories?: string[] // Example categories to extract
})文档结构
生成的文档遵循Mintlify的最佳实践:
docs/
├── introduction.mdx # Project overview
├── quickstart.mdx # Getting started guide
├── installation.mdx # Installation instructions
├── api/
│ ├── overview.mdx # API reference overview
│ ├── authentication.mdx # Authentication guide
│ └── endpoints/ # Individual endpoint docs
│ ├── users.mdx
│ └── projects.mdx
├── guides/
│ ├── overview.mdx # Guides overview
│ ├── best-practices.mdx # Best practices
│ └── troubleshooting.mdx # Common issues
├── components/ # Component documentation
│ ├── button.mdx
│ └── modal.mdx
├── examples/ # Code examples
│ ├── basic-usage.mdx
│ └── advanced-usage.mdx
├── changelog.mdx # Changelog
└── docs.json # Navigation configuration前线人员要求
所有生成的MDX文件都包含适用于Mintlify的正确frontmatter:
---
title: "Page Title"
description: "Page description for SEO and navigation"
icon: "file-lines"
---Mintlify组件
生成的文档支持并利用Mintlify的组件库:
Feature description
Content
Content
Collapsible content
// TypeScript example const example = "code";
Python example
example = "code"
TypeScript content
Python content
例子
看看 示例/ 目录:
- API插件集成 -与API文档工具集成
- 连续同步 -使文档与CI/CD保持同步
- 自定义主题 -创建自定义文档主题
- GitHub操作 -自动推送文档生成
- Mintlify部署 -部署到Mintlify主机
- 多回购 -聚合来自多个存储库的文档
- 预提交钩子 -提交前验证文档
看 examples/INTEGRATION_examples.md 获取详细的集成指南。
最佳实践
- 定期运行分析:使文档与代码更改保持同步
# Add to CI/CD pipeline
npm run analyze && npm run generate- 部署前验证:使用验证工具捕捉问题
npm run validate-docs- 自定义主题:将您的品牌与主题配置相匹配
{
"theme": "modern",
"theme_config": {
"primaryColor": "#0D9373",
"logo": "/logo.svg"
}
}- 使用示例:在文档中包含实用的代码示例
- 从测试文件中提取 - 创建专用示例文件 - 显示常见用例
- 保持新鲜:使用同步工具检测过时的内容
npm run sync-docs- 利用Git钩子:提交时自动验证文档
# Install pre-commit hook
cp examples/pre-commit/.pre-commit-config.yaml .发展
项目结构
autonomous-docs-mcp/
├── src/
│ ├── index.ts # MCP server entry point
│ ├── analyzers/
│ │ └── codebase-analyzer.ts # Codebase analysis logic
│ ├── generators/
│ │ ├── mdx-generator.ts # MDX file generation
│ │ └── docs-config-generator.ts # Config generation
│ └── validators/
│ └── doc-validator.ts # Documentation validation
├── dist/ # Compiled JavaScript
├── examples/ # Usage examples
├── tests/ # Test suite
├── package.json
├── tsconfig.json
└── README.md建筑
# Build TypeScript
npm run build
# Clean build artifacts
npm run clean
# Rebuild from scratch
npm run clean && npm run build测试
# Run all tests
npm test
# Run tests in watch mode
npm run test:watch
# Run with coverage
npm run test:coverage代码检查
# Lint TypeScript files
npm run lint
# Fix linting issues automatically
npm run lint:fix安全
- 无敏感数据:从不在生成的文档中包含敏感数据
- 链接验证:在生成之前验证所有链接
- 代码消毒:对代码示例进行消毒以防止注射
- Gitignore尊重:自动尊重.gitignore模式
- 私人API控制:排除私有/内部API的选项
故障排除
常见问题
构建错误
# Clear node_modules and reinstall
rm -rf node_modules package-lock.json
npm install
npm run buildMCP连接问题
# Check server is running
ps aux | grep autonomous-docs
# Check configuration
cat ~/.claude.json | grep autonomous-docs验证错误
# Run validation with verbose output
npm run validate-docs -- --verbose
# Check specific file
npm run validate-docs -- --file docs/api/endpoint.mdx贡献
我们欢迎捐款!请看 贡献.md 用于:
- 行为准则
- 开发工作流程
- 拉取请求流程
- 编码标准
- 测试指南
更新日志
看 更改日志.md 查看版本历史和发行说明。
许可证
此项目根据MIT许可证获得许可-请参阅 许可证 文件以获取详细信息。
支持
- 问题:
- 讨论:
- 电子邮件: perryjr1444@github.com
致谢
路线图
- \[\]支持更多编程语言(Ruby、PHP、C#)
- \[\]与流行的文档平台(ReadTheDocs、GitBook)集成
- \[\]实时协作功能
- \[\]基于人工智能的文档建议
- \[\]可视化文档生成器
- \[\]多语言文档支持(i18n)
- \[\]文档分析和见解
作者
佩里1444
______________________________________________________________________
由以下材料制成❤️ MCP社区
