# mcp_documents_reader **Repository Path**: xt765/mcp_documents_reader ## Basic Information - **Project Name**: mcp_documents_reader - **Description**: 该工具基于 MCP 协议开发,支持 Excel(XLSX/XLS)、DOCX、PDF、TXT 等多种主流格式,让AI智能体真正 “读懂” 你的文档。已经在Trae IDE成功测试运行。 - **Primary Language**: Python - **License**: MIT - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2026-01-23 - **Last Updated**: 2026-02-25 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # MCP Document Reader (MCP 文档读取器) [![CSDN Blog](https://img.shields.io/badge/CSDN-玄同765-orange.svg?style=flat&logo=csdn)](https://blog.csdn.net/Yunyi_Chi) [![GitHub Repository](https://img.shields.io/badge/GitHub-mcp_documents_reader-black.svg?style=flat&logo=github)](https://github.com/xt765/mcp_documents_reader) [![Gitee Repository](https://img.shields.io/badge/Gitee-mcp_documents_reader-red.svg?style=flat&logo=gitee)](https://gitee.com/xt765/mcp_documents_reader) [![License](https://img.shields.io/badge/License-MIT-blue.svg?style=flat&logo=opensourceinitiative)](LICENSE) [![Python Version](https://img.shields.io/badge/python-3.8%2B-blue.svg?style=flat&logo=python)](https://www.python.org/downloads/) [![PyPI Version](https://img.shields.io/pypi/v/mcp-documents-reader.svg?logo=pypi)](https://pypi.org/project/mcp-documents-reader/) [![PyPI Downloads](https://img.shields.io/pepy/dt/mcp-documents-reader.svg?logo=pypi&label=PyPI%20Downloads)](https://pepy.tech/project/mcp-documents-reader) [![MCP Registry](https://img.shields.io/badge/MCP-Registry-blue?logo=modelcontextprotocol)](https://registry.modelcontextprotocol.io/v0.1/servers?search=io.github.xt765/mcp_documents_reader) MCP(模型上下文协议)文档读取器 - 一个强大的 MCP 工具,用于读取多种格式的文档,使 AI 智能体能够真正"读取"您的文档。 GitHub 仓库:[https://github.com/xt765/mcp_documents_reader](https://github.com/xt765/mcp_documents_reader) Gitee 仓库:[https://gitee.com/xt765/mcp_documents_reader](https://gitee.com/xt765/mcp_documents_reader) PyPI:[https://pypi.org/project/mcp-documents-reader/](https://pypi.org/project/mcp-documents-reader/) 官方注册表:[在 MCP Registry 查看](https://registry.modelcontextprotocol.io/v0.1/servers?search=io.github.xt765/mcp_documents_reader) ## 架构 ```mermaid graph TB A[AI Assistant / User
AI 助手 / 用户] -->|Call read_document
调用 read_document| B[MCP Document Reader
MCP 文档读取器] B -->|Detect file type
检测文件类型| C{File Type?
文件类型?} C -->|.docx| D[DOCX Reader
DOCX 读取器] C -->|.pdf| E[PDF Reader
PDF 读取器] C -->|.xlsx/.xls| F[Excel Reader
Excel 读取器] C -->|.txt| G[Text Reader
文本读取器] D -->|Extract text
提取文本| H[Return Content
返回内容] E -->|Extract text
提取文本| H F -->|Extract text
提取文本| H G -->|Extract text
提取文本| H H -->|Text content
文本内容| A style A fill:#e1f5ff style B fill:#fff4e1 style C fill:#f0f0f0 style D fill:#e8f5e9 style E fill:#e8f5e9 style F fill:#e8f5e9 style G fill:#e8f5e9 style H fill:#fff9c4 ``` ## 功能特性 - **多格式支持**:支持 4 种主流文档格式:Excel(XLSX/XLS)、DOCX、PDF 和 TXT - **MCP 协议**:符合 MCP 标准,可作为 AI 助手(如 Trae IDE)的工具使用 - **易于集成**:简单配置即可立即使用 - **可靠性能**:已在 Trae IDE 中成功测试运行 - **文件系统支持**:直接从文件系统读取文档 ## 支持的格式 | 格式 | 扩展名 | MIME 类型 | 特性 | |------|--------|-----------|------| | Excel | .xlsx, .xls | application/vnd.openxmlformats-officedocument.spreadsheetml.sheet | 工作表和单元格数据提取 | | DOCX | .docx | application/vnd.openxmlformats-officedocument.wordprocessingml.document | 文本和结构提取 | | PDF | .pdf | application/pdf | 文本提取 | | Text | .txt | text/plain | 纯文本读取 | ## 安装 ### 前提条件 - Python 3.8 或更高版本 - 支持 MCP 的 AI 工具,如 Trae IDE ### 安装步骤 #### 选项 1:通过 PyPI 安装 (推荐) ```bash pip install mcp-documents-reader ``` #### 选项 2:通过源码安装 ```bash # 克隆仓库 git clone https://github.com/xt765/mcp_documents_reader.git # 或者使用 Gitee # git clone https://gitee.com/xt765/mcp_documents_reader.git cd mcp_documents_reader # 安装依赖 pip install -e . ``` ## 配置 ### 在 Trae IDE 中使用 将以下内容添加到 Trae IDE 的 MCP 配置中: #### 选项 1:使用 PyPI 包 (推荐) ```json { "mcpServers": { "mcp-document-reader": { "command": "uvx", "args": [ "mcp-documents-reader" ] } } } ``` #### 选项 2:使用 GitHub 仓库 ```json { "mcpServers": { "mcp-document-reader": { "command": "uvx", "args": [ "--from", "git+https://github.com/xt765/mcp_documents_reader", "mcp_documents_reader" ] } } } ``` #### 选项 3:使用 Gitee 仓库 ```json { "mcpServers": { "mcp-document-reader": { "command": "uvx", "args": [ "--from", "git+https://gitee.com/xt765/mcp_documents_reader", "mcp_documents_reader" ] } } } ``` ### 环境变量 - `DOCUMENT_DIRECTORY` - 存储文档的目录(默认:"./documents") ## 使用方法 ### 作为 MCP 工具使用 配置完成后,AI 助手可以直接调用以下工具: #### read_document (推荐) 使用统一接口读取任何支持的文档类型。 ``` read_document(filename="example.docx") read_document(filename="example.pdf") read_document(filename="example.xlsx") read_document(filename="example.txt") ``` ## 工具接口详情 ### read_document 读取任何支持的文档类型。 **参数:** | 参数 | 类型 | 必填 | 描述 | |------|------|------|------| | filename | string | ✅ | 文档文件路径,支持绝对路径或相对路径 | ## 许可证 MIT