Skip to main content

MCP Server

DocumentPro exposes document extraction, classification, and template authoring as an MCP (Model Context Protocol) server, so AI agents — Replit Agent, Lovable, Claude Code, Cursor, and any other MCP-capable client — can discover the available tools, read exact field schemas, and wire DocumentPro into the code they generate without guessing endpoint shapes or field names.

Connection

Endpoint:  https://api.documentpro.ai/mcp
Transport: Streamable HTTP
Auth: x-api-key: <your DocumentPro API key>

The MCP server uses the same API key as the REST API — there is no separate credential. Your client must support sending a custom header. For example, with Claude Code:

claude mcp add --transport http documentpro https://api.documentpro.ai/mcp \
--header "x-api-key: YOUR_API_KEY"

Requests to /mcp without a valid x-api-key header are rejected at the gateway with HTTP 403 and body {"message": "Forbidden"} — note this is a 403, not a 401. Once authenticated, per-tool authorization failures surface as structured tool errors (UNAUTHORIZED, FORBIDDEN) instead — see Errors.

Other clients

Claude Desktop, or any MCP client that takes a JSON server config:

{
"mcpServers": {
"documentpro": {
"type": "http",
"url": "https://api.documentpro.ai/mcp",
"headers": { "x-api-key": "YOUR_API_KEY" }
}
}
}

Python, using the official MCP SDK:

from mcp import ClientSession
from mcp.client.streamable_http import streamablehttp_client

async with streamablehttp_client(
"https://api.documentpro.ai/mcp",
headers={"x-api-key": "YOUR_API_KEY"},
) as (read, write, _):
async with ClientSession(read, write) as session:
await session.initialize()
tools = await session.list_tools()

Discovery

DocumentPro publishes a public MCP server card for registries and agents that discover servers programmatically:

GET https://api.documentpro.ai/.well-known/mcp/server-card.json

No authentication required. The card contains server metadata, transport details, and the full input schema for every tool below, generated from the live server so it can't drift from tools/list. Responses are cacheable for one hour.

Tools

extract_document

Submit a document for extraction. Asynchronous — returns a request_id immediately; poll check_extraction_status until the job completes.

InputTypeRequiredDescription
template_idstringyesTemplate to extract with. Find one via list_templates.
file_urlstringone ofPublicly reachable URL of the document (presigned URLs work).
file_base64stringone ofInline base64 file content, max 7 MB decoded. Prefer file_url.
file_namestringrequired with file_base64File name with extension, e.g. invoice.pdf. Omitting it when using file_base64 raises INVALID_INPUT.
use_ocrbooleannoForce OCR for scanned/image-based documents.
page_rangesstringnoLimit extraction to pages, e.g. "1-3" or "1,4".

Returns { request_id, document_id, request_status }.

check_extraction_status

Poll an extraction job by request_id.

Returns the job state: request_status is one of pending, processing, completed, failed, exception. When completed, results.data contains the extracted fields keyed exactly as defined in the template schema, and results.num_pages reports the pages processed. When failed, error describes what went wrong.

list_templates

List the extraction templates on your account (invoices, purchase orders, receipts, tax forms, custom layouts). Supports search_term and pagination via page_token / next_page_token. Returns template_id, template_title, and template_type per template.

get_schema

Fetch a template's field definitions — field name, type, description, and nested table columns — so an agent can generate a matching data model. Extraction results use exactly these field names.

create_template

Create a new extraction template (Workflow) from a title and field schema — agents can define extraction schemas on the fly instead of only using pre-built templates. See Create Workflow for the underlying REST endpoint and field-schema rules ("Workflow" and "Template" are used interchangeably in DocumentPro).

InputTypeRequiredDescription
template_titlestringyesTemplate name, max 300 characters.
template_schemaobjectyesField definitions: { "fields": [{ "name", "type", ... }] }.
template_typestringnoFree-text category, e.g. "invoice".

Field rules: names use lowercase letters, digits, underscores, and spaces (max 50 characters, unique within the template); types are text, number, date, radio, checkbox, boolean, object, table; table and object fields must define subFields; no field may be marked required — every field must allow null. Call get_schema on an existing template first for a worked example.

