文档自动化生成工具

MCP-RTFM是一个自动化文档生成和管理工具,通过内容分析、元数据生成和智能搜索功能,将不存在的或难以理解的文档转化为互联的知识库。

  • by ryanjoachim
  • JavaScript
  • 本地部署
  • 35 星标
  • 更新于
在 GitHub 查看 ryanjoachim/mcp-rtfm

使用说明

MCP-RTFM

“RTFM!”他们说,但如果没有FM到R怎么办? 🤔 输入MCP-RTFM:一个帮助您的MCP服务器 创建 每个人都在不断地告诉人们要阅读《F*ing手册》!使用先进的内容分析、元数据生成和智能搜索功能,它将您不存在或不可读的文档转换为相互关联的知识库,在被问到这些“基本问题”之前,这些知识库实际上会回答这些问题。

情节转折:现在,你不仅可以告诉人们使用RTFM,还可以给他们一个值得推荐的FM!因为对“阅读f*ing手册”的最佳回应是有一本真正值得一读的手册。 📚✨

📚 目录

🚀 快速开始

# Install dependencies
npm install

# Build the server
npm run build

# Add to your MCP settings and start using
await use_mcp_tool({
  server: "mcp-rtfm",
  tool: "analyze_project_with_metadata", // Enhanced initialization
  args: { projectPath: "/path/to/project" }
});

// This will:
// 1. Create documentation structure
// 2. Analyze content with unified/remark
// 3. Generate intelligent metadata
// 4. Build search index with minisearch
// 5. Add structured front matter
// 6. Make your docs actually readable!

✨ 特性

文档管理工具

  • analyze_existing_docs -通过内容分析和元数据分析和增强现有文档
  • analyze_project_with_metadata -通过增强的内容分析和元数据生成初始化文档结构
  • analyze_project -文档结构的基本初始化
  • read_doc -阅读文档文件(更新前需要)
  • update_doc -使用基于差异的更改更新文档
  • get_doc_content -获取文档文件的当前内容
  • get_project_info -获取项目结构和文档状态
  • search_docs -在文档文件中搜索突出显示的结果
  • update_metadata -更新文档元数据
  • get_related_docs -根据元数据和内容链接查找相关文档
  • customize_template -创建或更新文档模板

默认文档文件

服务器自动创建和管理这些核心文档文件:

  • techStack.md -工具、库和配置的详细清单
  • codebaseDetails.md -代码结构和逻辑的低级解释
  • workflowDetails.md -关键流程的分步工作流程
  • integrationGuides.md -外部系统连接说明
  • errorHandling.md -故障排除策略和实践
  • handoff_notes.md -关键主题和下一步行动摘要

文档模板

针对不同文档类型的内置模板:

  • 标准文档模板
  • API文档模板
  • 工作流文档模板

可以使用创建自定义模板 customize_template 工具。

📝 示例工作流

1.分析现有文件

// Enhance existing documentation with advanced analysis
await use_mcp_tool({
  server: "mcp-rtfm",
  tool: "analyze_existing_docs",
  args: { projectPath: "/path/to/project" }
});

// This will:
// - Find all markdown files in .handoff_docs
// - Analyze content structure with unified/remark
// - Generate intelligent metadata
// - Build search index
// - Add front matter if not present
// - Establish document relationships
// - Preserve existing content

// The results include:
// - Enhanced metadata for all docs
// - Search index population
// - Content relationship mapping
// - Git context if available

2.增强的项目文档设置

// Initialize documentation with advanced content analysis
await use_mcp_tool({
  server: "mcp-rtfm",
  tool: "analyze_project_with_metadata",
  args: { projectPath: "/path/to/project" }
});

// Results include:
// - Initialized documentation files
// - Generated metadata from content analysis
// - Established document relationships
// - Populated search index
// - Added structured front matter
// - Git repository context

// Get enhanced project information
const projectInfo = await use_mcp_tool({
  server: "mcp-rtfm",
  tool: "get_project_info",
  args: { projectPath: "/path/to/project" }
});

// Search across documentation with intelligent results
const searchResults = await use_mcp_tool({
  server: "mcp-rtfm",
  tool: "search_docs",
  args: {
    projectPath: "/path/to/project",
    query: "authentication"
  }
});

// Results include:
// - Weighted matches (title matches prioritized)
// - Fuzzy search results
// - Full content context
// - Related document suggestions

3.使用内容链接更新文档

// First read the document
await use_mcp_tool({
  server: "mcp-rtfm",
  tool: "read_doc",
  args: {
    projectPath: "/path/to/project",
    docFile: "techStack.md"
  }
});

