docling-mcp 1.3.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- docling_mcp-1.3.3/.gitignore +185 -0
- docling_mcp-1.3.3/LICENSE +21 -0
- docling_mcp-1.3.3/PKG-INFO +182 -0
- docling_mcp-1.3.3/README.md +127 -0
- docling_mcp-1.3.3/docling_mcp/__init__.py +1 -0
- docling_mcp-1.3.3/docling_mcp/docling_cache.py +82 -0
- docling_mcp-1.3.3/docling_mcp/logger.py +25 -0
- docling_mcp-1.3.3/docling_mcp/servers/__init__.py +1 -0
- docling_mcp-1.3.3/docling_mcp/servers/mcp_server.py +87 -0
- docling_mcp-1.3.3/docling_mcp/settings/__init__.py +1 -0
- docling_mcp-1.3.3/docling_mcp/settings/conversion.py +17 -0
- docling_mcp-1.3.3/docling_mcp/settings/llama_index.py +20 -0
- docling_mcp-1.3.3/docling_mcp/settings/llama_stack.py +19 -0
- docling_mcp-1.3.3/docling_mcp/shared.py +15 -0
- docling_mcp-1.3.3/docling_mcp/tools/__init__.py +6 -0
- docling_mcp-1.3.3/docling_mcp/tools/conversion.py +272 -0
- docling_mcp-1.3.3/docling_mcp/tools/generation.py +573 -0
- docling_mcp-1.3.3/docling_mcp/tools/llama_index/__init__.py +1 -0
- docling_mcp-1.3.3/docling_mcp/tools/llama_index/_shared.py +29 -0
- docling_mcp-1.3.3/docling_mcp/tools/llama_index/milvus_rag.py +132 -0
- docling_mcp-1.3.3/docling_mcp/tools/llama_stack/__init__.py +1 -0
- docling_mcp-1.3.3/docling_mcp/tools/llama_stack/_shared.py +15 -0
- docling_mcp-1.3.3/docling_mcp/tools/llama_stack/rag.py +104 -0
- docling_mcp-1.3.3/docling_mcp/tools/llama_stack/structured_output.py +111 -0
- docling_mcp-1.3.3/docling_mcp/tools/manipulation.py +357 -0
- docling_mcp-1.3.3/pyproject.toml +226 -0
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
env.secrets
|
|
2
|
+
*~
|
|
3
|
+
**.DS_Store
|
|
4
|
+
_cache/**
|
|
5
|
+
|
|
6
|
+
*.mcpb
|
|
7
|
+
mcpb/assets/
|
|
8
|
+
|
|
9
|
+
# Byte-compiled / optimized / DLL files
|
|
10
|
+
__pycache__/
|
|
11
|
+
*.py[cod]
|
|
12
|
+
*$py.class
|
|
13
|
+
|
|
14
|
+
# C extensions
|
|
15
|
+
*.so
|
|
16
|
+
|
|
17
|
+
# Distribution / packaging
|
|
18
|
+
.Python
|
|
19
|
+
build/
|
|
20
|
+
develop-eggs/
|
|
21
|
+
dist/
|
|
22
|
+
downloads/
|
|
23
|
+
eggs/
|
|
24
|
+
.eggs/
|
|
25
|
+
lib/
|
|
26
|
+
lib64/
|
|
27
|
+
parts/
|
|
28
|
+
sdist/
|
|
29
|
+
var/
|
|
30
|
+
wheels/
|
|
31
|
+
share/python-wheels/
|
|
32
|
+
*.egg-info/
|
|
33
|
+
.installed.cfg
|
|
34
|
+
*.egg
|
|
35
|
+
MANIFEST
|
|
36
|
+
|
|
37
|
+
# PyInstaller
|
|
38
|
+
# Usually these files are written by a python script from a template
|
|
39
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
40
|
+
*.manifest
|
|
41
|
+
*.spec
|
|
42
|
+
|
|
43
|
+
# Installer logs
|
|
44
|
+
pip-log.txt
|
|
45
|
+
pip-delete-this-directory.txt
|
|
46
|
+
|
|
47
|
+
# Unit test / coverage reports
|
|
48
|
+
htmlcov/
|
|
49
|
+
.tox/
|
|
50
|
+
.nox/
|
|
51
|
+
.coverage
|
|
52
|
+
.coverage.*
|
|
53
|
+
.cache
|
|
54
|
+
nosetests.xml
|
|
55
|
+
coverage.xml
|
|
56
|
+
*.cover
|
|
57
|
+
*.py,cover
|
|
58
|
+
.hypothesis/
|
|
59
|
+
.pytest_cache/
|
|
60
|
+
cover/
|
|
61
|
+
|
|
62
|
+
# Translations
|
|
63
|
+
*.mo
|
|
64
|
+
*.pot
|
|
65
|
+
|
|
66
|
+
# Django stuff:
|
|
67
|
+
*.log
|
|
68
|
+
local_settings.py
|
|
69
|
+
db.sqlite3
|
|
70
|
+
db.sqlite3-journal
|
|
71
|
+
|
|
72
|
+
# Flask stuff:
|
|
73
|
+
instance/
|
|
74
|
+
.webassets-cache
|
|
75
|
+
|
|
76
|
+
# Scrapy stuff:
|
|
77
|
+
.scrapy
|
|
78
|
+
|
|
79
|
+
# Sphinx documentation
|
|
80
|
+
docs/_build/
|
|
81
|
+
|
|
82
|
+
# PyBuilder
|
|
83
|
+
.pybuilder/
|
|
84
|
+
target/
|
|
85
|
+
|
|
86
|
+
# Jupyter Notebook
|
|
87
|
+
.ipynb_checkpoints
|
|
88
|
+
|
|
89
|
+
# IPython
|
|
90
|
+
profile_default/
|
|
91
|
+
ipython_config.py
|
|
92
|
+
|
|
93
|
+
# pyenv
|
|
94
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
95
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
96
|
+
# .python-version
|
|
97
|
+
|
|
98
|
+
# pipenv
|
|
99
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
100
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
101
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
102
|
+
# install all needed dependencies.
|
|
103
|
+
#Pipfile.lock
|
|
104
|
+
|
|
105
|
+
# UV
|
|
106
|
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
|
107
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
108
|
+
# commonly ignored for libraries.
|
|
109
|
+
#uv.lock
|
|
110
|
+
|
|
111
|
+
# poetry
|
|
112
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
113
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
114
|
+
# commonly ignored for libraries.
|
|
115
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
116
|
+
#poetry.lock
|
|
117
|
+
|
|
118
|
+
# pdm
|
|
119
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
120
|
+
#pdm.lock
|
|
121
|
+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
|
122
|
+
# in version control.
|
|
123
|
+
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
|
|
124
|
+
.pdm.toml
|
|
125
|
+
.pdm-python
|
|
126
|
+
.pdm-build/
|
|
127
|
+
|
|
128
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
129
|
+
__pypackages__/
|
|
130
|
+
|
|
131
|
+
# Celery stuff
|
|
132
|
+
celerybeat-schedule
|
|
133
|
+
celerybeat.pid
|
|
134
|
+
|
|
135
|
+
# SageMath parsed files
|
|
136
|
+
*.sage.py
|
|
137
|
+
|
|
138
|
+
# Environments
|
|
139
|
+
.env
|
|
140
|
+
.venv
|
|
141
|
+
env/
|
|
142
|
+
venv/
|
|
143
|
+
ENV/
|
|
144
|
+
env.bak/
|
|
145
|
+
venv.bak/
|
|
146
|
+
|
|
147
|
+
# Spyder project settings
|
|
148
|
+
.spyderproject
|
|
149
|
+
.spyproject
|
|
150
|
+
|
|
151
|
+
# Rope project settings
|
|
152
|
+
.ropeproject
|
|
153
|
+
|
|
154
|
+
# mkdocs documentation
|
|
155
|
+
/site
|
|
156
|
+
|
|
157
|
+
# mypy
|
|
158
|
+
.mypy_cache/
|
|
159
|
+
.dmypy.json
|
|
160
|
+
dmypy.json
|
|
161
|
+
|
|
162
|
+
# Pyre type checker
|
|
163
|
+
.pyre/
|
|
164
|
+
|
|
165
|
+
# pytype static type analyzer
|
|
166
|
+
.pytype/
|
|
167
|
+
|
|
168
|
+
# Cython debug symbols
|
|
169
|
+
cython_debug/
|
|
170
|
+
|
|
171
|
+
# PyCharm
|
|
172
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
173
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
174
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
175
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
176
|
+
#.idea/
|
|
177
|
+
|
|
178
|
+
# Ruff stuff:
|
|
179
|
+
.ruff_cache/
|
|
180
|
+
|
|
181
|
+
# PyPI configuration file
|
|
182
|
+
.pypirc
|
|
183
|
+
|
|
184
|
+
# Milvus local databases
|
|
185
|
+
*.db
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Docling Project
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: docling-mcp
|
|
3
|
+
Version: 1.3.3
|
|
4
|
+
Summary: Running Docling as an agent using tools
|
|
5
|
+
Project-URL: Homepage, https://github.com/docling-project/docling-mcp
|
|
6
|
+
Project-URL: Repository, https://github.com/docling-project/docling-mcp
|
|
7
|
+
Project-URL: Issues, https://github.com/docling-project/docling-mcp/issues
|
|
8
|
+
Project-URL: Changelog, https://github.com/docling-project/docling-mcp/blob/main/CHANGELOG.md
|
|
9
|
+
Author-email: Peter Staar <taa@zurich.ibm.com>, Adel Zaalouk <azaalouk@redhat.com>, Michele Dolfi <dol@zurich.ibm.com>, Panos Vagenas <pva@zurich.ibm.com>, Christoph Auer <cau@zurich.ibm.com>, Cesar Berrospi Ramis <ceb@zurich.ibm.com>
|
|
10
|
+
Maintainer-email: Peter Staar <taa@zurich.ibm.com>, Adel Zaalouk <azaalouk@redhat.com>, Michele Dolfi <dol@zurich.ibm.com>, Panos Vagenas <pva@zurich.ibm.com>, Christoph Auer <cau@zurich.ibm.com>, Cesar Berrospi Ramis <ceb@zurich.ibm.com>
|
|
11
|
+
License-Expression: MIT
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Keywords: AI,Docling,RAG,agentic,agents,artificial intelligence,document understanding,mcp,message control protocol
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Intended Audience :: Science/Research
|
|
16
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
17
|
+
Classifier: Operating System :: OS Independent
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
23
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
24
|
+
Classifier: Topic :: Software Development :: Build Tools
|
|
25
|
+
Classifier: Typing :: Typed
|
|
26
|
+
Requires-Python: >=3.10
|
|
27
|
+
Requires-Dist: docling-core>=2.51.0
|
|
28
|
+
Requires-Dist: docling~=2.25
|
|
29
|
+
Requires-Dist: httpx>=0.28.1
|
|
30
|
+
Requires-Dist: mcp[cli]>=1.9.4
|
|
31
|
+
Requires-Dist: pydantic-settings~=2.4
|
|
32
|
+
Requires-Dist: pydantic~=2.10
|
|
33
|
+
Requires-Dist: python-dotenv>=1.1.0
|
|
34
|
+
Provides-Extra: llama-index-rag
|
|
35
|
+
Requires-Dist: llama-index-core>=0.12.28; extra == 'llama-index-rag'
|
|
36
|
+
Requires-Dist: llama-index-embeddings-huggingface>=0.5.2; extra == 'llama-index-rag'
|
|
37
|
+
Requires-Dist: llama-index-embeddings-openai>=0.3.1; extra == 'llama-index-rag'
|
|
38
|
+
Requires-Dist: llama-index-llms-openai-like>=0.3.0; extra == 'llama-index-rag'
|
|
39
|
+
Requires-Dist: llama-index-node-parser-docling>=0.3.1; extra == 'llama-index-rag'
|
|
40
|
+
Requires-Dist: llama-index-readers-docling>=0.3.2; extra == 'llama-index-rag'
|
|
41
|
+
Requires-Dist: llama-index-readers-file>=0.4.7; extra == 'llama-index-rag'
|
|
42
|
+
Requires-Dist: llama-index-vector-stores-milvus>=0.7.2; extra == 'llama-index-rag'
|
|
43
|
+
Requires-Dist: llama-index>=0.12.33; extra == 'llama-index-rag'
|
|
44
|
+
Provides-Extra: llama-stack
|
|
45
|
+
Requires-Dist: llama-stack-client<0.2.18,>=0.2.14; (python_version >= '3.12') and extra == 'llama-stack'
|
|
46
|
+
Provides-Extra: mellea
|
|
47
|
+
Requires-Dist: mellea>=0.0.2; extra == 'mellea'
|
|
48
|
+
Provides-Extra: smolagents
|
|
49
|
+
Requires-Dist: accelerate>=0.20.0; extra == 'smolagents'
|
|
50
|
+
Requires-Dist: ollama>=0.1.0; extra == 'smolagents'
|
|
51
|
+
Requires-Dist: smolagents[litellm,mcp]>=1.0.0; extra == 'smolagents'
|
|
52
|
+
Requires-Dist: torch>=2.0.0; extra == 'smolagents'
|
|
53
|
+
Requires-Dist: transformers>=4.30.0; extra == 'smolagents'
|
|
54
|
+
Description-Content-Type: text/markdown
|
|
55
|
+
|
|
56
|
+
<p align="center">
|
|
57
|
+
<a href="https://github.com/docling-project/docling-mcp">
|
|
58
|
+
<img loading="lazy" alt="Docling" src="https://github.com/docling-project/docling-mcp/raw/main/docs/assets/docling_mcp.png" width="40%"/>
|
|
59
|
+
</a>
|
|
60
|
+
</p>
|
|
61
|
+
|
|
62
|
+
# Docling MCP: making docling agentic
|
|
63
|
+
|
|
64
|
+
[](https://pypi.org/project/docling-mcp/)
|
|
65
|
+
[](https://pypi.org/project/docling-mcp/)
|
|
66
|
+
[](https://github.com/astral-sh/uv)
|
|
67
|
+
[](https://github.com/astral-sh/ruff)
|
|
68
|
+
[](https://pydantic.dev)
|
|
69
|
+
[](https://github.com/pre-commit/pre-commit)
|
|
70
|
+
[](https://opensource.org/licenses/MIT)
|
|
71
|
+
[](https://pepy.tech/projects/docling-mcp)
|
|
72
|
+
[](https://lfaidata.foundation/projects/)
|
|
73
|
+
|
|
74
|
+
A document processing service using the Docling-MCP library and MCP (Model Context Protocol) for tool integration.
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
## Overview
|
|
78
|
+
|
|
79
|
+
Docling MCP is a service that provides tools for document conversion, processing and generation. It uses the Docling library to convert PDF documents into structured formats and provides a caching mechanism to improve performance. The service exposes functionality through a set of tools that can be called by client applications.
|
|
80
|
+
|
|
81
|
+
## Features
|
|
82
|
+
|
|
83
|
+
- Conversion tools:
|
|
84
|
+
- PDF document conversion to structured JSON format (DoclingDocument)
|
|
85
|
+
- Generation tools:
|
|
86
|
+
- Document generation in DoclingDocument, which can be exported to multiple formats
|
|
87
|
+
- Local document caching for improved performance
|
|
88
|
+
- Support for local files and URLs as document sources
|
|
89
|
+
- Memory management for handling large documents
|
|
90
|
+
- Logging system for debugging and monitoring
|
|
91
|
+
- RAG applications with Milvus upload and retrieval
|
|
92
|
+
|
|
93
|
+
## Getting started
|
|
94
|
+
|
|
95
|
+
The easiest way to install Docling MCP is connect it to your client is launching it via [uvx](https://docs.astral.sh/uv/).
|
|
96
|
+
|
|
97
|
+
Depending on the transfer protocol required, specify the argument `--transport`, for example
|
|
98
|
+
|
|
99
|
+
- **`stdio`** used e.g. in Claude for Desktop and LM Studio
|
|
100
|
+
|
|
101
|
+
```sh
|
|
102
|
+
uvx --from docling-mcp docling-mcp-server --transport stdio
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
- **`sse`** used e.g. in Llama Stack
|
|
106
|
+
|
|
107
|
+
```sh
|
|
108
|
+
uvx --from docling-mcp docling-mcp-server --transport sse
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
- **`streamable-http`** used e.g. in containers setup
|
|
113
|
+
|
|
114
|
+
```sh
|
|
115
|
+
uvx --from docling-mcp docling-mcp-server --transport streamable-http
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
More options are available, e.g. the selection of which toolgroup to launch. Use the `--help` argument to inspect all the CLI options.
|
|
119
|
+
|
|
120
|
+
For developing the MCP tools further, please refer to the [docs/development.md](docs/development.md) page for instructions.
|
|
121
|
+
|
|
122
|
+
## Integration with MCP clients
|
|
123
|
+
|
|
124
|
+
One of the easiest ways to experiment with the tools provided by Docling MCP is to leverage an AI desktop client with MCP support.
|
|
125
|
+
Most of these clients use a common config interface. Adding Docling MCP in your favorite client is usually as simple as adding the following entry in the configuration file.
|
|
126
|
+
|
|
127
|
+
```json
|
|
128
|
+
{
|
|
129
|
+
"mcpServers": {
|
|
130
|
+
"docling": {
|
|
131
|
+
"command": "uvx",
|
|
132
|
+
"args": [
|
|
133
|
+
"--from=docling-mcp",
|
|
134
|
+
"docling-mcp-server"
|
|
135
|
+
]
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
When using **[Claude for Desktop](https://claude.ai/download)**, simply edit the config file `claude_desktop_config.json` with the snippet above or the example provided [here](docs/integrations/claude_desktop_config.json).
|
|
142
|
+
|
|
143
|
+
In **[LM Studio](https://lmstudio.ai/)**, edit the `mcp.json` file with the appropriate section or simply clik on the button below for a direct install.
|
|
144
|
+
|
|
145
|
+
[](https://lmstudio.ai/install-mcp?name=docling&config=eyJjb21tYW5kIjoidXZ4IiwiYXJncyI6WyItLWZyb209ZG9jbGluZy1tY3AiLCJkb2NsaW5nLW1jcC1zZXJ2ZXIiXX0%3D)
|
|
146
|
+
|
|
147
|
+
Other integrations are described in [./docs/integrations/](./docs/integrations/).
|
|
148
|
+
|
|
149
|
+
## Examples
|
|
150
|
+
|
|
151
|
+
### Converting documents
|
|
152
|
+
|
|
153
|
+
Example of prompt for converting PDF documents:
|
|
154
|
+
|
|
155
|
+
```prompt
|
|
156
|
+
Convert the PDF document at <provide file-path> into DoclingDocument and return its document-key.
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
### Generating documents
|
|
160
|
+
|
|
161
|
+
Example of prompt for generating new documents:
|
|
162
|
+
|
|
163
|
+
```prompt
|
|
164
|
+
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_listitem_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.
|
|
165
|
+
|
|
166
|
+
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.
|
|
167
|
+
|
|
168
|
+
The document should investigate the impact of tokenizers on the quality of LLMs.
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
## License
|
|
172
|
+
|
|
173
|
+
The Docling MCP codebase is under MIT license. For individual model usage, please refer to the model licenses found in the original packages.
|
|
174
|
+
|
|
175
|
+
## LF AI & Data
|
|
176
|
+
|
|
177
|
+
Docling and Docling MCP is hosted as a project in the [LF AI & Data Foundation](https://lfaidata.foundation/projects/).
|
|
178
|
+
|
|
179
|
+
**IBM ❤️ Open Source AI**: The project was started by the AI for knowledge team at IBM Research Zurich.
|
|
180
|
+
|
|
181
|
+
[docling_document]: https://docling-project.github.io/docling/concepts/docling_document/
|
|
182
|
+
[integrations]: https://docling-project.github.io/docling-mcp/integrations/
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="https://github.com/docling-project/docling-mcp">
|
|
3
|
+
<img loading="lazy" alt="Docling" src="https://github.com/docling-project/docling-mcp/raw/main/docs/assets/docling_mcp.png" width="40%"/>
|
|
4
|
+
</a>
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
# Docling MCP: making docling agentic
|
|
8
|
+
|
|
9
|
+
[](https://pypi.org/project/docling-mcp/)
|
|
10
|
+
[](https://pypi.org/project/docling-mcp/)
|
|
11
|
+
[](https://github.com/astral-sh/uv)
|
|
12
|
+
[](https://github.com/astral-sh/ruff)
|
|
13
|
+
[](https://pydantic.dev)
|
|
14
|
+
[](https://github.com/pre-commit/pre-commit)
|
|
15
|
+
[](https://opensource.org/licenses/MIT)
|
|
16
|
+
[](https://pepy.tech/projects/docling-mcp)
|
|
17
|
+
[](https://lfaidata.foundation/projects/)
|
|
18
|
+
|
|
19
|
+
A document processing service using the Docling-MCP library and MCP (Model Context Protocol) for tool integration.
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
## Overview
|
|
23
|
+
|
|
24
|
+
Docling MCP is a service that provides tools for document conversion, processing and generation. It uses the Docling library to convert PDF documents into structured formats and provides a caching mechanism to improve performance. The service exposes functionality through a set of tools that can be called by client applications.
|
|
25
|
+
|
|
26
|
+
## Features
|
|
27
|
+
|
|
28
|
+
- Conversion tools:
|
|
29
|
+
- PDF document conversion to structured JSON format (DoclingDocument)
|
|
30
|
+
- Generation tools:
|
|
31
|
+
- Document generation in DoclingDocument, which can be exported to multiple formats
|
|
32
|
+
- Local document caching for improved performance
|
|
33
|
+
- Support for local files and URLs as document sources
|
|
34
|
+
- Memory management for handling large documents
|
|
35
|
+
- Logging system for debugging and monitoring
|
|
36
|
+
- RAG applications with Milvus upload and retrieval
|
|
37
|
+
|
|
38
|
+
## Getting started
|
|
39
|
+
|
|
40
|
+
The easiest way to install Docling MCP is connect it to your client is launching it via [uvx](https://docs.astral.sh/uv/).
|
|
41
|
+
|
|
42
|
+
Depending on the transfer protocol required, specify the argument `--transport`, for example
|
|
43
|
+
|
|
44
|
+
- **`stdio`** used e.g. in Claude for Desktop and LM Studio
|
|
45
|
+
|
|
46
|
+
```sh
|
|
47
|
+
uvx --from docling-mcp docling-mcp-server --transport stdio
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
- **`sse`** used e.g. in Llama Stack
|
|
51
|
+
|
|
52
|
+
```sh
|
|
53
|
+
uvx --from docling-mcp docling-mcp-server --transport sse
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
- **`streamable-http`** used e.g. in containers setup
|
|
58
|
+
|
|
59
|
+
```sh
|
|
60
|
+
uvx --from docling-mcp docling-mcp-server --transport streamable-http
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
More options are available, e.g. the selection of which toolgroup to launch. Use the `--help` argument to inspect all the CLI options.
|
|
64
|
+
|
|
65
|
+
For developing the MCP tools further, please refer to the [docs/development.md](docs/development.md) page for instructions.
|
|
66
|
+
|
|
67
|
+
## Integration with MCP clients
|
|
68
|
+
|
|
69
|
+
One of the easiest ways to experiment with the tools provided by Docling MCP is to leverage an AI desktop client with MCP support.
|
|
70
|
+
Most of these clients use a common config interface. Adding Docling MCP in your favorite client is usually as simple as adding the following entry in the configuration file.
|
|
71
|
+
|
|
72
|
+
```json
|
|
73
|
+
{
|
|
74
|
+
"mcpServers": {
|
|
75
|
+
"docling": {
|
|
76
|
+
"command": "uvx",
|
|
77
|
+
"args": [
|
|
78
|
+
"--from=docling-mcp",
|
|
79
|
+
"docling-mcp-server"
|
|
80
|
+
]
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
When using **[Claude for Desktop](https://claude.ai/download)**, simply edit the config file `claude_desktop_config.json` with the snippet above or the example provided [here](docs/integrations/claude_desktop_config.json).
|
|
87
|
+
|
|
88
|
+
In **[LM Studio](https://lmstudio.ai/)**, edit the `mcp.json` file with the appropriate section or simply clik on the button below for a direct install.
|
|
89
|
+
|
|
90
|
+
[](https://lmstudio.ai/install-mcp?name=docling&config=eyJjb21tYW5kIjoidXZ4IiwiYXJncyI6WyItLWZyb209ZG9jbGluZy1tY3AiLCJkb2NsaW5nLW1jcC1zZXJ2ZXIiXX0%3D)
|
|
91
|
+
|
|
92
|
+
Other integrations are described in [./docs/integrations/](./docs/integrations/).
|
|
93
|
+
|
|
94
|
+
## Examples
|
|
95
|
+
|
|
96
|
+
### Converting documents
|
|
97
|
+
|
|
98
|
+
Example of prompt for converting PDF documents:
|
|
99
|
+
|
|
100
|
+
```prompt
|
|
101
|
+
Convert the PDF document at <provide file-path> into DoclingDocument and return its document-key.
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### Generating documents
|
|
105
|
+
|
|
106
|
+
Example of prompt for generating new documents:
|
|
107
|
+
|
|
108
|
+
```prompt
|
|
109
|
+
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_listitem_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.
|
|
110
|
+
|
|
111
|
+
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.
|
|
112
|
+
|
|
113
|
+
The document should investigate the impact of tokenizers on the quality of LLMs.
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## License
|
|
117
|
+
|
|
118
|
+
The Docling MCP codebase is under MIT license. For individual model usage, please refer to the model licenses found in the original packages.
|
|
119
|
+
|
|
120
|
+
## LF AI & Data
|
|
121
|
+
|
|
122
|
+
Docling and Docling MCP is hosted as a project in the [LF AI & Data Foundation](https://lfaidata.foundation/projects/).
|
|
123
|
+
|
|
124
|
+
**IBM ❤️ Open Source AI**: The project was started by the AI for knowledge team at IBM Research Zurich.
|
|
125
|
+
|
|
126
|
+
[docling_document]: https://docling-project.github.io/docling/concepts/docling_document/
|
|
127
|
+
[integrations]: https://docling-project.github.io/docling-mcp/integrations/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Main package for Docling MCP server."""
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"""This module manages the cache directory to run Docling MCP tools."""
|
|
2
|
+
|
|
3
|
+
import hashlib
|
|
4
|
+
import json
|
|
5
|
+
import os
|
|
6
|
+
import sys
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
from typing import Optional
|
|
9
|
+
|
|
10
|
+
from docling_mcp.logger import setup_logger
|
|
11
|
+
|
|
12
|
+
# Create a default project logger
|
|
13
|
+
logger = setup_logger()
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def hash_string(input_string: str) -> str:
|
|
17
|
+
"""Creates a hash-string from the input string."""
|
|
18
|
+
return hashlib.sha256(input_string.encode(), usedforsecurity=False).hexdigest()
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def get_cache_dir() -> Path:
|
|
22
|
+
"""Get the cache directory for the application.
|
|
23
|
+
|
|
24
|
+
Returns:
|
|
25
|
+
Path: A Path object pointing to the cache directory.
|
|
26
|
+
|
|
27
|
+
The function will:
|
|
28
|
+
1. First check for an environment variable 'CACHE_DIR'
|
|
29
|
+
2. If not found, create a '_cache' directory in the root of the current package
|
|
30
|
+
3. Ensure the directory exists before returning
|
|
31
|
+
"""
|
|
32
|
+
# Check if cache directory is specified in environment variable
|
|
33
|
+
cache_dir = os.environ.get("CACHE_DIR")
|
|
34
|
+
|
|
35
|
+
if cache_dir:
|
|
36
|
+
# Use the directory specified in the environment variable
|
|
37
|
+
cache_path = Path(cache_dir)
|
|
38
|
+
else:
|
|
39
|
+
# Determine the package root directory
|
|
40
|
+
if getattr(sys, "frozen", False):
|
|
41
|
+
# Handle PyInstaller case
|
|
42
|
+
package_root = Path(os.path.dirname(sys.executable))
|
|
43
|
+
else:
|
|
44
|
+
# Get the directory of the caller's module
|
|
45
|
+
caller_file = sys._getframe(1).f_globals.get("__file__")
|
|
46
|
+
|
|
47
|
+
if caller_file:
|
|
48
|
+
# If running as a script or module
|
|
49
|
+
current_path = Path(caller_file).resolve()
|
|
50
|
+
|
|
51
|
+
# Find the package root by looking for the highest directory with an __init__.py
|
|
52
|
+
package_root = current_path.parent
|
|
53
|
+
while package_root.joinpath("__init__.py").exists():
|
|
54
|
+
package_root = package_root.parent
|
|
55
|
+
else:
|
|
56
|
+
# Fallback to current working directory if __file__ is not available
|
|
57
|
+
package_root = Path.cwd()
|
|
58
|
+
|
|
59
|
+
logger.info(f"package-root: {package_root}")
|
|
60
|
+
|
|
61
|
+
# Create the cache directory path
|
|
62
|
+
cache_path = package_root / "_cache"
|
|
63
|
+
|
|
64
|
+
# Ensure cache directory exists
|
|
65
|
+
logger.info(f"cache-path: {cache_path}")
|
|
66
|
+
os.makedirs(cache_path, exist_ok=True)
|
|
67
|
+
|
|
68
|
+
return cache_path
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def get_cache_key(
|
|
72
|
+
source: str, enable_ocr: bool = False, ocr_language: Optional[list[str]] = None
|
|
73
|
+
) -> str:
|
|
74
|
+
"""Generate a cache key for the document conversion."""
|
|
75
|
+
key_data = {
|
|
76
|
+
"source": source,
|
|
77
|
+
"enable_ocr": enable_ocr,
|
|
78
|
+
"ocr_language": ocr_language or [],
|
|
79
|
+
}
|
|
80
|
+
key_str = json.dumps(key_data, sort_keys=True)
|
|
81
|
+
hash = hash_string(key_str)
|
|
82
|
+
return hash[:32]
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"""Utility module for logging."""
|
|
2
|
+
|
|
3
|
+
import logging
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def setup_logger() -> logging.Logger:
|
|
7
|
+
"""Setup and return a logger for the entire project."""
|
|
8
|
+
# Create logger
|
|
9
|
+
logger = logging.getLogger("docling_mcp")
|
|
10
|
+
logger.setLevel(logging.INFO)
|
|
11
|
+
|
|
12
|
+
# Create a handler and set its level to INFO
|
|
13
|
+
handler = logging.StreamHandler()
|
|
14
|
+
handler.setLevel(logging.INFO)
|
|
15
|
+
|
|
16
|
+
# Create a formatter and add it to the handler
|
|
17
|
+
formatter = logging.Formatter(
|
|
18
|
+
"%(asctime)s - %(name)s - %(levelname)s - %(message)s"
|
|
19
|
+
)
|
|
20
|
+
handler.setFormatter(formatter)
|
|
21
|
+
|
|
22
|
+
# Add the handler to the logger
|
|
23
|
+
logger.addHandler(handler)
|
|
24
|
+
|
|
25
|
+
return logger
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""MCP Servers."""
|