roshan-alefba-mcp
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@roshan-alefba-mcp read a Persian invoice from URL"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
roshan-alefba-mcp
A self-hostable Model Context Protocol server for Roshan AI's OCR service Alefba (الفبا).
Unofficial, community-built. Wraps the public API documented at docs.roshan-ai.ir.
What is this?
Alefba (الفبا) is Roshan AI's high-accuracy OCR / document-understanding service for Persian (fa), Arabic (ar) and English (en). Give it an image or PDF and it returns the text split into pages, paragraphs and lines — each with its bounding box, direction and recognition confidence — and it can tell tables, images and text apart. It also exports the analyzed document as a searchable PDF, Word or Excel file.
This server exposes Alefba to any MCP client (Claude or otherwise) as a set of
first-class tools. Alefba is commonly self-hosted, and organizations often
run many independent instances (per data-center, tenant, or environment), so
named instances are a core concept here: every tool takes an optional instance
argument selecting which deployment to talk to.
Related MCP server: OwlOCR MCP
Features
All Alefba endpoints as tools, prefixed
alefba_(read, pages, status, download to PDF/Word/Excel, delete, callback).URL input and local-file upload (multipart).
Async OCR: queue with
wait=false, then poll withalefba_get_result.Many named, self-hosted instances; pick per call via
instance.Guardrails: http(s) URL validation, enum/number clamping, list-size limits, and token redaction — tokens are never logged or returned.
Transports:
stdio(default),sse,streamable-http.
Install
Requires Python 3.10+.
git clone <this-repo>
cd roshan-alefba-mcp
python -m venv .venv && . .venv/bin/activate
pip install -e ".[dev]" # runtime + test deps (omit [dev] for runtime only)Run it:
python -m roshan_alefba_mcp --help
python -m roshan_alefba_mcp --transport stdio # default
python -m roshan_alefba_mcp --transport streamable-httpConfiguration
Configuration is read from environment variables. The simplest setup uses the
shorthand form, which synthesizes a single instance named default:
Variable | Description | Default |
| Base URL of the default Alefba instance |
|
| API token for the default instance (sent as | (none) |
For multiple instances, use the nested form (one base_url + token per
instance):
Variable | Description |
| Base URL for instance |
| Token for instance |
| Verify TLS for |
| Request timeout in seconds (default |
| Instance used when a call omits |
| Log level (default |
Example (two instances, default = dc1):
export ROSHAN_ALEFBA__INSTANCES__DC1__BASE_URL="https://alefba-dc1.example.ir"
export ROSHAN_ALEFBA__INSTANCES__DC1__TOKEN="token-1"
export ROSHAN_ALEFBA__INSTANCES__DC2__BASE_URL="https://alefba-dc2.example.ir"
export ROSHAN_ALEFBA__INSTANCES__DC2__TOKEN="token-2"
export ROSHAN_ALEFBA__DEFAULT_INSTANCE="dc1"Call list_instances at any time to see configured instance names and base URLs
(never tokens).
Use with an MCP client
Add the server to your client config (example for stdio):
{
"mcpServers": {
"roshan-alefba": {
"command": "python",
"args": ["-m", "roshan_alefba_mcp", "--transport", "stdio"],
"env": {
"ROSHAN_ALEFBA_BASE_URL": "https://alefba.roshan-ai.ir",
"ROSHAN_ALEFBA_TOKEN": "your-token"
}
}
}
}Tool reference
All tools accept an optional instance (except list_instances and
roshan_alefba_docs). OCR tools also share type (general | ID-card |
excel), fix_orientation, word_positions, wait, and priority (1–4).
Tool | Endpoint | Purpose |
|
| Read (OCR) a document/image from a URL; sync ( |
|
| Upload a local |
|
| Fetch/poll an async result by |
|
| Read specific pages given as URLs with |
|
| Per-document progress ( |
|
| List a document's page URLs. |
|
| Download as Word ( |
|
| Download as Excel ( |
|
| Download as searchable PDF ( |
|
| Delete a document and its results. |
|
| Process and receive the result via a webhook |
|
| Check an instance is up and ready. |
| (local) | List configured instance names + base URLs (no tokens). |
| (local) | Documentation about Alefba and these tools. |
Download tools return the download URL and request payload by default; pass
save_pathto download the bytes and save them locally (the saved path is returned).boxvalues in OCR results are"left top width height"in pixels.
Architecture

The MCP client calls tools registered by build_server(); the ocr, common
and docs tool modules validate input (guardrails.py), resolve the target
deployment (config.py) and talk to Alefba over an authenticated async HTTP
client (client.py).
Self-hosting & scaling
One process can route to many self-hosted Alefba deployments, selected per
call by instance:

The server is stateless, so scale it horizontally (more replicas behind a load balancer, or enable the Helm/Kubernetes HPA). Each replica reads the same instance configuration.
Request flow (async OCR + PDF export)

alefba_read_document(wait=false)queues the job; Alefba returns{state, task_ids}.Poll
alefba_get_result(task_id)until the full{document_url, pages[...]}result is ready.alefba_download_pdf(document_url, save_path)exports a searchable PDF.
The diagrams above are generated with the
diagramslibrary. Regenerate them withpython assets/diagrams/generate_diagrams.py(requirespip install diagramsand the Graphvizdotbinary).
Deployment
Manifests and modules live in deploy/:
deploy/kubernetes/— raw, kustomize-ready manifests.deploy/helm/roshan-alefba-mcp/— Helm chart.deploy/terraform/— Terraform (Kubernetes provider).Dockerfile+docker-compose.yml— container image and a two-instance compose example.
See deploy/README.md for details.
Testing
make test # pytest, HTTP mocked with respx (live tests skipped)
make smoke # offline: build server, list tools, assert invariants
python examples/inspect_server.pyLive tests against a real Alefba instance are skipped unless
ROSHAN_ALEFBA_LIVE=1 and credentials are set.
License
MIT. "Roshan", the Roshan logo, and "Alefba" are trademarks of their respective owner and are used only to identify the upstream service this tool integrates with.
Available Tools
17 toolsalefba_delete_documentA
Delete a previously uploaded document and its results. حذف سند بارگذاریشده و نتایج آن. Calls POST /api/delete_document/ and returns {message} confirming deletion. Optional name of the configured Alefba instance to target. Omit to use the default instance.
Inputs: document_url (required), instance. Returns: object
alefba_detail_documentC
Fetch full detail for a document (thumbnails, page URLs, pages, type). دریافت جزئیات کامل یک سند. Calls POST /api/detail_document/ and returns {document_url, thumbnail, thumbnails:[...], page_urls:[...], pages:[...], document_type}. May start processing any remaining pages of the document. Optional name of the configured Alefba instance to target. Omit to use the default instance.
Inputs: document_url (required), instance. Returns: object
alefba_document_pagesA
List the page URLs that make up a previously uploaded document. فهرست صفحات یک سند بارگذاریشده. Calls POST /api/document_pages/ and returns {document_url, pages:[page_url, ...]}. Optional name of the configured Alefba instance to target. Omit to use the default instance.
Inputs: document_url (required), instance. Returns: object
alefba_document_statusA
Report processing progress for one or more documents. گزارش وضعیت پردازش اسناد. Calls POST /api/document_status/ and returns a mapping of each URL to {analyzed, processed_pages, all_pages} so you can track async jobs. Optional name of the configured Alefba instance to target. Omit to use the default instance.
Inputs: document_urls (required), instance. Returns: object
alefba_download_excelA
Download the analyzed document as an Excel (.xlsx) file. دریافت سند تحلیلشده به صورت فایل اکسل. Calls POST /api/download_excel/. The document must have been processed with type=excel. Returns download info, or the saved path when save_path is provided. Optional name of the configured Alefba instance to target. Omit to use the default instance.
Inputs: document_url (required), save_path, instance. Returns: object
alefba_download_originalA
Get a signed link to download a document's ORIGINAL source file. دریافت پیوند دانلود فایل اصلی سند. Calls POST /api/download_original/ and returns {download_link}. The link is signed and short-lived (expires ~30s) and only works for already-processed local files. Optional name of the configured Alefba instance to target. Omit to use the default instance.
Inputs: document_url (required), instance. Returns: object
alefba_download_pdfA
Download the analyzed document as a searchable PDF. دریافت سند به صورت پیدیاف قابلجستوجو. Calls POST /api/download_pdf/. quality controls image quality (0-100), color toggles colour vs. grayscale, and img_format (png|jpg) sets the embedded image format. Returns download info, or the saved path when save_path is provided. Optional name of the configured Alefba instance to target. Omit to use the default instance.
Inputs: document_url (required), quality, color, img_format, +2 more. Returns: object
alefba_download_wordA
Download the analyzed document as a Word (.docx) file. دریافت سند تحلیلشده به صورت فایل ورد. Calls POST /api/download_word/. Returns the download endpoint info; when save_path is given the .docx bytes are saved locally and the saved path is returned. The document must have been processed first. Optional name of the configured Alefba instance to target. Omit to use the default instance.
Inputs: document_url (required), save_path, instance. Returns: object
alefba_get_resultA
Fetch or poll the result of an async document read. دریافت نتیجه پردازش ناهمگام با شناسه کار. Pass a task_id returned by alefba_read_document(wait=false). If the job is still running you get {state} (e.g. pending); when done you get the full document result. Set wait=true to block server-side until completion. Optional name of the configured Alefba instance to target. Omit to use the default instance.
Inputs: task_id (required), wait, instance. Returns: object
alefba_list_documentsA
List documents known to an Alefba instance, page by page. فهرست اسناد موجود در سرویس الفبا. Calls GET /api/list_documents/?page=N and returns {results:[{url, thumbnail, indexed_in_bazz, processed_pages, page_count, analyzed, processed_diff, type, filename}], num_pages}. Use num_pages to iterate; page defaults to 1. Optional name of the configured Alefba instance to target. Omit to use the default instance.
Inputs: page, instance. Returns: object
alefba_read_documentA
Read (OCR) a document or image from a URL. استخراج متن از سند یا تصویر با آدرس اینترنتی. By default the call blocks (wait=true) and returns the full structured result {document_url, pages:[{page_url,width,height,angle,text,parts:[...]}]} where each box is 'left top width height' in pixels. Set wait=false to queue the job and get {state, task_ids} back, then poll with alefba_get_result. type is one of general, ID-card, excel; priority is 1 (highest) to 4 (lowest). Pass an optional task_id to fetch a queued result. Optional name of the configured Alefba instance to target. Omit to use the default instance.
Inputs: document_url (required), type, fix_orientation, word_positions, +4 more. Returns: object
alefba_read_document_callbackA
Read a document and receive the result via webhook (callback). پردازش سند و دریافت نتیجه از طریق وبهوک. Instead of polling, Alefba POSTs the result to callback_url when done. Returns {state:'processing', document_url} immediately. Optional name of the configured Alefba instance to target. Omit to use the default instance.
Inputs: document_url (required), callback_url (required), instance. Returns: object
alefba_read_document_uploadA
Upload a local file and read (OCR) it. بارگذاری فایل محلی و استخراج متن آن. Sends the file as multipart form data (field 'document') to Alefba with the same options as alefba_read_document. Returns the structured OCR result, or {state, task_ids} when wait=false. Optional name of the configured Alefba instance to target. Omit to use the default instance.
Inputs: file_path (required), type, fix_orientation, word_positions, +3 more. Returns: object
alefba_read_pagesA
Read (OCR) specific pages of documents. استخراج متن از صفحات مشخص اسناد. Each entry in page_urls is a document URL with an @page=N suffix, e.g. https://example.com/doc.pdf@page=2. Returns the same structured result as alefba_read_document (or {state, task_ids} async). Optional name of the configured Alefba instance to target. Omit to use the default instance.
Inputs: page_urls (required), type, fix_orientation, word_positions, +3 more. Returns: object
healthcheckA
Check that an Alefba instance is up and ready. بررسی سلامت سرویس الفبا. Calls Alefba's GET /api/healthcheck/ readiness probe and returns {status, message}, e.g. {"status": "ok", "message": "Server is up and ready"}. Optional name of the configured Alefba instance to target. Omit to use the default instance.
Inputs: instance. Returns: object
list_instancesA
List the configured Alefba instances (names and base URLs only). فهرست نمونههای پیکربندیشده الفبا. Useful for discovering which 'instance' values the other tools accept. Returns {default_instance, instances:[{name, base_url, verify_ssl}]}. Tokens are NEVER returned.
Inputs: no named parameters. Returns: object
roshan_alefba_docsA
Return documentation about Alefba (الفبا) OCR and these MCP tools. راهنمای سرویس الفبا و ابزارهای این سرور. Use this to learn what the server does, which tools exist, and where to read the official docs (https://docs.roshan-ai.ir) before calling other tools. Pass an optional topic to filter to one tool or doc link.
Inputs: topic. Returns: object
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 17 tools
Every tool has a clearly distinct purpose; even the four read-document variants are distinguished by method (URL, callback, upload, pages). Persian and English descriptions reinforce uniqueness.
Most tools follow 'alefba_verb_noun' (e.g., delete_document), but some use 'alefba_noun_verb' (e.g., document_status) and three tools (healthcheck, list_instances, roshan_alefba_docs) lack the 'alefba_' prefix, breaking the pattern.
17 tools cover the full OCR document lifecycle—upload, read, status, download, delete—plus instance management and docs. Slightly above the typical ideal range but justifiable for the feature set.
The tool surface is comprehensive: multiple read modes, format-specific downloads, async result polling, healthcheck, instance listing, and documentation. No obvious gaps for document processing.
Related MCP Connectors
Document conversion MCP server: PDF to Markdown, image OCR, spreadsheet parsing.
Hosted MCP server: convert PDFs to clean, LLM-ready Markdown with tables, formulas and OCR.
OCR, transcription, file extraction, and image generation for AI agents via MCP.
Document-to-Markdown MCP server — convert PDF, Office and HTML into LLM-ready Markdown.
Related MCP Servers
- AlicenseBqualityDmaintenanceA universal MCP server for document processing, conversion, and automation. Handle PDF, DOCX, HTML, Markdown, and more through a unified API and toolset.1328 npm140MIT
- AlicenseNot gradedqualityNot gradedmaintenanceA macOS-based MCP server that enables high-accuracy text extraction from PDF and image files using the OwlOCR app or Apple's Vision Framework. It supports multi-language OCR and provides asynchronous tools for processing documents directly within MCP clients.MIT
- AlicenseBqualityDmaintenanceAn MCP server that lets AI assistants read and visually analyze local documents — PDFs, Excel spreadsheets, CSV files, Word documents, PowerPoint presentations, and images.449 npm100 PyPIMIT
- FlicenseNot gradedqualityDmaintenanceA self-hostable MCP server for Roshan AI's Persian speech service, Harf, enabling transcription, forced alignment, real-time streaming, and speaker analysis through natural language.-