mcpField
D
Docling MCP

Docling MCP

本地服务
github.com/docling-project生产力7781 天前更新

关于 Docling MCP

Docling MCP 是面向需要结构化文档转换与生成的应用的 MCP 服务,支持本地或远程处理、缓存及可选的 RAG 工具。

主要功能

  1. 01将 PDF 转为结构化 DoclingDocument JSON
  2. 02生成可导出为多种格式的 DoclingDocument
  3. 03处理本地文件和 URL
  4. 04缓存文档并管理大型输入
  5. 05支持 Milvus 上传与检索的 RAG

适用场景

  1. 01转换 PDF 以供下游 AI 应用处理
  2. 02生成结构化文档并导出
  3. 03通过 Docling Serve 或本地处理文档

MCP 相关

它向 MCP 客户端提供文档转换、生成及相关工具。客户端可通过 stdio、SSE 或 streamable HTTP 启动连接。

配置

本地服务的配置在各客户端中通用,复制后粘贴到客户端的 MCP 配置文件即可。

mcp.json · 通用配置
{
"mcpServers": {
"docling-project-docling": {
"command": "uvx",
"args": [
"docling-mcp"
],
"env": {
"DOCLING_MCP_CONVERSION_MODE": "<DOCLING_MCP_CONVERSION_MODE>",
"DOCLING_MCP_SERVICE_URL": "<DOCLING_MCP_SERVICE_URL>",
"DOCLING_MCP_SERVICE_API_KEY": "<DOCLING_MCP_SERVICE_API_KEY>",
"DOCLING_MCP_SERVICE_TIMEOUT": "<DOCLING_MCP_SERVICE_TIMEOUT>",
"DOCLING_MCP_SERVICE_MAX_RETRIES": "<DOCLING_MCP_SERVICE_MAX_RETRIES>",
"DOCLING_MCP_FALLBACK_TO_LOCAL": "<DOCLING_MCP_FALLBACK_TO_LOCAL>",
"DOCLING_MCP_KEEP_IMAGES": "<DOCLING_MCP_KEEP_IMAGES>",
"DOCLING_MCP_IMAGES_SCALE": "<DOCLING_MCP_IMAGES_SCALE>",
"DOCLING_MCP_DO_OCR": "<DOCLING_MCP_DO_OCR>",
"DOCLING_MCP_DO_TABLE_STRUCTURE": "<DOCLING_MCP_DO_TABLE_STRUCTURE>",
"DOCLING_MCP_DO_PICTURE_DESCRIPTION": "<DOCLING_MCP_DO_PICTURE_DESCRIPTION>",
"DOCLING_MCP_PICTURE_DESCRIPTION_PRESET": "<DOCLING_MCP_PICTURE_DESCRIPTION_PRESET>",
"DOCLING_MCP_IMAGE_EXPORT_MODE": "<DOCLING_MCP_IMAGE_EXPORT_MODE>",
"DOCLING_MCP_CACHE_MAX_DOCUMENTS": "<DOCLING_MCP_CACHE_MAX_DOCUMENTS>"
}
}
}
}
启动命令uvx docling-mcp
需要配置的环境变量
DOCLING_MCP_CONVERSION_MODEConversion mode: 'remote' (default) or 'local' (requires docling-mcp[local] extra).
DOCLING_MCP_SERVICE_URLBase URL of the Docling Serve instance. Required when conversion mode is remote.
DOCLING_MCP_SERVICE_API_KEY密钥API key for authenticating with Docling Serve.
DOCLING_MCP_SERVICE_TIMEOUTRequest timeout in seconds for the remote Docling Serve API. Default: 300.0.
DOCLING_MCP_SERVICE_MAX_RETRIESMaximum number of retry attempts for remote API requests. Default: 3.
DOCLING_MCP_FALLBACK_TO_LOCALSet to 'true' to fall back to local conversion when Docling Serve is unreachable.
DOCLING_MCP_KEEP_IMAGESSet to 'true' to retain page images in converted documents. Default: false.
DOCLING_MCP_IMAGES_SCALEImage scale factor (e.g. 1.0, 2.0). Increase to avoid tensor batching errors. Default: 1.0.
DOCLING_MCP_DO_OCRSet to 'false' to disable the OCR pipeline. Default: true.
DOCLING_MCP_DO_TABLE_STRUCTURESet to 'false' to disable table structure detection. Default: true.
DOCLING_MCP_DO_PICTURE_DESCRIPTIONSet to 'true' to run a vision-language model to generate textual descriptions for figures and pictures. Requires a VLM to be available on the conversion backend. Default: false.
DOCLING_MCP_PICTURE_DESCRIPTION_PRESETPreset ID for the picture-description VLM (e.g. 'smolvlm', 'granite_vision'). When unset the backend default is used. Only applies when DOCLING_MCP_DO_PICTURE_DESCRIPTION=true.
DOCLING_MCP_IMAGE_EXPORT_MODEControls how images are rendered when exporting to Markdown. Accepted values: 'placeholder' (default, emits <!-- image -->), 'embedded' (base64 data-URI), 'referenced' (file path / URL).
DOCLING_MCP_CACHE_MAX_DOCUMENTSMaximum number of documents to keep in the in-memory cache. Oldest (least-recently-used) documents are evicted when the limit is reached. Default: 10.

