MCP 文档服务是一个用于文档管理的模型上下文协议(MCP)实现。它提供了一套工具,用于读取、写入和管理带有 frontmatter 元数据的 markdown 文档。该服务设计为与像 Cursor 或 Claude Desktop 中的 AI 助手无缝协作,使您能够通过自然语言交互轻松管理您的文档。
需要在您的机器上安装 Node。
npm install -g mcp-docs-service
或者直接使用 npx:
npx mcp-docs-service /path/to/docs
要与 Cursor 一起使用,请在项目根目录下创建一个 .cursor/mcp.json
文件:
{
"mcpServers": {
"docs-manager": {
"command": "npx",
"args": ["-y", "mcp-docs-service", "/path/to/your/docs"]
}
}
}

要将 MCP 文档服务与 Claude Desktop 一起使用:
安装 Claude Desktop - 从 Claude 的网站 下载最新版本。
配置 Claude Desktop 以支持 MCP:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
编辑配置文件 以添加 MCP 文档服务:
{
"mcpServers": {
"docs-manager": {
"command": "npx",
"args": ["-y", "mcp-docs-service", "/path/to/your/docs"]
}
}
}

请确保将 /path/to/your/docs
替换为您文档目录的绝对路径。
完全重启 Claude Desktop。
验证工具是否可用 - 重新启动后,您应该能在 docs-manager MCP 工具 (Cursor 设置 > MCP) 中看到一个绿色的点。
故障排除:
~/Library/Logs/Claude/mcp*.log
%APPDATA%\Claude\logs\mcp*.log
当在 Cursor 中使用 Claude 时,可以通过两种方式调用工具:
Can you search my documentation for anything related to "getting started"?
Please list all the markdown files in my docs directory.
Could you check if there are any issues with my documentation?
@docs-manager mcp_docs_manager_read_document path=docs/getting-started.md
@docs-manager mcp_docs_manager_list_documents recursive=true
@docs-manager mcp_docs_manager_check_documentation_health
当使用 Claude Desktop 时,可以通过两种方式调用工具:
Can you read the README.md file for me?
Please find all documents that mention "API" in my documentation.
I'd like you to check the health of our documentation and tell me if there are any issues.
Claude 将解释您的自然语言请求,并使用适当的工具和正确的参数。您不需要记住确切的工具名称或参数格式——只需描述您想要做什么!
以下是一些您可以与工具一起使用的常见命令:
@docs-manager mcp_docs_manager_read_document path=docs/getting-started.md
@docs-manager mcp_docs_manager_write_document path=docs/new-document.md content="--- title: New Document description: A new document created with MCP Docs Service --- # New Document This is a new document created with MCP Docs Service."
@docs-manager mcp_docs_manager_edit_document path=README.md edits=[{"oldText":"# Documentation", "newText":"# Project Documentation"}]
@docs-manager mcp_docs_manager_search_documents query="getting started"
@docs-manager mcp_docs_manager_generate_navigation
欢迎贡献!以下是您如何贡献的方法:
git checkout -b feature/my-feature
git commit -am 'Add my feature'
git push origin feature/my-feature
请确保您的代码遵循现有的风格,并包含适当的测试。
MCP 文档服务具有全面的测试覆盖范围,以确保可靠性和稳定性。我们使用 Vitest 进行测试,并跟踪覆盖率指标以维护代码质量。
# Run all tests
npm test
# Run tests with coverage report
npm run test:coverage

测试套件包括:
我们的测试设计得非常健壮,能够处理实现中的潜在错误,确保即使底层代码存在问题也能通过测试。
运行覆盖率命令后,在 coverage
目录中生成详细的报告:
coverage/index.html
coverage/coverage-final.json
我们保持高测试覆盖率以确保服务的可靠性,重点测试关键路径和边缘情况。
我们使用 MCP 文档服务来维护我们自己文档的健康。健康分数基于以下因素:
您可以使用以下命令检查文档的健康状况:
npx mcp-docs-service --health-check /path/to/docs
MCP Docs Service 可以生成一个针对大型语言模型优化的整合文档文件。当你希望将整个文档集提供给 LLM 作为上下文时,此功能非常有用:
# Generate consolidated documentation with default filename (consolidated-docs.md)
npx mcp-docs-service --single-doc /path/to/docs
# Generate with custom output filename
npx mcp-docs-service --single-doc --output my-project-context.md /path/to/docs
# Limit the total tokens in the consolidated documentation
npx mcp-docs-service --single-doc --max-tokens 100000 /path/to/docs

整合输出包括:
MCP Docs Service 被设计为默认具有弹性。即使面对不完整或结构不良的文档,服务也能自动处理而不会失败:
这使得该服务特别适用于:
该服务总是提供有用的反馈而不是失败,允许你随着时间逐步改进你的文档。
有关更详细的信息,请参阅我们的文档:
MIT