Skip to main content

mcp-dharmamitra

MCP server that runs OCR on an image via the public Dharmamitra OCR endpoint and writes the extracted text to a local file. Optimised for Tibetan / Sanskrit / Devanagari input.

Tool

ocr_image

Argument Type Default Notes
image_path str Absolute path to a local image (png/jpg/…).
output_path str File to write UTF-8 text into. Parent dirs are created.
transliterate_devanagari_to_iast bool false Passed to the API.
transliterate_tibetan_to_wylie bool false Passed to the API.
instruction str "" Optional model instruction.
model str "auto" OCR model id.
poll_interval_seconds float 2.0 Delay between status polls.
timeout_seconds float 300.0 Overall polling deadline.

Returns a small JSON summary — the extracted text is written to output_path, not returned to the client.

{
  "job_id": "b8b26984b3ca49199c28303cad6a144d",
  "output_path": "/abs/path/out.txt",
  "pages": 1,
  "processing_time_seconds": 3.957,
  "chars": 1234
}

Install

uv sync                           # or: pip install -e '.[dev]'

Run locally with the MCP inspector:

uv run mcp dev src/mcp_dharmamitra/server.py

Run tests:

uv run pytest

Wire into Claude Desktop / Claude Code

~/Library/Application Support/Claude/claude_desktop_config.json:

{
    "mcpServers": {
      "dharmamitra": {
        "command": "uv",
        "args": ["--directory", "/path/mcp-dharmamitra", "run", "mcp-dharmamitra"],
        "env": {"DHARMAMITRA_COOKIE": ""}
      }
    }
  }

Docker

Build the image:

docker build -t mcp-dharmamitra:latest .

MCP talks over stdio, so the container must be run with -i (no -t). Mount a host directory that holds the input images — the tool arguments (image_path, output_path) are paths inside the container.

Smoke-test the entrypoint:

docker run --rm --entrypoint python mcp-dharmamitra:latest \
  -c "from mcp_dharmamitra.server import mcp; print(mcp.name)"

Wire the container into Claude Desktop / Claude Code

Replace /Users/aleksei/projects/ai/mcp-dharmamitra/tmp with any host directory you want the tool to be able to read/write. Files inside it will be visible under /data in the container.

{
  "mcpServers": {
    "dharmamitra": {
      "command": "docker",
      "args": [
        "run", "-i", "--rm",
        "-v", "/Users/aleksei/projects/ai/mcp-dharmamitra/tmp:/data",
        "-e", "DHARMAMITRA_COOKIE",
        "mcp-dharmamitra:latest"
      ],
      "env": {
        "DHARMAMITRA_COOKIE": ""
      }
    }
  }
}

Or the same via CLI:

claude mcp add dharmamitra \
  --scope project \
  -e DHARMAMITRA_COOKIE="" \
  -- docker run -i --rm \
       -v /Users/aleksei/projects/ai/mcp-dharmamitra/tmp:/data \
       -e DHARMAMITRA_COOKIE \
       mcp-dharmamitra:latest

When calling the tool, pass container paths. Example — image at <host>/tmp/text.png/data/text.png:

{
  "image_path": "/data/text.png",
  "output_path": "/data/text.txt"
}

The resulting text.txt appears in the mounted host directory.

Cloudflare / cf_clearance

The endpoint sits behind Cloudflare. Most requests go through without any cookie. If you start getting 403, grab a fresh cf_clearance value from a logged-in browser session on dharmamitra.org and export it:

export DHARMAMITRA_COOKIE='cf_clearance value here'

The server will attach it as a cookie on every request. Do not hardcode it — Cloudflare rotates the value.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mcp_dharmamitra-0.1.0.tar.gz (55.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mcp_dharmamitra-0.1.0-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

Details for the file mcp_dharmamitra-0.1.0.tar.gz.

File metadata

  • Download URL: mcp_dharmamitra-0.1.0.tar.gz
  • Upload date:
  • Size: 55.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.7

File hashes

Hashes for mcp_dharmamitra-0.1.0.tar.gz
Algorithm Hash digest
SHA256 90a428dcd87f2fce7854a79d81543b8e935f2cc6635d64c84d54a4723d24f14f
MD5 dcd6a6f615e4d5ce2da26dd1e9b7546e
BLAKE2b-256 0027d2ced23e6d2512b6df098f3a4e13f7500f76257cc7c574c5e298d2d47828

See more details on using hashes here.

File details

Details for the file mcp_dharmamitra-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for mcp_dharmamitra-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c5533dae96566c7d526cdbf0856ac01e06151ad181ac5a53f5f5b61b239cd892
MD5 bb73913a7535bbf540a545193aea4f08
BLAKE2b-256 ee1ad978e70d049505c6f852a1dab0df5a46e6fd1fc58c4dbc22fded41515b02

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 files

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