Skip to main content

Module mcp

Module mcp 

Source
Expand description

docling-rs mcp (#669): a Model Context Protocol server, so agents — Claude Desktop, Claude Code, IDE assistants — call docling.rs directly.

Three tools:

  • convert_to_markdown(uri) — MarkItDown’s MCP tool (markitdown-mcp), same name and contract, so a config that pointed at MarkItDown keeps working: the document behind an http:/https:/file:/data: URI as Markdown. A plain path is accepted too.
  • convert(uri, to?, images?, options?) — any output format docling.rs writes as text, with the conversion options every other surface takes (docling::ConvertOptions, docs/OPTIONS.md).
  • list_input_formats() — the extensions this binary converts.

Transports: stdio (the default — what a desktop client launches) or Streamable HTTP with --http (/mcp on --host/--port, 127.0.0.1:3001 by default), both through rmcp, the protocol’s official Rust SDK.

The server reads files and, when allowed, the network on behalf of a model, whose inputs may be steered by the documents it reads — so what a call can reach is the operator’s decision, made on the command line:

  • local reads are confined to --root DIR (repeatable; the working directory by default) — paths are checked lexically first, so a probe outside the root learns nothing about what exists there, then after resolving symlinks;
  • URLs are fetched only with --allow-url-fetch, through docling::fetch: the SSRF block-list on every redirect hop, a size cap (DOCLING_RS_MAX_FETCH_BYTES, 256 MiB) and timeouts. The options that reach the network on their own — remote <img src> (image_sources=remote), a request-supplied vlm_endpoint, the headless browser — sit behind the same flag, docling-serve’s rules; options that name files (xbrl_taxonomy, a copybook path in ebcdic_layout) are held to the root;
  • --http binds loopback unless --allow-remote, checks the Host header (DNS rebinding) and the browser Origin on a loopback bind, and takes an optional bearer token (--bearer-token / DOCLING_RS_MCP_TOKEN).

Conversions run on the blocking pool, at most --concurrency (2) at a time; a call that carries a progress token gets a heartbeat notifications/progress every 10 s, so clients that reset their request timeout on progress wait out a long PDF. stdout is the stdio transport’s wire — everything else the process says goes to stderr.

The same server runs from the docling-rs binary (run) and from embedders such as the Python package’s docling-rs-mcp launcher (run_with and a Launcher naming the command and where its PDF models come from).

Structs§

Launcher
How the server presents itself: the command that starts it (in --help, usage errors and the startup line), the client configuration --help shows, and how to get the PDF models when they are missing. The binary uses Launcher::CLI.

Functions§

run
docling-rs mcp … — parse the flags, then serve until the client hangs up (stdio) or Ctrl-C (HTTP).
run_with
run for an embedder: the flags after the command, how the server should name itself; returns the process exit status (0, 1 on a serving error, 2 on a usage error). Call it before other threads read the environment — it defaults DOCLING_RS_NO_ARENA.