Skip to main content

SwissDocAI MCP server

Use SwissDocAI from Claude, Cursor, Codex or any other MCP client. It runs on your computer as a local MCP server (stdio). You give the AI a file path. The server reads the file itself and sends it to the SwissDocAI API (https://ocr.swissdocai.ch). The AI never has to copy the document into the conversation.

Tool What it does API
process_document OCR, classification into your workspace's labels and extraction of the label's fields. Optionally splits a PDF of several documents and writes each one as its own PDF. POST /v1/upload with async=true, GET /v1/jobs/{job_id}
ocr_document The text of a document as Markdown, with page markers and tables. POST /v1/ocr
analyze_layout Words, lines, paragraphs, tables and checkboxes with their boxes, in the shape of Azure AI Document Intelligence's prebuilt-layout. It writes the result to <name>.layout.json (beta). POST /v1/layout; from 11 pages, or while many requests are waiting, POST /v1/layout/jobs
redact_document Finds personal data and writes a redacted PDF, <name>.redacted.pdf, next to the source (beta). POST /v1/redact with render=true, GET /v1/redact/{job_id}

The document tools take PDF, PNG and JPEG files. Each page processed costs one page of your quota, the same as a direct API call.

The label tools manage the labels documents are classified into. They are free of charge, apart from classify_text.

Tool What it does API
list_labels, get_label The workspace's labels with description, examples, fields, file name template and revision. GET /v1/labels, GET /v1/labels/{label_id}
create_label A new label. POST /v1/labels
update_label Changes the fields given; needs the label's current revision. PATCH /v1/labels/{label_id} with If-Match
delete_label Deletes a label with all its revisions, for good. DELETE /v1/labels/{label_id} with If-Match
list_label_revisions, restore_label_revision Earlier states of a label (the last 50), and going back to one. GET .../revisions, POST .../revisions/{revision}/restore
classify_text Classifies a text into the labels, to check a change. One page of quota per call. POST /v1/classify

Labels

Any token can read labels. To create, change, restore or delete them, the token needs "Read and write" access to labels, which you choose when you create it in the console. With a read-only token these tools answer with a clear error.

A typical loop: read a label, change its description or examples, then check it with classify_text on the text of a document you know (run ocr_document once and reuse the text). Every change is kept as a revision, so restore_label_revision can undo it. update_label sends the revision it read as If-Match; if someone changed the label in the meantime, it is refused (412) instead of overwriting that change. Deleting a label cannot be undone. AI clients usually ask before running a tool marked as destructive, as delete_label is, but check the request before you approve it. At most 60 label changes per minute.

Where your data goes

SwissDocAI processes your documents in Switzerland. But this server hands the results (text, extracted fields, labels) back to your AI client. From there they go to the client's provider, for example Anthropic, Cursor or OpenAI, which may process them outside Switzerland. You decide whether that is allowed for your documents.

To keep a document's content on your computer, pass output_path. The server then writes the full result to that local file and sends only a short summary back to the AI: label, confidence and page count, no text or fields. analyze_layout and redact_document always write their results to a file. By default redact_document also leaves out the values it found (include_values=false), because those values are the personal data being removed.

The file name is only sent along with rename=true, which needs it for the suggested file name. Otherwise the document goes out as document.pdf. The server logs nothing: no contents, texts, values or file names.

Setup

You need:

  • An API token from the console (API-Tokens). Processing also needs labels; you create them in the console.
  • uv, which provides uvx.

uvx swissdocai-mcp downloads the server and starts it. You never start it yourself: the AI client does that. Replace sd_... with your token in the examples below.

Claude Code

claude mcp add --env SWISSDOCAI_API_TOKEN=sd_... --transport stdio swissdocai -- uvx swissdocai-mcp

Add --scope project to share the server with your team through .mcp.json. Then use ${SWISSDOCAI_API_TOKEN} instead of the token itself, so the token stays out of the repository:

{
  "mcpServers": {
    "swissdocai": {
      "command": "uvx",
      "args": ["swissdocai-mcp"],
      "env": { "SWISSDOCAI_API_TOKEN": "${SWISSDOCAI_API_TOKEN}" }
    }
  }
}

Claude Desktop

Quit Claude Desktop completely. Then edit claude_desktop_config.json:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
{
  "mcpServers": {
    "swissdocai": {
      "command": "uvx",
      "args": ["swissdocai-mcp"],
      "env": { "SWISSDOCAI_API_TOKEN": "sd_..." }
    }
  }
}

Cursor

In ~/.cursor/mcp.json (all projects) or .cursor/mcp.json (one project):

{
  "mcpServers": {
    "swissdocai": {
      "command": "uvx",
      "args": ["swissdocai-mcp"],
      "env": { "SWISSDOCAI_API_TOKEN": "sd_..." }
    }
  }
}

Codex

codex mcp add swissdocai --env SWISSDOCAI_API_TOKEN=sd_... -- uvx swissdocai-mcp

Or in ~/.codex/config.toml. Codex stops a tool after 60 seconds by default, which is too short for redaction and for long documents, so raise tool_timeout_sec. The first start downloads the server, so give it more time as well:

[mcp_servers.swissdocai]
command = "uvx"
args = ["swissdocai-mcp"]
startup_timeout_sec = 60
tool_timeout_sec = 1800

[mcp_servers.swissdocai.env]
SWISSDOCAI_API_TOKEN = "sd_..."

Examples

  • "Process ~/Scans/invoice-0425.pdf with SwissDocAI and give me the total and the IBAN."
  • "Split C:\Inbox\batch.pdf into its documents and save each one as its own PDF."
  • "Redact report.pdf and keep the clinic's name and address readable."
  • "Run OCR on contract.pdf and save the text to contract.md; don't show me the text."
  • "Show my labels. scan-17.pdf is a delivery note but comes out as an invoice: improve the labels until it is classified right, and tell me what you changed."
  • "Add a field Vertragsende (date) to the label contract."

Settings

Environment variable Default Meaning
SWISSDOCAI_API_TOKEN (required) API token from the console
SWISSDOCAI_BASE_URL https://ocr.swissdocai.ch Another endpoint, e.g. an on-premises installation
SWISSDOCAI_JOB_TIMEOUT_SECONDS 1800 How long a tool waits for a job (processing, layout, redaction)
SWISSDOCAI_POLL_INTERVAL_SECONDS 2 How often a running job is checked

Relative paths are resolved against the server's working directory, which depends on the client. Absolute paths always work.

Files the server writes

  • Never the source file, and never over an existing file it chose itself: if the name is taken, it writes name (2).ext. Only a file you name in output_path is overwritten.
  • analyze_layout: <name>.layout.json next to the source.
  • redact_document: <name>.redacted.pdf, or with render=false the findings with their boxes as <name>.redaction.json.
  • process_document with save_split_pdfs=true: <name>_01_p1-2.pdf, <name>_02_p3-3.pdf and so on.

Redaction is automatic: check the redacted PDF before you pass it on. The summary tells you how many values could not be located on the page (values_not_located), and whether the redacted pages, when read again, still show a value (verification).

Errors

API errors come back as tool errors that say what to do: an invalid token (401), no active plan (402), a read-only token or team (403), a label ID that already exists (409), a label changed in the meantime (412), a document too large (413), quota or rate limit reached (429, with the time to retry), or a busy service (503, nothing charged, try again shortly).

Development

uv sync
uv run pytest
uv run ruff check .
uv run swissdocai-mcp   # waits for an MCP client on stdin

The tests replace the network with a mock (httpx.MockTransport) and never call the API. To run your local checkout in a client, use uv run --directory /path/to/mcp-server swissdocai-mcp as the command instead of uvx swissdocai-mcp.

License

Apache License 2.0, full text in the LICENSE file that ships with the package. Copyright 2026 SwissDocAI.

The license covers this client only. The SwissDocAI service it calls is not part of the package and is used under the SwissDocAI terms of service (https://swissdocai.ch/agb).

Metadata

Release files for swissdocai-mcp 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for swissdocai-mcp 0.2.0
File Size Uploaded Provenance Actions
swissdocai_mcp-0.2.0.tar.gz 29.9 kB Without provenance Details for swissdocai_mcp-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for swissdocai-mcp 0.2.0
File Interpreter ABI Platform Actions
swissdocai_mcp-0.2.0-py3-none-any.whl Python 3 none any Details for swissdocai_mcp-0.2.0-py3-none-any.whl

Total release size: 54.5 kB

Release files / swissdocai_mcp-0.2.0.tar.gz

Download URL swissdocai_mcp-0.2.0.tar.gz
Size 29.9 kB
Tags Source
SHA-256 checksum
How to use checksums
6437b41ec52037361c4552ce8ad2e670d1d7d684d63a84d6bcf1813995a725fa
BLAKE2b-256 checksum
How to use checksums
1e2d1fb11ef2e607fe5132284dd449ef977e25dba9d935a701398892fff66a0a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / swissdocai_mcp-0.2.0-py3-none-any.whl

Download URL swissdocai_mcp-0.2.0-py3-none-any.whl
Size 24.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
94357a360308a335dd68984200652026f24cfe49f8d385198bdbacbd1806551f
BLAKE2b-256 checksum
How to use checksums
ee808e137476454a62c3616f335fb2039db3aae7b0f053f718144d1d9c487931
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for swissdocai-mcp 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page