本地服务需要在你的电脑上安装运行环境(如 Node.js 18+)。各客户端的配置文件位置不同,请参考客户端文档。

安装包
pypidocling-mcp3.4.0

工具

21

收录的工具列表 · 更新于 今天

参数类型必填说明
document_keystring是本地缓存中该文档的唯一标识符。

详细介绍

Docling

Docling MCP:让 Docling 具备 Agent 能力

CI PyPI version PyPI - Python Version uv Ruff Pydantic v2 prek License MIT PyPI Downloads LF AI & Data MCP Registry docling-mcp MCP server MCP Toplist

一个使用 Docling-MCP 库和 MCP(模型上下文协议)进行工具集成的文档处理服务。

概览

Docling MCP 是一项服务,提供用于文档转换、处理和生成的工具。它使用 Docling 库将 PDF 文档转换为结构化格式,并提供缓存机制以提升性能。该服务通过一组工具向客户端应用程序开放功能,供其调用。

兼容性

docling-mcpMCP Python SDK
>=3.0.0mcp>=2.0.0
>=2.0.0,<3.0.0mcp>=1.9.4,<2.0.0

如果你的 MCP 客户端应用程序尚未迁移到 MCP SDK v2,请固定版本:

pip install "docling-mcp<3.0.0"

完整迁移指南请参阅 MIGRATION.md。

安装选项

远程模式(推荐 - 轻量级)

适用于可访问 Docling Serve API 的用户:

获取 Docling Serve:访问 docling-serve 查看安装指南。你可以通过已发布的容器镜像进行部署,也可以寻找托管的 Docling SaaS 服务。

pip install docling-mcp

然后配置环境:

export DOCLING_MCP_SERVICE_URL=https://your-docling-service.example.com
export DOCLING_MCP_SERVICE_API_KEY=your-api-key-here
export DOCLING_MCP_CONVERSION_MODE=remote
本地模式(完整功能)

适用于需要本地转换或无法访问 Docling Serve 的用户:

pip install docling-mcp[local]

然后配置环境:

export DOCLING_MCP_CONVERSION_MODE=local
混合模式(两全其美)

安装本地支持并启用自动回退:

pip install docling-mcp[local]

配置为使用远程模式并启用回退:

export DOCLING_MCP_SERVICE_URL=https://your-docling-service.example.com
export DOCLING_MCP_CONVERSION_MODE=remote
export DOCLING_MCP_FALLBACK_TO_LOCAL=true

