Skip to main content
Glama
MENARHQ-cloud

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 / PowerPoint

Claude Desktop、Claude Code和Cursor都连接到同一个MCP服务器和同一个文件夹列表。

快速开始

  1. 运行你的LiteLLM代理。

  2. 双击start.bat。

  3. 打开http://127.0.0.1:7860。

  4. 设置 → LiteLLM:粘贴基础URL(例如http://localhost:4000)、API密钥,加载模型或添加模型,然后保存。

  5. 设置 → 文件夹:粘贴Windows文件夹路径。首次运行时已注册sample_docs。

  6. 问任何这些文件能回答的问题。

手动操作

python -m venv .venv
.venv\Scripts\activate
pip install -r requirements.txt
copy .env.example .env
python -m app

Related MCP server: file-analysis-mcp

设置

选项卡

功能说明

LiteLLM

基础URL、密钥、加载/v1/models、添加不在列表中的本地模型名称、测试连接

文件夹

MCP根目录(允许列表)。与Model Council的OFFICE_ALLOWED_ROOTS相同

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循环:

  1. 主机调用MCP tools/list并将模式转换为OpenAI工具。

  2. 主机向LiteLLM POST chat/completions,附带这些工具(tool_choice: auto)。

  3. 如果模型返回tool_calls,主机运行MCP tools/call(stdio)。

  4. 工具JSON作为role: tool追加,循环重复直到得到正常答案。

模型除非调用工具,否则永远不会看到文件。根目录被列入允许列表。Office文件优先使用COM,以便仍能读取Windows解锁/IRM文件。

MCP工具

工具

用途

ping

健康检查、引擎、文件夹数量

list_folders

已注册的根目录

add_folder / remove_folder

更改根目录

list_documents

清单

search_documents

名称 + 提取的文本

read_document

提取(优先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 / .docx

  • Excel.Application → .xls / .xlsx / .xlsm

  • PowerPoint.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)

Related MCP Connectors

Related MCP Servers

  • F
    license
    A
    quality
    C
    maintenance
    Enables 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
    -
  • F
    license
    A
    quality
    C
    maintenance
    Enables local Windows file management with allowlisted folder access and integration with Outlook Classic or Microsoft 365 email for AI assistants like Claude Desktop.
    38
    -
  • A
    license
    Not graded
    quality
    B
    maintenance
    Enables 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.
    1
    MIT