Document MCP
Document MCP
ChatGPT风格聊天机器人加一个Document MCP服务器。你在设置中注册文件夹路径和本地LiteLLM模型。问题发送到LiteLLM(带MCP工具);服务器只读取这些文件夹,使用pywin32 COM处理Word/Excel/PowerPoint(与Model Council相同的Office路径)。
Chat UI → LiteLLM /v1/chat/completions (+ tools)
↑ tool_calls (search_documents, read_document, …)
MCP host → Document MCP (stdio JSON-RPC)
→ allowlisted folders
→ win32com Word / Excel / PowerPointClaude Desktop、Claude Code和Cursor都连接到同一个MCP服务器和同一个文件夹列表。
快速开始
运行你的LiteLLM代理。
双击
start.bat。设置 → LiteLLM:粘贴基础URL(例如
http://localhost:4000)、API密钥,加载模型或添加模型,然后保存。设置 → 文件夹:粘贴Windows文件夹路径。首次运行时已注册
sample_docs。问任何这些文件能回答的问题。
手动操作
python -m venv .venv
.venv\Scripts\activate
pip install -r requirements.txt
copy .env.example .env
python -m appRelated MCP server: file-analysis-mcp
设置
选项卡 | 功能说明 |
LiteLLM | 基础URL、密钥、加载 |
文件夹 | MCP根目录(允许列表)。与Model Council的 |
Claude MCP | 复制Claude Desktop / Claude Code / Cursor代码片段,或为你写入Claude Desktop配置 |
URL可以粘贴为http://host:4000、http://host:4000/v1或.../v1/chat/completions——它们会像Model Council一样被标准化。
LiteLLM + MCP如何在此工作
取自Model Council的应用内MCP循环:
主机调用MCP
tools/list并将模式转换为OpenAI工具。主机向LiteLLM POST
chat/completions,附带这些工具(tool_choice: auto)。如果模型返回
tool_calls,主机运行MCPtools/call(stdio)。工具JSON作为
role: tool追加,循环重复直到得到正常答案。
模型除非调用工具,否则永远不会看到文件。根目录被列入允许列表。Office文件优先使用COM,以便仍能读取Windows解锁/IRM文件。
MCP工具
工具 | 用途 |
| 健康检查、引擎、文件夹数量 |
| 已注册的根目录 |
| 更改根目录 |
| 清单 |
| 名称 + 提取的文本 |
| 提取(优先COM,库作为后备) |
提示词:ask_documents。
Claude Desktop / Claude Code / Cursor
在聊天机器人中:设置 → Claude MCP → 添加到Claude Desktop(写入%APPDATA%\Claude\claude_desktop_config.json)。重启Claude,然后让它ping Document MCP。
或者复制此形状(路径由设置填入):
{
"mcpServers": {
"document-mcp": {
"command": "D:\\\\AntigravityCodes\\\\Document-MCP\\\\.venv\\\\Scripts\\\\python.exe",
"args": ["-m", "document_mcp"],
"cwd": "D:\\\\AntigravityCodes\\\\Document-MCP",
"env": {
"PYTHONUTF8": "1",
"DOCUMENT_MCP_ROOTS": "D:\\\\AntigravityCodes\\\\Document-MCP\\\\data\\\\folders.json"
}
}
}
}Claude Code:
claude mcp add-json document-mcp "{...stdio server json from Settings...}"Cursor:仓库mcp.json,或设置 → Claude MCP复制Cursor代码片段。
HTTP(LiteLLM MCP网关):
start_mcp_http.bat然后添加http://127.0.0.1:8765/mcp。
pywin32 / Office
Word.Application→.doc/.docxExcel.Application→.xls/.xlsx/.xlsmPowerPoint.Application→.ppt/.pptx
后备:python-docx / openpyxl / python-pptx。PDF:PyMuPDF。旧版二进制Office仍需要Microsoft Office。
python -m document_mcp.reader sample_docs\mena_rhq_overview.md布局
app/ FastAPI chat host (MCP client + UI)
document_mcp/ FastMCP server, COM readers, Claude install helper
sample_docs/ Starter files
data/ folders.json, settings, extract cache (local)This server cannot be deployed
Maintenance
Related MCP Connectors
Safe folder access for ChatGPT and Claude: read, write and search files, risky tools opt-in.
OCR, transcription, file extraction, and image generation for AI agents via MCP.
Securely search and manage workspace context files for AI agents and teams.
Document-to-Markdown MCP server — convert PDF, Office and HTML into LLM-ready Markdown.
Related MCP Servers
- FlicenseAqualityDmaintenanceEnables natural language interaction with local .docx files, allowing users to find, read, search, and summarize Word documents using friendly names and location hints.53-
- FlicenseAqualityCmaintenanceEnables read-only scanning and text extraction from PDF, DOCX, PPTX, SVG, and PNG files in a local folder, providing the raw text to AI models for summarization or analysis without an external LLM API.5-
- FlicenseAqualityCmaintenanceEnables local Windows file management with allowlisted folder access and integration with Outlook Classic or Microsoft 365 email for AI assistants like Claude Desktop.38-
- AlicenseNot gradedqualityBmaintenanceEnables AI agents on Windows to drive real Microsoft Word and WPS Office applications through COM, automating legacy .doc/.docx batch conversion, bookmark and placeholder template filling, print-fidelity PDF export, extraction from legacy binaries, editing of documents currently open on screen, and mail-merge batch generation. It hardens these operations with CJK font preservation, password and corruption pre-checks, structured self-correcting errors, path allowlisting, read-only mode, and automatic Word-to-WPS failover.1MIT