功能

  • 转换工具:
  • 生成工具:
    • 以 DoclingDocument 格式生成文档,并可导出为多种格式
  • 本地文档缓存,提升性能
  • 支持将本地文件和 URL 作为文档来源
  • 内存管理,用于处理大型文档
  • 用于调试和监控的日志系统
  • 支持使用 Milvus 上传和检索的 RAG 应用

配置

所有设置均使用 DOCLING_MCP_ 前缀,可通过环境变量、工作目录中的 .env 文件,或 MCP 客户端配置中的 env 块提供。复制 .env.example 作为起点。

转换模式
变量默认值描述
DOCLING_MCP_CONVERSION_MODEremoteremote 或 local
远程服务(DOCLING_MCP_CONVERSION_MODE=remote 时必需)
变量默认值描述
DOCLING_MCP_SERVICE_URL—Docling Serve 实例的 URL
DOCLING_MCP_SERVICE_API_KEY—服务的 API 密钥
DOCLING_MCP_SERVICE_TIMEOUT300.0整个转换任务的超时时间,单位为秒
DOCLING_MCP_SERVICE_MAX_RETRIES3最大重试次数
DOCLING_MCP_FALLBACK_TO_LOCALfalse服务无法访问时回退到本地(需要 docling-mcp[local])
转换管线(适用于两种模式)
变量默认值描述
DOCLING_MCP_KEEP_IMAGESfalse在输出中保留页面图像
DOCLING_MCP_IMAGES_SCALE1.0图像缩放系数(增大此值可避免张量填充错误)
DOCLING_MCP_DO_OCRtrue运行 OCR 管线
DOCLING_MCP_DO_TABLE_STRUCTUREtrue检测表格结构
DOCLING_MCP_DO_PICTURE_DESCRIPTIONfalse运行视觉语言模型,为图表和图片生成文本描述
DOCLING_MCP_PICTURE_DESCRIPTION_PRESET—图片描述 VLM 的预设 ID(例如 smolvlm、granite_vision)。未设置时使用后端默认值。仅在 DOCLING_MCP_DO_PICTURE_DESCRIPTION=true 时生效

提示

启用 DOCLING_MCP_DO_PICTURE_DESCRIPTION=true 后,文档中的每个图表都会增加一个 VLM 推理步骤。在资源受限的硬件上(例如在笔记本电脑上使用 CPU 运行模型),这会显著增加转换时间。

  • 远程模式 — 增大 DOCLING_MCP_SERVICE_TIMEOUT(单位为秒),为远程服务留出足够的完成时间。默认值为 300.0(5 分钟)。
  • 本地模式 / MCP 客户端超时 — MCP 客户端本身也可能会强制执行请求超时。例如,在 LM Studio 中,可在 mcp.json 中设置 timeout 字段(单位为毫秒):
{
  "mcpServers": {
    "docling": {
      "url": "http://localhost:8000/mcp",
      "timeout": 300000
    }
  }
}
Markdown 导出
变量默认值描述
DOCLING_MCP_IMAGE_EXPORT_MODEplaceholderMarkdown 输出中图像的呈现方式:placeholder(输出 ``)、embedded(base64 数据 URI)、referenced(文件路径 / URL)
缓存
变量默认值描述
DOCLING_MCP_CACHE_MAX_DOCUMENTS10内存缓存中保留的最大文档数。达到上限时,将移除最近最少使用的文档。
LlamaIndex RAG(--tools llama-index-rag)
变量默认值描述
DOCLING_MCP_LI_API_BASEhttp://127.0.0.1:1234/v1与 OpenAI 兼容的大模型端点
DOCLING_MCP_LI_API_KEYnone大模型端点的 API 密钥
DOCLING_MCP_LI_MODEL_IDibm/granite-3.2-8b大模型标识符
DOCLING_MCP_LI_EMBEDDING_MODELBAAI/bge-base-en-v1.5HuggingFace 嵌入模型
LlamaStack(--tools llama-stack-rag / --tools llama-stack-ie)
变量默认值描述
DOCLING_MCP_LLS_URLhttp://localhost:8321LlamaStack 服务 URL
DOCLING_MCP_LLS_VDB_EMBEDDINGall-MiniLM-L6-v2向量数据库的嵌入模型
DOCLING_MCP_LLS_EXTRACTION_MODELopenai/gpt-oss-20b用于结构化提取的模型
在 MCP 客户端配置中设置变量
{
  "mcpServers": {
    "docling": {
      "command": "uvx",
      "args": [
        "--from=docling-mcp",
        "docling-mcp-server"
      ],
      "env": {
        "DOCLING_MCP_CONVERSION_MODE": "remote",
        "DOCLING_MCP_SERVICE_URL": "https://your-docling-service.example.com",
        "DOCLING_MCP_SERVICE_API_KEY": "your-api-key-here"
      }
    }
  }
}

