DocAI
How it worksPricingDocsTrustCookies
Sign inStart free
DocAI Docs
DocAI Docs
ProductOpenAPIDocAI APIAuthenticationPythonExtractJobs & batchCreditsErrorsIdempotencyConnectorsMCP

MCP

Connect Cursor, Claude, Codex, VS Code Copilot, and other agents to DocAI over Streamable HTTP.

DocAI exposes a remote Model Context Protocol server over Streamable HTTP.

Use MCP for agent/IDE workflows. For large PDFs or full extract options, prefer REST.

Endpoint & transport

URLhttps://docaiapi.subgradientlabs.com/mcp (trailing slash optional)
TransportStreamable HTTP (remote), not stdio or legacy SSE-only
AuthAuthorization: Bearer docai_sk_... (API key only; JWT rejected)

Create a key in the workstation (Settings → API keys). See Authentication.

Never commit API keys. Use environment variables in client configs.

Tools

ToolMaps toNotes
extractPOST /api/v1/extractSync extract; charges credits. Pass idempotency_key to retry without a second charge. Auto keys are not a stable contract; pin schema_id
extract_batchPOST /api/v1/extract/batchUp to 10 files via MCP; charges credits; lite not supported. Same schema_id / idempotency_key as REST
get_jobGET /api/v1/jobs/{id}Poll a single async job
get_batchGET /api/v1/batches/{id}Poll batch from extract_batch or REST
list_jobsGET /api/v1/historyProcessing history, not a live job queue
balanceGET /api/v1/billing/usageCredits + ledger

Tool results are a structured object: { "http_status": <int>, "body": <REST payload> }. Use body for data and errors (Errors).

extract arguments

Provide exactly one of file_base64 or file_url.

ArgRequiredDefaultNotes
file_base64one-ofn/aStandard base64 of PDF bytes (~33% larger than file)
file_urlone-ofn/aPublic https PDF URL (SSRF-safe; private IPs blocked). Prefer over large base64
filenamenodocument.pdf
extract_tiernopluslite | plus | pro | ultra (same as REST /upload)
system_promptnon/aOptional guidance (server default if omitted on Plus/Pro/Ultra)
custom_promptnon/aOptional alternate prompt field
custom_fieldsnon/aJSON string: [{"name","description","type"}]
extract_schemanon/aJSON string schema
schema_idnon/aPin a saved org schema (stable contract; prefer over Auto)
save_schema_namenon/aName used when Auto generate is persisted
idempotency_keynon/aSent as Idempotency-Key; same key + org within 24h does not charge twice
extraction_targetnoper_docSame as REST
cite_sourcesnofalse
confidence_scoresnofalse
target_pagesnon/ae.g. "1-3"
max_pagesnon/aCap pages processed
do_not_cachenotrue

extract_batch arguments

ArgRequiredNotes
files_jsonyesJSON array of { "filename", "file_base64" } or { "filename", "file_url" } (max 10)
schema_idnoPin a saved schema (same as REST)
idempotency_keynoSame as extract
(same extract options)noDefault extract_tier is plus (lite not supported for batch)

Limits

  • Decoded PDF max 10 MB each (same as REST). Larger files: use REST multipart.
  • Prefer file_url over base64 when the agent would otherwise paste megabytes of base64.
  • Prompts and custom fields are optional for all tiers; cloud modes use a server default prompt when omitted (see Extract).
  • Auto schema keys are not a stable contract. Pin schema_id after the first Auto run.
  • To retry after a timeout, pass the same idempotency_key. See Idempotency.

Client setup

Cursor

Project: .cursor/mcp.json · Global: ~/.cursor/mcp.json

{
  "mcpServers": {
    "docai": {
      "url": "https://docaiapi.subgradientlabs.com/mcp",
      "headers": {
        "Authorization": "Bearer ${env:DOCAI_API_KEY}"
      }
    }
  }
}
  1. export DOCAI_API_KEY='docai_sk_live_...'
  2. Save config → refresh MCP servers in Cursor
  3. Smoke-test: call balance

Claude Code

Remote Streamable HTTP is supported natively. Use your Claude Code MCP config (often project or user mcpServers) with env interpolation:

{
  "mcpServers": {
    "docai": {
      "url": "https://docaiapi.subgradientlabs.com/mcp",
      "headers": {
        "Authorization": "Bearer ${DOCAI_API_KEY}"
      }
    }
  }
}

Syntax for env vars may be ${DOCAI_API_KEY} or product-specific. Check your Claude Code version. Then restart the session and list tools.

Claude Desktop

Claude Desktop’s claude_desktop_config.json is stdio-oriented. A bare "url" block (like Cursor) often does not work.