// Update with content that links to other docs
await use_mcp_tool({
  server: "mcp-rtfm",
  tool: "update_doc",
  args: {
    projectPath: "/path/to/project",
    docFile: "techStack.md",
    searchContent: "[Why this domain is critical to the project]",
    replaceContent: "The tech stack documentation provides essential context for development. See [[workflowDetails]] for implementation steps.",
    continueToNext: true // Automatically move to next document
  }
});

4.管理文档元数据

// Update metadata for better organization
await use_mcp_tool({
  server: "mcp-rtfm",
  tool: "update_metadata",
  args: {
    projectPath: "/path/to/project",
    docFile: "techStack.md",
    metadata: {
      title: "Technology Stack Overview",
      category: "architecture",
      tags: ["infrastructure", "dependencies", "configuration"]
    }
  }
});

// Find related documentation
const related = await use_mcp_tool({
  server: "mcp-rtfm",
  tool: "get_related_docs",
  args: {
    projectPath: "/path/to/project",
    docFile: "techStack.md"
  }
});

5.使用上下文搜索文档

// Search with highlighted results
const results = await use_mcp_tool({
  server: "mcp-rtfm",
  tool: "search_docs",
  args: {
    projectPath: "/path/to/project",
    query: "authentication"
  }
});

// Results include:
// - File name
// - Line numbers
// - Highlighted matches
// - Context around matches

6.创建自定义模板

// Create a custom template for architecture decisions
await use_mcp_tool({
  server: "mcp-rtfm",
  tool: "customize_template",
  args: {
    templateName: "architecture-decision",
    content: `# {title}

## Context
[Background and context for the decision]

## Decision
[The architecture decision made]

## Consequences
[Impact and trade-offs of the decision]

## Related Decisions
[Links to related architecture decisions]`,
    metadata: {
      category: "architecture",
      tags: ["decision-record", "design"]
    }
  }
});

🔧 安装

VSCode(Roo-Cline)

添加到设置文件: 添加到设置文件:

  • 窗户: %APPDATA%\Code\User\globalStorage\rooveterinaryinc.roo-cline\settings\cline_mcp_settings.json
  • MacOS: ~/Library/Application Support/Code/User/globalStorage/rooveterinaryinc.roo-cline/settings/cline_mcp_settings.json
  • Linux: ~/.config/Code/User/globalStorage/rooveterinaryinc.roo-cline/settings/cline_mcp_settings.json
{
  "mcpServers": {
    "mcp-rtfm": {
      "command": "node",
      "args": ["<path-to-mcp-rtfm>/build/index.js"],
      "disabled": false,
      "alwaysAllow": []
    }
  }
}

克劳德桌面

添加到配置文件:

  • 窗户: %APPDATA%\Claude\claude_desktop_config.json
  • MacOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json
{
  "mcpServers": {
    "mcp-rtfm": {
      "command": "node",
      "args": ["<path-to-mcp-rtfm>/build/index.js"],
      "disabled": false,
      "alwaysAllow": []
    }
  }
}

🎯 高级功能

内容链接

使用 [[document-name]] 用于在文档之间创建链接的语法。服务器会自动跟踪这些关系,并在查找相关文档时将其包含在内。

元数据驱动的组织

文档的组织方式如下:

  • 类别(例如,“架构”、“api”、“工作流”)
  • 灵活分组标签
  • 基于共享元数据的自动关系发现
  • 内容链接分析

增强的内容分析

服务器使用高级库来更好地管理文档:

  • 统一/备注 对于Markdown处理:

    • 基于AST的内容分析
    • 精确的航向结构检测
    • 代码块和链接提取
    • 正确的Markdown解析和操作
  • _上一条搜索 强大的搜索功能:

    • 在所有文档中快速模糊搜索
    • 字段加权搜索(标题具有更高的优先级)
    • 完整内容和元数据索引
    • 通过TTL管理实现高效缓存
    • 实时搜索索引更新

智能元数据生成

  • 用于分类的自动内容分析
  • 基于内容模式的智能标签生成
  • 文档中的结构化前端内容
  • 基于AST的标题和章节检测
  • 代码段识别和标记
  • 上下文感知结果演示

模板系统

  • 常见文档类型的内置模板
  • 具有元数据默认值的自定义模板支持
  • 模板继承和覆盖功能
  • 占位符系统,格式一致

🛠️ 发展

# Install dependencies
npm install

# Build the server
npm run build

# Development with auto-rebuild
npm run watch

🐛 调试

由于MCP服务器通过stdio进行通信,调试可能具有挑战性。使用 MCP检查员:

npm run inspector

检查器将提供一个URL,用于访问浏览器中的调试工具。

📄 许可证

MIT© 模型上下文协议