入门

安装 Docling MCP 并将其连接到客户端,最简单的方式是通过 uvx 启动。

根据所需的传输协议,指定参数 --transport,例如:

  • stdio,例如用于 Claude for Desktop 和 LM Studio

    uvx --from docling-mcp docling-mcp-server --transport stdio
    
  • sse,例如用于 Llama Stack

    uvx --from docling-mcp docling-mcp-server --transport sse
    
  • streamable-http,例如用于容器设置

    uvx --from docling-mcp docling-mcp-server --transport streamable-http
    

还有其他选项,例如选择要启动的工具组。使用 --help 参数查看所有 CLI 选项。

如需进一步开发 MCP 工具,请参阅 CONTRIBUTING.md 中的 开发 部分,了解相关说明。

与 MCP 客户端集成

试用 Docling MCP 提供的工具,最简单的方式之一是使用支持 MCP 的 AI 桌面客户端。 大多数此类客户端都使用通用配置接口。要在你常用的客户端中添加 Docling MCP,通常只需在配置文件中添加以下条目。

{
  "mcpServers": {
    "docling": {
      "command": "uvx",
      "args": [
        "--from=docling-mcp",
        "docling-mcp-server"
      ]
    }
  }
} 

使用 Claude for Desktop 时,只需编辑配置文件 claude_desktop_config.json,并加入上面的代码片段或此处提供的示例。

在 LM Studio 中,编辑 mcp.json 文件并添加相应部分,或直接点击下方按钮进行安装。

将 MCP 服务 docling 添加到 LM Studio

其他集成方式请参阅 [集成] 页面。

示例

转换文档

转换 PDF 文档的提示词示例:

Convert the PDF document at <provide file-path> into DoclingDocument and return its document-key.
生成文档

生成新文档的提示词示例:

I want you to write a Docling document. To do this, you will create a document first by invoking `create_new_docling_document`. Next you can add a title (by invoking `add_title_to_docling_document`) and then iteratively add new section-headings and paragraphs. If you want to insert lists (or nested lists), you will first open a list (by invoking `open_list_in_docling_document`), next add the list_items (by invoking `add_list_items_to_list_in_docling_document`). After adding list-items, you must close the list (by invoking `close_list_in_docling_document`). Nested lists can be created in the same way, by opening and closing additional lists.

During the writing process, you can check what has been written already by calling the `export_docling_document_to_markdown` tool, which will return the currently written document. At the end of the writing, you must save the document and return me the filepath of the saved document.

The document should investigate the impact of tokenizers on the quality of LLMs.

贡献

欢迎外部贡献。请参阅 CONTRIBUTING.md,了解如何开始。

许可证

Docling MCP 代码库采用 MIT 许可证。有关各个模型的使用,请参阅原始软件包中的模型许可证。

LF AI & Data

Docling 和 Docling MCP 是 LF AI & Data Foundation 下的一个项目。

IBM ❤️ 开源 AI:该项目由 IBM Research Zurich 的 AI for knowledge 团队发起。

评论

支持 Markdown

第一次接触 MCP?

从协议是什么,到在客户端里装上第一个服务,这几条回答覆盖了大多数入门问题。

一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。