Returns the created template: { template_id, template_title, template_type, template_schema }.

update_template

Replace a template's field schema and/or rename it. template_schema replaces the schema entirely, so fetch the current schema with get_schema before adding or changing fields.

InputTypeRequiredDescription
template_idstringyesTemplate to update.
template_schemaobjectone ofNew field definitions — same shape and rules as create_template.
template_titlestringone ofNew template name.

Returns the updated template, same shape as create_template.

classify_document

Assign one of your labels to a document — use it to route mixed document streams to the right extraction template. Synchronous — no polling required. Calls the same classification pipeline as Classify Document / Run Classification.

InputTypeRequiredDescription
classifier_idstringone ofA saved classifier (see create_classifier).
labelsarrayone ofInline labels, at least 2: [{ "label", "description" }].
document_idstringone ofAn already-uploaded document.
file_urlstringone ofPublicly reachable URL of the document.
file_base64stringone ofInline base64 file content, max 7 MB decoded. Requires file_name.
page_rangestringnoClassify using specific pages only, e.g. "1-3".
query_modelstringnoModel override — inline labels only; saved classifiers use their own model.

Provide the document as exactly one of document_id / file_url / file_base64, and the classifier as exactly one of classifier_id / labels.

New documents are OCR'd automatically

Unlike the REST classify endpoints, classify_document does not require the document to be pre-processed — it enqueues OCR automatically and waits briefly. If OCR takes longer than a few seconds, the tool returns a DOCUMENT_NOT_READY error carrying the document_id; retry the same call with that document_id after about 15 seconds.

Returns { request_id, document_id, classifier_id, classification, confidence_scores, request_status, credits_used, num_pages, duration }.

create_classifier

Save a reusable classifier — see Create Classifier for the underlying REST endpoint. Use its classifier_id with classify_document to route documents consistently instead of repeating inline labels.

InputTypeRequiredDescription
namestringyesClassifier name.
labelsarrayyesAt least 2 classes: [{ "label", "description" }].
classifier_typestringno"document" (default, one label per document) or "page" (labels each page).
page_rangestringnoDefault page range to classify on.

Returns the created classifier: { classifier_id, name, classifier_type, labels, page_range, created_at, updated_at }.

list_classifiers

List the saved classifiers on this account, including their labels. See List Classifiers for the underlying REST endpoint. No parameters.

Returns { classifiers: [...] }.

list_supported_formats

Returns the accepted file formats: pdf, png, jpg/jpeg, tiff/tif, txt, doc, docx, html.

get_credit_balance

Check remaining credits before starting a batch job. Takes no parameters.

FieldDescription
plan_typeCurrent subscription plan.
plan_credits_remainingCredits remaining in the current billing period. Resets on plan renewal.
topup_credits_remainingPurchased top-up credits. Never expire; drawn down after plan credits.
total_credits_remainingPlan + top-up credits — the total available before extraction/classification calls start failing with INSUFFICIENT_CREDITS.
plan_end_dateWhen the current billing period ends and plan credits reset.

Errors

Tools return structured errors, never stack traces:

{ "error_code": "NOT_FOUND", "message": "Template not found" }
CodeMeaning
UNAUTHORIZEDMissing or unknown API key.
FORBIDDENThe key does not have access to the requested resource.
NOT_FOUNDTemplate or request id does not exist on this account.
INVALID_INPUTBad arguments (e.g. both file_url and file_base64, unsupported format, file over the base64 limit, an invalid template or classifier schema). The message includes field-level detail so you can correct and retry.
DOCUMENT_NOT_READYclassify_document only: the document is still being OCR'd. Retry with the document_id from the error message after about 15 seconds.
INSUFFICIENT_CREDITSYour account is out of credits for this operation. Not fixable by retrying — top up before trying again.
SCHEMA_UNAVAILABLEThe template's stored schema cannot be rendered (rare legacy records). Choose a different template.
PAGE_LIMIT_EXCEEDEDDocument exceeds the page cap (100 pages, 300 for tax-flagged accounts).
INTERNAL_ERRORSomething went wrong on our side — contact support if it persists.

See Error Codes for details and the REST API's separate (non-matching) error vocabulary.

Notes