Skip to main content
Glama
zanetworker

MCP Docling Server

by zanetworker

MCP ドキュメントサーバー

Docling ライブラリを使用してドキュメント処理機能を提供する MCP サーバー。

インストール

pip を使用してパッケージをインストールできます。

pip install -e .

Related MCP server: MarkItDown MCP Server

使用法

stdio (デフォルト) または SSE トランスポートのいずれかを使用してサーバーを起動します。

# Using stdio transport (default)
mcp-server-lls

# Using SSE transport on custom port
mcp-server-lls --transport sse --port 8000

uv を使用している場合は、インストールせずにサーバーを直接実行できます。

# Using stdio transport (default)
uv run mcp-server-lls

# Using SSE transport on custom port
uv run mcp-server-lls --transport sse --port 8000

利用可能なツール

サーバーは次のツールを公開します。

  1. convert_document : URL またはローカルパスからマークダウン形式にドキュメントを変換します

    • source : ドキュメントへの URL またはローカルファイルパス (必須)

    • enable_ocr : スキャンしたドキュメントのOCRを有効にするかどうか(オプション、デフォルト: false)

    • ocr_language : OCRの言語コードのリスト、例: ["en", "fr"] (オプション)

  2. convert_document_with_images : ドキュメントを変換し、埋め込まれた画像を抽出する

    • source : ドキュメントへの URL またはローカルファイルパス (必須)

    • enable_ocr : スキャンしたドキュメントのOCRを有効にするかどうか(オプション、デフォルト: false)

    • ocr_language : OCRの言語コードのリスト(オプション)

  3. extract_tables : ドキュメントから表を構造化データとして抽出する

    • source : ドキュメントへの URL またはローカルファイルパス (必須)

  4. convert_batch : 複数のドキュメントをバッチモードで処理する

    • sources : ドキュメントへのURLまたはファイルパスのリスト(必須)

    • enable_ocr : スキャンしたドキュメントのOCRを有効にするかどうか(オプション、デフォルト: false)

    • ocr_language : OCRの言語コードのリスト(オプション)

  5. qna_from_document : URL またはローカル パスから YAML 形式で Q&A ドキュメントを作成します

    • source : ドキュメントへの URL またはローカルファイルパス (必須)

    • no_of_qnas : 予想されるQ&Aの数(オプション、デフォルト: 5)

    • : このツールでは、IBM Watson X の資格情報を環境変数として設定する必要があります。

      • WATSONX_PROJECT_ID : Watson X プロジェクト ID

      • WATSONX_APIKEY : IBM Cloud APIキー

      • WATSONX_URL : Watson X API URL (デフォルト: https://us-south.ml.cloud.ibm.com )

  6. get_system_info : システム構成と加速ステータスに関する情報を取得します

ラマスタックの例

https://github.com/user-attachments/assets/8ad34e50-cbf7-4ec8-aedd-71c42a5de0a1

このサーバーをLlama Stackと併用することで、LLMアプリケーションにドキュメント処理機能を提供できます。Llama Stackサーバーが稼働していることを確認し、 INFERENCE_MODELを設定してください。

from llama_stack_client.lib.agents.agent import Agent
from llama_stack_client.lib.agents.event_logger import EventLogger
from llama_stack_client.types.agent_create_params import AgentConfig
from llama_stack_client.types.shared_params.url import URL
from llama_stack_client import LlamaStackClient
import os

# Set your model ID
model_id = os.environ["INFERENCE_MODEL"]
client = LlamaStackClient(
    base_url=f"http://localhost:{os.environ.get('LLAMA_STACK_PORT', '8080')}"
)

# Register MCP tools
client.toolgroups.register(
    toolgroup_id="mcp::docling",
    provider_id="model-context-protocol",
    mcp_endpoint=URL(uri="http://0.0.0.0:8000/sse"))

# Define an agent with MCP toolgroup
agent_config = AgentConfig(
    model=model_id,
    instructions="""You are a helpful assistant with access to tools to manipulate documents.
Always use the appropriate tool when asked to process documents.""",
    toolgroups=["mcp::docling"],
    tool_choice="auto",
    max_tool_calls=3,
)

# Create the agent
agent = Agent(client, agent_config)

# Create a session
session_id = agent.create_session("test-session")

def _summary_and_qna(source: str):
    # Define the prompt
    run_turn(f"Please convert the document at {source} to markdown and summarize its content.")
    run_turn(f"Please generate a Q&A document with 3 items for source at {source} and display it in YAML format.")

def _run_turn(prompt):
    # Create a turn
    response = agent.create_turn(
        messages=[
            {
                "role": "user",
                "content": prompt,
            }
        ],
        session_id=session_id,
    )

    # Log the response
    for log in EventLogger().log(response):
        log.print()

_summary_and_qna('https://arxiv.org/pdf/2004.07606')

キャッシング

サーバーは、繰り返しのリクエストのパフォーマンスを向上させるために、処理済みのドキュメントを~/.cache/mcp-docling/にキャッシュします。

Install Server
A
license - permissive license
-
quality - not tested
C
maintenance

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/zanetworker/mcp-docling'

If you have feedback or need assistance with the MCP directory API, please join our Discord server