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
| URL | https://docaiapi.subgradientlabs.com/mcp (trailing slash optional) |
| Transport | Streamable HTTP (remote), not stdio or legacy SSE-only |
| Auth | Authorization: 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
| Tool | Maps to | Notes |
|---|---|---|
extract | POST /api/v1/extract | Sync extract; charges credits. Pass idempotency_key to retry without a second charge. Auto keys are not a stable contract; pin schema_id |
extract_batch | POST /api/v1/extract/batch | Up to 10 files via MCP; charges credits; lite not supported. Same schema_id / idempotency_key as REST |
get_job | GET /api/v1/jobs/{id} | Poll a single async job |
get_batch | GET /api/v1/batches/{id} | Poll batch from extract_batch or REST |
list_jobs | GET /api/v1/history | Processing history, not a live job queue |
balance | GET /api/v1/billing/usage | Credits + 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.
| Arg | Required | Default | Notes |
|---|---|---|---|
file_base64 | one-of | n/a | Standard base64 of PDF bytes (~33% larger than file) |
file_url | one-of | n/a | Public https PDF URL (SSRF-safe; private IPs blocked). Prefer over large base64 |
filename | no | document.pdf | |
extract_tier | no | plus | lite | plus | pro | ultra (same as REST /upload) |
system_prompt | no | n/a | Optional guidance (server default if omitted on Plus/Pro/Ultra) |
custom_prompt | no | n/a | Optional alternate prompt field |
custom_fields | no | n/a | JSON string: [{"name","description","type"}] |
extract_schema | no | n/a | JSON string schema |
schema_id | no | n/a | Pin a saved org schema (stable contract; prefer over Auto) |
save_schema_name | no | n/a | Name used when Auto generate is persisted |
idempotency_key | no | n/a | Sent as Idempotency-Key; same key + org within 24h does not charge twice |
extraction_target | no | per_doc | Same as REST |
cite_sources | no | false | |
confidence_scores | no | false | |
target_pages | no | n/a | e.g. "1-3" |
max_pages | no | n/a | Cap pages processed |
do_not_cache | no | true |
extract_batch arguments
| Arg | Required | Notes |
|---|---|---|
files_json | yes | JSON array of { "filename", "file_base64" } or { "filename", "file_url" } (max 10) |
schema_id | no | Pin a saved schema (same as REST) |
idempotency_key | no | Same as extract |
| (same extract options) | no | Default 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_urlover 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_idafter 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}"
}
}
}
}export DOCAI_API_KEY='docai_sk_live_...'- Save config → refresh MCP servers in Cursor
- 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--headervalue (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:
| Client | Config | Env pattern | Native HTTP? |
|---|---|---|---|
| Cursor | .cursor/mcp.json | ${env:VAR} | Yes |
| Claude Code | Claude MCP config | ${VAR} (typical) | Yes |
| Claude Desktop | Connectors or mcp-remote | env block | Bridge / Connector |
| Codex | config.toml | bearer_token_env_var | Yes |
| VS Code Copilot | .vscode/mcp.json | ${input:…} / env | Yes (type: http) |
| Windsurf / others | product MCP JSON | varies | Usually yes |
If a client only supports stdio, use mcp-remote (see Claude Desktop option B).
Credits & errors
Same billing as REST. See Credits:
| Mode | Credits / page |
|---|---|
| Lite | 0.5 |
| Plus | 2.0 |
| Pro | 3.0 |
| Ultra | 8.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_urlover pasting multi-MB base64 into the agent context
Troubleshooting
| Symptom | Likely cause |
|---|---|
| 401 at HTTP layer | Missing/invalid Bearer API key (not JWT) |
| Tools missing in Claude Desktop | Used Cursor-style url config. Switch to Connector or mcp-remote |
extract timeout / huge payload | Base64 too large. Use file_url or REST multipart |
| Unexpected cheap/draft quality | Pass extract_tier: "lite" for draft parse, or "pro" / "ultra" for deeper extract. Default is plus. |
| Double charges | Retried extract after network timeout. Poll history instead |
402 in tool body | Insufficient 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"}}}'