Option A: Custom Connector (preferred when available)
Settings → Connectors → add custom MCP → URL https://docaiapi.subgradientlabs.com/mcp → Bearer token = your DocAI API key.

Option B: mcp-remote bridge (stdio to HTTP)

{
  "mcpServers": {
    "docai": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-remote",
        "https://docaiapi.subgradientlabs.com/mcp",
        "--header",
        "Authorization:${DOCAI_AUTH}"
      ],
      "env": {
        "DOCAI_AUTH": "Bearer docai_sk_live_..."
      }
    }
  }
}

Notes:

  • macOS config path: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Requires Node.js for npx
  • No space after Authorization: in the --header value (Windows/arg parsing pitfall)
  • Restart Claude Desktop after edits

ChatGPT & Codex

ChatGPT desktop / Codex (CLI + IDE extension) share MCP config for Streamable HTTP.

Codex (~/.codex/config.toml or project .codex/config.toml):

[mcp_servers.docai]
url = "https://docaiapi.subgradientlabs.com/mcp"
bearer_token_env_var = "DOCAI_API_KEY"

Or static header map:

[mcp_servers.docai]
url = "https://docaiapi.subgradientlabs.com/mcp"
http_headers = { Authorization = "Bearer docai_sk_live_..." }

Prefer bearer_token_env_var so secrets stay out of the file.

ChatGPT UI: Settings → MCP / connectors (when available) → add Streamable HTTP URL + Bearer API key. If your ChatGPT build only supports OAuth connectors, use REST or Codex/Cursor instead.

VS Code + GitHub Copilot

Workspace .vscode/mcp.json or user MCP config (Copilot agent mode). Prefer "type": "http":

{
  "servers": {
    "docai": {
      "type": "http",
      "url": "https://docaiapi.subgradientlabs.com/mcp",
      "headers": {
        "Authorization": "Bearer ${input:docai-api-key}"
      }
    }
  }
}

Some builds use "mcpServers" instead of "servers". Match your VS Code / Copilot docs version. Enable MCP in Copilot settings if tools do not appear.

Windsurf, Cline, Continue, other IDEs

Most use a Cursor-like mcpServers JSON with a remote url + headers. Paths and env syntax differ:

ClientConfigEnv patternNative HTTP?
Cursor.cursor/mcp.json${env:VAR}Yes
Claude CodeClaude MCP config${VAR} (typical)Yes
Claude DesktopConnectors or mcp-remoteenv blockBridge / Connector
Codexconfig.tomlbearer_token_env_varYes
VS Code Copilot.vscode/mcp.json${input:…} / envYes (type: http)
Windsurf / othersproduct MCP JSONvariesUsually yes

If a client only supports stdio, use mcp-remote (see Claude Desktop option B).

Credits & errors

Same billing as REST. See Credits:

ModeCredits / page
Lite0.5
Plus2.0
Pro3.0
Ultra8.0

Call balance before large runs. Inside tool JSON: 402 = top up; 429 = backoff. Prompts are optional for all modes.

Limitations (when to use REST)

  • Very large PDFs → REST multipart (MCP still caps at 10 MB per file)
  • More than 10 files in one batch → REST /extract/batch
  • Checkout / catalog → REST billing endpoints
  • Prefer file_url over pasting multi-MB base64 into the agent context

Troubleshooting

SymptomLikely cause
401 at HTTP layerMissing/invalid Bearer API key (not JWT)
Tools missing in Claude DesktopUsed Cursor-style url config. Switch to Connector or mcp-remote
extract timeout / huge payloadBase64 too large. Use file_url or REST multipart
Unexpected cheap/draft qualityPass extract_tier: "lite" for draft parse, or "pro" / "ultra" for deeper extract. Default is plus.
Double chargesRetried extract after network timeout. Poll history instead
402 in tool bodyInsufficient credits

Smoke test

After configuring a client, call balance. You should get http_status: 200 and a usage summary.

Optional raw check (expects 401 without a key; 200/JSON-RPC with a valid key depending on client Accept headers):

curl -sS -X POST 'https://docaiapi.subgradientlabs.com/mcp' \
  -H "Authorization: Bearer $DOCAI_API_KEY" \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json, text/event-stream' \
  -d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-03-26","capabilities":{},"clientInfo":{"name":"curl","version":"0"}}}'

Connectors

How to use Google Drive, Gmail, Sheets, Slack, QuickBooks, and Shippo from DocAI Settings - and why each one matters.

On this page

Endpoint & transportToolsextract argumentsextract_batch argumentsClient setupCursorClaude CodeClaude DesktopChatGPT & CodexVS Code + GitHub CopilotWindsurf, Cline, Continue, other IDEsCredits & errorsLimitations (when to use REST)TroubleshootingSmoke test