Skip to content

Model Context Protocol

Docbank provides a read-mostly Model Context Protocol (MCP) server for local agents. It implements only MCP 2026-07-28, using the official Go SDK at github.com/modelcontextprotocol/go-sdk v1.7.0. Older MCP versions and the legacy initialize flow are rejected. Clients start with server/discover.

Standalone MCP is a client of the selected vault's daemon. It discovers or starts that daemon the same way the CLI does and never opens docbank.db, a blob, pack, or rendition directly. There is no MCP-only embedded-vault path and no remote-daemon option.

Start the server

Stdio is the default transport:

docbank mcp
# equivalent to: docbank mcp --transport stdio

Print configuration for your client:

docbank mcp config --client claude-code
docbank mcp config --client codex
# Include the write tools you need:
docbank mcp config --client codex --allow-processing

Paste Claude Code's JSON into your project's .mcp.json, or merge the docbank entry into its existing mcpServers object. Keep this project's .mcp.json out of version control because it contains machine-specific paths. Paste Codex's TOML into ~/.codex/config.toml, replacing any existing [mcp_servers.docbank] entry. See the Claude Code MCP guide and Codex configuration reference.

The snippet uses Docbank's absolute launch path, preserving package-manager symlinks, and the selected vault's canonical DOCBANK_HOME. All six --allow-* flags carry through to stdio arguments. Printing creates no vault, starts no daemon, and leaves client files untouched. Your client must support MCP 2026-07-28 and server/discover; configuration alone cannot add protocol support.

Tested clients are Claude Code 2.1.301 and Codex 0.164.0. For Codex, run this once to persist the client's MCP protocol support in config.toml for either transport:

codex features enable mcp_2026_07_28

Then launch with plain codex. The generated stdio configuration also sets CODEX_MCP_PROTOCOL_VERSION=2026-07-28 for Codex, which reads it to pick the protocol version and does not pass it to the server. After upgrading Docbank, rerun docbank mcp config and replace the saved configuration so its protocol selection matches the installed server.

Stdio carries one complete JSON-RPC message per line. Docbank accepts LF or CRLF terminators, rejects embedded newlines, and limits the JSON payload before the terminator to 1 MiB. Stdout contains MCP frames only. Bounded, redacted diagnostics go to stderr.

HTTP requires an explicit IP and port plus a separate named bearer binding:

# $DOCBANK_HOME/config.toml
[mcp.http]
credential_binding = "credential:mcp-http"

[credential_bindings.mcp-http]
environment_variable = "DOCBANK_MCP_HTTP_TOKEN"

Make DOCBANK_MCP_HTTP_TOKEN available to the MCP process through the machine's secret or process manager, then start the listener:

docbank mcp --transport http --listen 127.0.0.1:7341

Print the client configuration for that listener:

docbank mcp config --client claude-code --transport http --listen 127.0.0.1:7341
docbank mcp config --client codex --transport http --listen 127.0.0.1:7341

The URL ends in /mcp. Claude Code receives an Authorization header with Bearer ${DOCBANK_MCP_HTTP_TOKEN}; Codex receives bearer_token_env_var = "DOCBANK_MCP_HTTP_TOKEN". The command reads the selected credential binding's variable name and leaves its value unresolved. If this shell has no binding, it prints DOCBANK_MCP_HTTP_TOKEN, the listener's conventional variable. The listener still requires its token. Make that variable available to the client too. If the listener reads DOCBANK_MCP_HTTP_TOKEN_FILE, the client still needs DOCBANK_MCP_HTTP_TOKEN containing the token itself. A custom binding uses its own variable name.

--listen accepts an explicit IPv4 or IPv6 address and port, including wildcards. Hostnames and IPv6 zone identifiers are rejected. Printed URLs replace wildcard addresses with loopback, and require a nonzero port. HTTP write flags belong on the standalone listener's startup command.

The HTTP credential is resolved from its environment binding when the listener starts and remains fixed for the hosting process. Restart that process to rotate it. It is separate from the daemon API key. Docbank refuses to start if the values match. Standalone MCP repeats that check whenever it acquires a restarted daemon. The MCP bearer never appears in a flag, URL, runtime record, discovery result, log, or error.

This bearer is a fixed credential, not MCP OAuth. Docbank does not publish protected-resource metadata, authorization-server discovery, dynamic client registration, scopes, or token refresh. A client may connect locally or through a trusted tunnel, but it must be able to set the Authorization header. Clients that require the MCP HTTP OAuth flow are not supported.

The daemon also hosts the same read-only HTTP tools at /mcp on its API port. For a loopback API this is on by default once the MCP bearer resolves in the daemon's environment; without it, the daemon logs why and starts without MCP. Set [mcp.http] enabled or DOCBANK_MCP_HTTP_ENABLED to true to require it, or false to turn it off. [mcp.http] port moves it to a separate loopback port. The API port is ephemeral unless [server] api_port is set, so pin it for a stable client URL; the daemon logs the MCP URL at startup. The daemon uses the same credential and Host rules, and its API key is rejected at /mcp. MCP reads use that daemon's API. On shutdown, in-flight reads get up to five seconds to finish before the API closes. A daemon hosting MCP does not idle out. With hosting enabled explicitly, invalid credentials or a failed bind stop daemon startup. Restart the daemon to rotate its bearer. See the configuration reference and container example.

To connect to the daemon-hosted endpoint, pass its pinned [server] api_port or separate [mcp.http] port as --listen when printing configuration. For example, --listen 127.0.0.1:7341 targets the daemon when its API port is 7341. Start the daemon with the same bearer binding available in its environment. Printing configuration leaves the listener's startup to you.

Both transports have the fixed read catalog described below. --allow-processing adds only guarded processing start. --allow-package-writes permits load-file preflight, import, and custodian changes. --allow-photo-edits permits photo asset mutations. --allow-export-writes enables native export jobs and local downloads. --allow-report-writes enables frozen report creation, revision, local delivery, and explicit release. --allow-kata-writes permits quoting verified passages into Kata issues. Each flag is independent and applies only to standalone MCP. The daemon-hosted catalog stays read-only. Enable the combination you need at standalone startup.

Connect over a trusted network

Choosing a non-loopback listener opts into sending the MCP bearer and returned vault data over the selected network. This is plain HTTP; use a trusted private container network, encrypted tunnel, or HTTPS proxy. The bearer grants the read-only catalog, with extra tools available only through standalone MCP's startup flags. It remains distinct from the daemon's full-authority API key. The MCP process still connects to its local daemon; remote-daemon configuration is not supported.

You can start without config.toml using a mounted bearer file:

DOCBANK_MCP_HTTP_TOKEN_FILE=/run/secrets/mcp-bearer \
DOCBANK_MCP_HTTP_ALLOWED_HOSTS=docbank:7341 \
  docbank mcp --transport http --listen 0.0.0.0:7341

DOCBANK_MCP_HTTP_TOKEN or its _FILE form selects an environment-backed named credential binding, overriding a TOML binding for this process. Alternatively, retain the TOML example above and supply either its named variable or <variable>_FILE. Conflicting nonempty values and invalid selected files fail HTTP startup; they never fall back to another source. The daemon reads the MCP bearer only when MCP hosting is enabled explicitly or by default. Restart the hosting process to rotate it.

List accepted client authorities in [mcp.http] allowed_hosts, the comma-separated DOCBANK_MCP_HTTP_ALLOWED_HOSTS replacement, or additive, repeatable --allowed-host docbank:7341 flags. Values are IPs or ASCII DNS names, optionally with ports; a name without a port permits any port. Loopback hosts and a concrete listen IP are also accepted. Wildcard binds do not permit arbitrary Host names. The flags are valid only with HTTP.

A network client uses http://docbank:7341/mcp and Authorization: Bearer <token>. Missing or invalid credentials return 401; unconfigured Hosts and cross-origin requests return 403 before authentication. The container guide shows how to enable the daemon-hosted listener in the stock image.

Exact protocol contract

Every request carries these two metadata fields:

{
  "_meta": {
    "io.modelcontextprotocol/protocolVersion": "2026-07-28",
    "io.modelcontextprotocol/clientCapabilities": {}
  }
}

Every HTTP request also carries:

  • Content-Type: application/json;
  • an Accept value that permits both application/json and text/event-stream;
  • Mcp-Protocol-Version: 2026-07-28;
  • Mcp-Method matching the JSON-RPC method; and
  • Mcp-Name matching the tool name for tools/call, or the complete resource URI for resources/read.

Missing or mismatched protocol headers return HTTP 400 with HeaderMismatch. An unknown JSON-RPC method over HTTP returns HTTP 404 with JSON-RPC -32601. initialize, missing protocol metadata, and every other protocol version return the supported-version error and identify only 2026-07-28. Successful results include Docbank server information.

server/discover advertises tools, resource templates, resource reads, and cancellation. The catalog is fixed when the process starts, so there are no list-change notifications. These operations do not emit progress tokens. Stdio cancellation uses notifications/cancelled. For ordinary HTTP request/response calls, aborting or closing the request cancels its in-flight handler work, and the response is JSON. Notification-only requests may instead return HTTP 202 with no body. subscriptions/listen uses SSE, but Docbank advertises no subscriptions. A call with an empty notification selection acknowledges the request and completes immediately.

Tool catalog

All inputs and outputs use closed JSON Schema 2020-12 objects, so unknown fields are rejected. Every successful tool result contains both structured content and its JSON text representation. The complete result, including resource links, is capped at 1 MiB.

Tool Contract and important bounds
get_report_summary Reads an owned frozen report by its 48-character lowercase hexadecimal ID. If the full summary exceeds the result cap, returns report_limit; the handle remains usable.
get_report_dates Reads frozen date evidence with an optional opaque cursor and 1–100 members, default 50. Requests a 256 KiB page; candidates can continue on the next page.
get_export_plan Reads the complete frozen plan header by plan_id, including its admission deadline.
get_export_problems Reads up to 50 frozen unavailable outputs by plan_id and optional numeric after.
get_export_status Reads one retained native export job, including progress, failure code, and any completed receipt. It never downloads or releases the job.
get_vault_info Returns the stable vault ID and aggregate live, trash, version, and blob counts. It never returns the host vault path.
list_changes Returns up to 500 retained events with cursor, kind, node_id, and revision. Pass the saved next_cursor to resume; call again while has_more is true.
list_documents Lists current, live files. path_prefix defaults to / and is capped at 16,384 Unicode characters and 16 KiB of UTF-8. Sorts are path, name, modified_at, size, and media_type, in asc or desc order. Page size defaults to 50 and is capped at 250.
answer_question Searches for evidence with a question and returns passages, leads, coverage, and a receipt. Optional filters narrow the scope; profile, binding, reranking, and output limits can be selected explicitly.
search_documents Requires a 1–8,192-character query, a 1–128-character processing profile name, and exactly one source selector: 1–4,096 unique content-version IDs or metadata filters selecting every matching live file without a 4,096-file cap. Mode defaults to auto and may be auto, lexical, semantic, or hybrid; result limit defaults to 20 and is capped at 100. Optional binding IDs are capped at 128 characters. Optional rerank is a boolean that requests the profile's configured reranker.
find_conflicts Uses the query, profile, limit, and source selectors from search_documents. Retrieval is lexical only, with at most 20 hits. Compares money, percentages, and durations in whole source sentences and returns source dates and evidence IDs.
get_document Requires an exact positive node ID and current content-version UUID. A stale, trashed, moved-to-another-version, or mismatched identity is rejected.
read_document_content Reads original bytes from a selected immutable version as base64. Requires the exact vault, node, version, SHA-256 and size from list_document_versions. Originals are limited to 32 MiB; byte windows default to 64 KiB and are capped at 256 KiB. Returns offset, next offset and EOF. Verify the assembled size and SHA-256 before using the bytes. No export job or local file is created.
list_document_versions Lists immutable versions, including each original's blob_hash and size, for one live file. Limit defaults to 100 and is capped at 250; offset is capped at 1,000,000.
resolve_text_citation Reopens a saved quotation from exact retained rendition text.
check_answer Checks answer figures against saved citations.
get_kata_context Reads an issue's Docbank evidence and current source states.
get_text_outline Reads the headings and whole-section bounds of retained text.
read_text_section Reads an exact page of a retained section, with explicit completion.
read_rendition_text Reads the exact vault/node/version/attachment tuple described under Resources.
get_processing_plan Requires an exact node ID, content-version UUID, and 1–128-character processing profile name. Returns the complete provider, trust-boundary, retention, estimate, consent, and backup disclosure plus its fingerprint.
get_processing_status Reads one stable 64-hex-character job identity. A response contains at most 64 embedding job IDs.
get_processing_coverage Reports rendition and embedding coverage for 1–4,096 unique version IDs in one exact vault fence and one 1–128-character processing profile. The response has at most 65 coverage classes.
get_package_import Reads durable progress for one import operation UUID.
get_package_preflight Reads one retained preflight by its exact identity.
list_package_preflight_diagnostics Pages through bounded diagnostics for a retained preflight.
list_package_custodians Pages through active custodian claims for an exact package scope.
find_people Finds bounded active canonical people by word-start folded display-name search, with global display-only identity labels that may contain email addresses, phone numbers, or scoped handles, and folded-name page continuation.
get_person Reads one person, its identities, and its external UIDs.
list_packages Pages through received and produced load-file packages.
get_package Reads one package and its retained source authority.
list_package_members Pages through a package's immutable document occurrences.
get_package_record Reads one immutable sender row by its package-scoped record key.
lookup_bates_label Finds bounded package-scoped matches for an exact received or assigned label.
get_photo_faces Reads up to 100 face boxes and depicted-person assertions per page, plus canonical people with person_id, display_name, and state for that page. Pages shrink together to fit the response byte limit. Pass next_offset as offset to continue.
get_photo_asset Reads one photo asset by asset UUID or positive node ID. Returns the selected display source, total_files, file_offset, and a page of complete file decisions. Pass next_file_offset as file_offset to continue. Pages are live; restart if the asset revision or a member's file revision changes.

The browser applies name visibility and namesake recognition rules. MCP find_people keeps global search. An invalid cursor or one from another query, projection, or ordering returns the tool error cursor_expired; restart from the first page.

Starting the server with --allow-kata-writes adds this write tool:

Tool Contract and important bounds
cite_kata_evidence Quotes up to 1,000 Unicode code points from a verified document passage into a new or existing Kata issue.

Starting the server with --allow-photo-edits adds these write tools:

Tool Contract and important bounds
create_photo_asset Creates an asset for one positive file node.
attach_photo_file Attaches one node at an expected asset revision.
detach_photo_file Detaches one member at an expected asset revision.
exclude_photo_asset Changes inclusion at an expected asset revision.
promote_photo_asset Explicitly creates an asset for one live file node.

For hidden photo details, run docbank photos assets inspect /path/to/photo.jpg and enter the Hidden passcode. The CLI returns the details while keeping the photo hidden; MCP photo tools remain locked. Ordinary MCP document tools retain access to its files.

Photo writes return the first file page with the committed asset revision. Continue through get_photo_asset when next_file_offset is present. Photo writes make one daemon request. An ambiguous transport failure returns processing_outcome_unknown. Inspect the asset before retrying. Display and vault settings writes remain HTTP and CLI operations.

Call list_changes with {} to get an empty page and the current checkpoint. Save next_cursor before scanning documents, then pass it on the next call to receive changes made since that checkpoint:

{"name":"list_changes","arguments":{"cursor":"SAVED_NEXT_CURSOR"}}

Each response includes events, next_cursor, has_more, ttlMs: 0, and cacheScope: "private". Save next_cursor even when events is empty, so later calls include changes made afterward. Cursors are opaque strings capped at 128 UTF-8 bytes. An interrupted drain returns no partial page; retry with the previous cursor.

An omitted or empty cursor starts at the present. For initial synchronization, save that checkpoint, scan the vault, and replay after the checkpoint. On changes_cursor_expired, call list_changes without a cursor, save the new checkpoint, rescan the vault, and resume with that cursor. See event kinds and retention.

list_documents uses live keyset pagination, not a snapshot. A mutation between pages can change later membership or order. Each opaque cursor is at most 32 KiB of ASCII, expires after 15 minutes, and authenticates the normalized prefix, sort, direction, page size, position, and traversal. Cursors carry their own position, so paging does not consume a shared daemon cursor quota. The size bound accommodates paths up to 16 KiB. Tampered, expired, reused-for-another-query, or daemon-restart-invalidated cursors fail instead of restarting at page one.

list_documents.source_present and search_documents.filters.source_present optionally exclude documents whose watched source is known to be gone. Both default to false. Push-owned documents remain included. The filter is applied before pagination and retrieval.

search_documents with filters searches every matching live file without a 4,096-file cap. Filters may select a tag UUID, a MIME type of at most 255 characters, a positive ancestor node ID, and RFC 3339 modified_since or modified_before bounds of at most 64 characters each. Explicit version lists resolve to an exact source fence of up to 4,096 current, live versions. Only version-list searches return fence, fence_fingerprint, and observed_scope_count. Version-list searches always return vault_id; filter searches return it only with hits. Every search returns requested and actual mode, coverage, skipped reasons, and truncation state. It returns at most 100 hits. Each excerpt is capped at 512 characters. Each hit has at most 64 evidence identities of at most 1,024 characters each. A result contains at most 64 skipped-reason codes of at most 64 characters each.

Set rerank: true to request the profile's configured reranker. The query and bounded candidate excerpts are sent to the provider only under the existing reranking consent grant. search_documents reports openWorldHint: true because a reranked search can send the query and excerpts to a provider. The optional reranking receipt reports applied, skipped, or degraded, the candidate count, and any failure cause. When the receipt is applied, the first candidate_count hits include rerank_relevance equal to their score, including zero. Later hits omit rerank_relevance. Applied searches use different score scales, provider relevance for the first candidate_count hits and search scores for later hits, so clients must not sort the whole list by score. A degraded search retains its original order and adds reranking_degraded to skipped reasons, unless the profile fails closed. MCP returns reranking_unavailable when no reranker is configured and reranking_failed when reranking fails under a fail-closed policy; these errors omit provider bodies, credentials, query text, and excerpts.

Document summaries use paths of at most 16,384 characters, names and MIME types of at most 255 characters, and at most 64 active rendition identities. Processing-plan responses contain at most 129 flow hops, 129 disclosed classes, and 129 retained classes. Each runtime disclosure has at most 64 metadata classes and 64 retained-artifact roles, and each flow hop has at most three input classes. Processor, endpoint, deployment, model, revision, and vector-space strings are capped at 1,024 characters, and provider and class names at 128. The backup-consequence text is capped at 4,096 characters. Processing status contains at most 64 embedding job IDs and caps state, phase, and failure codes at 64 characters. completed_bindings is capped at 64. Processing coverage contains at most 65 classes, with class names capped at 128 characters, states at 64, and each class count at 4,096. These schema limits are admission bounds, not promises that a configured provider or vault will fill them.

Expected domain failures return isError: true with a structured payload capped at 1 KiB and a stable code:

  • not_found
  • stale_version
  • stale_revision
  • plan_changed
  • consent_required
  • processing_outcome_unknown
  • scope_too_large
  • cursor_expired
  • daemon_unavailable
  • invalid_document_cursor
  • invalid_rendition_window
  • invalid_rendition_encoding
  • invalid_photo_asset
  • photo_node_not_eligible
  • photo_node_owned
  • audit_mutation_unsupported

Invalid tool arguments use JSON-RPC -32602. Unexpected failures use a sanitized JSON-RPC internal error. Stderr records the operation and a fixed error category for diagnosis. Neither path includes host paths, SQL, provider secrets, daemon keys, or unrequested document text.

Find differing figures

Call find_conflicts with search terms and a source selector. For example:

{"name":"find_conflicts","arguments":{"query":"cooling period","profile":"default","filters":{}}}

If matching sentences say "The cooling period is 7 days." and "The cooling period is 15 days.", the result is CONFLICTING. Each conflict includes the figures, their sentences, and passage references starting at 1. Each passage includes its document identity, evidence IDs, and modified_at, the catalog modification time, not a date from the source text.

The tool uses lexical search, so it needs no embedding provider. It rejects mode, binding_id, explain, and rerank. Its result limit is capped at 20.

It compares money in the same currency, percentages written as % or percent, and durations in the same unit from minutes through years. Sentences must match exactly after lowercasing, collapsing whitespace, and masking the figure and its unit. Each sentence must contain exactly one figure. A second figure, including a date, makes the sentence ambiguous. The text outside the figure and its unit must contain at least one letter. Headings, titles, and neighbouring paragraphs are outside the match, so sentences that differ only in that context can appear as conflicts to inspect, while list items joined to a sentence by hard wraps produce a sentence with several figures, which is skipped.

The tool reads each hit's retained Markdown or original plain text through a verified read. Each quote is a whole sentence from that source, located by the search excerpt. It skips truncated renditions, sources over 256 KiB, unreadable sources, and hits whose excerpt is absent from or repeated in the source. A cancelled call fails rather than returning partial results.

Every sentence touched by the excerpt is eligible, including sentences beside the query match. Line breaks join hard-wrapped text; blank lines and lines containing only a code fence end paragraphs and keep sentences separate. Sentences need a final ., !, or ?, optionally followed by a closing quote or bracket, and must fit within 512 characters. A trailing ... or … marks an incomplete sentence, as does a final period after a capital letter followed by up to three letters, such as Dr. or Ltd.. Name-only evidence is skipped. A passage stating different values for the same matching sentence drops that comparison. compared: false marks hits whose eligible figures matched no other hit, so open those sources.

NO_CONFLICT means at least one matching sentence could be compared across passages and all comparable figures agreed. NOT_COMPARABLE means none could be lined up. These statuses cover only the retrieved, eligible sentences. Check truncated and open the sources to verify disagreements. The tool chooses no winner.

Answer questions

answer_question returns evidence without writing an answer. Content passages require every word of question to appear in one segment; key terms match better than a sentence. ANSWERED means that a content excerpt matched; it does not verify that the excerpt answers the question. Open the source to verify any quotation: excerpts can include omission markers and are not necessarily contiguous spans. Results without content text are leads, not passages. NO_MATCH means a completed search returned no candidates, not that the vault contains no answer. A validated empty scope is vacuously complete and returns NO_MATCH without executing a search. Incomplete indexing, leads, truncated retrieval, or omitted evidence can produce INCOMPLETE_COVERAGE. coverage_complete reports embedding coverage only. It can be true alongside INCOMPLETE_COVERAGE when passage text is unavailable or evidence is omitted. For a nonempty scope with no usable embedding index, a search with no match returns INCOMPLETE_COVERAGE with semantic_unavailable. limit accepts 1–50 results and defaults to 20. max_passage_bytes accepts 2,048–65,536 bytes and defaults to 12,288. At most 20 leads are returned. Passages and resource links are returned in order within the response budget; omitted_passages, omitted_leads, and omitted_links report what did not fit.

The default scope is all live files. A scope above 4,096 versions reports scope_too_large and its observed count; narrow it with filters. The receipt records the vault ID, scope fingerprint, and observed version count. The fingerprint identifies the version ID set, not an immutable catalog or index snapshot. cited_versions lists the versions of returned passages. vector_space_ids come from returned passages and leads. The receipt supports audit, not exact reproduction. Search may send the question to a query embedding provider under the daemon's existing consent policy. Reranking is optional and can disclose excerpts under that policy. When present, relevance preserves the applied reranker's score on its own scale; it is not necessarily normalized to 0–1.

Omit profile for automatic profile and binding retries, including when a vector index is stale or a query provider fails. If every binding fails, lexical search returns available passages with semantic_unavailable and semantic_failure. Reranking failures and errors from the lexical retry stop the search. With rerank: true, automatic selection and lexical fallback use only profiles that support reranking. An explicit profile uses its first query binding in name order unless binding_id selects another. binding_id requires profile. Profiles without query bindings use lexical search. Its search failures are returned without automatic retries or lexical fallback.

PDF facts

get_document exposes pdf_facts for its accepted current content version. The PDF evidence reference defines its seven fields and omission rules. Missing observations mean unknown; PDF evidence that hasn't been extracted omits pdf_facts entirely.

Resources and rendition windows

resources/list is intentionally empty. list_documents, search_documents, find_conflicts, answer_question, and get_document attach resource links for each active rendition, and resources/templates/list publishes one RFC 6570 template.

The canonical rendition URI is:

docbank://vaults/{vault_id}/documents/{node_id}/versions/{content_version_id}/renditions/{attachment_id}

The windowed resource template is:

docbank://vaults/{vault_id}/documents/{node_id}/versions/{content_version_id}/renditions/{attachment_id}{?offset,max_chars}

The vault and content-version identities are canonical lowercase UUIDv4 values, the node ID is a positive decimal integer, and the attachment ID is a lowercase 64-character SHA-256 value. Only an active, sanitized Markdown rendition whose complete tuple matches the URI can be read. Source binaries, raw provider responses, inactive attachments, superseded versions, and host paths are never resource content.

offset is a Unicode code-point offset from 0 through 2,147,483,647. max_chars defaults to 8,000 and ranges from 1 through 16,000. Every window ends on a valid UTF-8 boundary and reports the requested offset, actual start and end, next offset, EOF state, media type, checksum, response byte count, and source identities. read_rendition_text returns the same window data with the tool error codes above. Resource reads report unavailable identities and invalid windows as resource-not-found errors, and are capped at 1 MiB.

Saved text citations

resolve_text_citation is a default read-only tool on stdio and HTTP. It reopens an exact quote after the source version or active rendition has been replaced, provided the cited evidence is still retained. It needs no write opt-in and does not create processing jobs or keep evidence alive.

To save a reference:

  1. Discover a document and its active rendition with list_documents, search_documents, or get_document.
  2. Use list_document_versions to obtain the selected version's blob_hash. Keep it as content_sha256; this is the original hash, not the text hash.
  3. Read the desired read_rendition_text window. Keep its vault_id as vault_uid, node_id, content_version_id, attachment_id as rendition_attachment_id, build_id, and checksum as rendition_sha256.
  4. Save those fields with version: 1, start, and end. The range is measured in Unicode code points in stored Markdown, with an inclusive start and exclusive end. A whole nonempty window uses actual_start and actual_end. A subquote adds its code-point offsets to actual_start. Search-segment offsets and rendered Markdown positions cannot be substituted.

Call resolve_text_citation with that flat object. Every field is required. UUIDs must be canonical lowercase UUIDv4; hashes and build/attachment IDs must be lowercase hex64. Ranges span 1–16,000 code points and end at or before 2,147,483,647. The result returns the unchanged citation, exact text, its text_sha256, and UTF-8 text_bytes, with private cache scope and zero TTL.

The daemon reads and verifies the entire retained rendition before returning a quote. Each call can read up to 64 MiB and uses the normal 60-second daemon deadline, including maintenance waits. Neither this reference nor the returned quote is an offline proof of the original document.

citation_unavailable means to check the vault and evidence retention. Trash, version pruning, and rendition purge can make the reference unavailable; retrying alone cannot restore it. invalid_citation_range requires a range that exists in that exact rendition. citation_limit means the rendition exceeds this operation's size limit. citation_integrity returns no quote after failed verification; investigate the stored evidence. For citation_failed, check the daemon log. A citation_timeout or citation_canceled permits a later deliberate retry of the same reference. The read helper retries a disconnected daemon only before any response starts, never after a domain failure.

The HTTP contract owns the complete field and error table. Current/live rendition resources and windows retain their existing behavior.

Check figures in an answer

check_answer compares a plain-text answer with 1–8 saved citations on stdio and HTTP. Send 1–16,000 Unicode code points, at most 512 figures, and 512 [n] markers. A marker is [ with one to three digits and ], and an index outside 1 to the number of citations is unknown. Each citation requires a verified read, including duplicates. [2024] counts as a figure. A figure is a token containing a digit, with edge punctuation trimmed. Whitespace, em dashes, horizontal bars, and [ ] ( ) < > | * ~ backtick = ; separate tokens. A leading -, −, +, or ± stays as a sign, and a leading decimal point stays. Figures compare across all resolved citations; markers don't scope them. Normalization adds matches for recognized dates and currency amounts while preserving every literal match. A recognized figure is found if its normalized value matches or every digit-containing token in its spelling appears literally in the citations. The first matching rule determines the verdict:

  • ungrounded: an unknown marker or a missing figure with all citations resolved. Example: 30 against cited 20.
  • incomplete: any citation is unavailable. Example: one of two saved citations can no longer be read.
  • no_figures: the answer has no figures. Example: The invoice is attached.
  • grounded: every figure has a literal or normalized match in the cited text. Example: March 15, 2026 against cited 2026-03-15.

Other resolver failures return tool errors. Results include figures, unknown marker indexes, citation statuses, and text digests, with private cache scope and zero TTL.

  • Reported figures keep their spelling. A recognized date or amount can span words, so March 15, 2026 appears as one figure in the result. Literal comparison keeps case, signs before digits or currency symbols, and decimal points. Example: -.5 differs from .5. Edge punctuation before an ISO code is trimmed for literal comparison, so -USD5 matches USD5.
  • Identifiers and ordinary numbers keep their spelling. Examples: 12-AB differs from 12-ab, and 5.00 differs from 5.
  • Dates accept YYYY-MM-DD, Month D, YYYY, and D Month YYYY, with Unicode whitespace between words. English months can use full names, three-letter abbreviations, or Sept and Sept.. Timestamps and invalid dates compare literally. An invalid date can consume a following currency code, so $40 reports missing against 2026-02-30 USD 40.
  • Amounts accept $, €, or £ before a number, or an uppercase ISO currency code before or after it, attached or separated only by spaces or tabs. Other whitespace keeps markers separate, so 40\nUSD compares literally, and USD 20\n\nCAD 30 supplies matches for $20 and CAD30. Codes such as ALL count as currency markers even when they could be ordinary words. These symbols mean USD, EUR, and GBP. Commas group three digits, and a decimal point accepts one or two fractional digits. Leading and trailing zeros normalize, so $1,250, USD 1250.00, and 1,250 USD match.
  • Signed amounts and amounts with multiple currency markers compare literally. For example, neither -USD5.00 nor -USD 5USD supplies a normalized match for $5, and neither CAD $40, $40 CAD, CAD ($40), nor $40 : CAD supplies one for USD40. The marker check skips edge punctuation and formatting delimiters, including punctuation-only tokens, and joins across spaces or tabs only. A separate marker after an amount makes that amount compare literally and is consumed with it, whatever follows the marker. For example, USD 20, CAD 30 leaves 20 and 30 literal and reports missing for CAD30 or $20, while $40 CAD 15 March 2026 supplies a match for 2026-03-15 but not USD40. In 40 CAD 15 March 2026, 40 CAD keeps its marker and matches CAD40. Likewise, 40USD 30CAD supplies matches for $40 and CAD30. A marker next to a signed figure stays with it, so -5 USD 30 CAD supplies a match for CAD30, while in USD -5 EUR 30 the 30 compares literally.
  • Numbered-list numbers count as figures. Example: 1. contributes 1.
  • Literal matches can also ground different date or currency labels. For example, June 5, 2026 against July 5, 2026, or USD 40 against EUR 40, grounds because the digit-containing tokens match. Use $40 against EUR 40 or March 16, 2026 against 2026-03-15 for examples that report missing.
  • Both sides undo Markdown punctuation escapes, including literal backslashes in plain-text bodies. Example: plain-text INV\-5 matches INV-5.
  • Occurrence alone confirms neither the subject nor other claims. Example: a cited price doesn't establish which item it belongs to.

Read complete retained sections

get_text_outline and read_text_section are default read-only tools on stdio and HTTP. They use the saved citation above and need no write opt-in. A valid historical rendition works even without a configured or executable profile.

  1. Send get_text_outline {citation, offset: 0}. If you have no particular quote, use citation range [0,1) with the exact retained identities.
  2. Choose the returned enclosing_section, or any sections entry. The enclosing section contains the entire anchor, including an anchor crossing smaller sections. To browse more entries, use the optional next_offset.
  3. Send read_text_section {citation, section: {start,end}, offset: 0, max_chars: 16000}. The section includes its subsections.
  4. Append text, replace the relative offset with next_offset, and continue until complete is true. Keep the citation and section unchanged. A page is not a complete section until then; a later failure leaves a partial result.
  5. To cite a nonempty page, copy its citation and substitute actual_start and actual_end. resolve_text_citation reopens those exact bytes.

Sections describe stored Markdown. They preserve code-point offsets, escapes, combining marks and line endings. title_markdown is a navigation label, limited to 160 code points with explicit title_truncated; it is not quotation text. The plaintext adapter also normalizes through Markdown, so # comments in Python, YAML or plain text can appear as headings. This does not reconstruct source-language structure or the original document's layout.

Each request verifies and parses the whole retained artifact. Navigation is limited to 4 MiB, 65,536 LF characters and 4,096 headings, with two concurrent reads per service. Outline pages contain at most 50 entries. Section pages contain 1–16,000 code points; use the largest useful page size to avoid repeated reads. Waiting counts against the daemon deadline. Parsing is synchronous and cannot be interrupted mid-call. Results use private cache scope and zero TTL.

Malformed arguments, including negative offsets and reversed bounds, return MCP's generic invalid-arguments error before contacting the daemon. Once the daemon reads the rendition, invalid_text_navigation means to correct whole-section bounds or offsets using that rendition's outline. text_navigation_limit means the artifact exceeds a navigation cap. Short citations still support artifacts up to 64 MiB. rendition get can download an attachment still active for its version; a superseded attachment has no general bulk-download path here. Existing citation errors keep their meanings. A missing processing service or a transport/decode failure keeps the existing generic MCP error behavior.

Every page checks retained authority again. Trash, pruning or purge between pages can stop a read sequence; there is no cursor, saved outline or retention lease. The full HTTP contract owns fields, limits and errors. Neither page hashes nor a saved citation prove that provider text quotes the original file verbatim.

Optional processing start

Start a process with the additional tool only when the agent is allowed to enqueue already-consented work:

docbank mcp --transport stdio --allow-processing

The tool catalog then adds start_processing. It accepts only a content-version UUID and the 64-character plan fingerprint previously returned by get_processing_plan from the same MCP process. The process remembers at most 4,096 reviewed plans. An evicted plan, a fingerprint from another process, changed disclosure, changed profile, or stale source is rejected.

MCP cannot grant consent. The tool sends consent=false to the daemon and succeeds only when the operator already granted consent for the identical plan through an operator-controlled Docbank surface. With the public CLI, first call get_processing_plan in MCP, then have the operator verify and consent to that same plan:

docbank processing plan id:<node-id> --profile <configured-profile>
docbank processing build id:<node-id> \
  --profile <configured-profile> \
  --plan-fingerprint <fingerprint-from-plan> \
  --consent

The fingerprint and content-version ID printed by the CLI plan must match the MCP plan. processing build --consent records consent and also starts the reviewed work. It is not a consent-only command. See Document processing for the complete operator flow.

After consent is active, start_processing returns the stable queued job identities, including at most 64 embedding job IDs, and does not poll. An initial processing_outcome_unknown result contains no job ID, so its outcome cannot be reconciled through MCP. Do not retry it blindly, because MCP has no job lookup for that case.

Recover numbered PDFs

Use find_bates_exports to find a retained delivery by an exact Bates label. With --allow-package-writes, export_bates_file saves that PDF outside the vault. Its verification field distinguishes stamped_labels for ordinary stamped exports with the installed engine from recorded_bytes_and_numbers for numbered native redactions or stamps made with a different engine version. The latter checks the recorded size, SHA-256 and numbering metadata; it does not recheck masks, approved text or rendered numbers. It works after restart and backup/restore without the original review files or a configured page runtime.

Numbered reservation and rendering use the CLI or authenticated HTTP routes. Full download verification requires the three review files through bates export download; the MCP export tool does not accept them. See Numbered delivery for retention consent and verification scope.

Optional package writes

Allow the agent to preflight local load-file sources, import packages, and change package custodians with a separate opt-in:

docbank mcp --transport stdio --allow-package-writes

This flag adds four tools:

Tool Contract
preflight_load_file_package Reads a local source and retains a preflight with diagnostics before import.
start_package_import Starts an import from an exact preflight identity and operation UUID. An exact retry with the same operation UUID returns the existing operation.
resolve_package_custodian Links an existing package custodian claim to an exact canonical person, subject to the supplied revision.
assign_package_custodian Creates or replaces an operator-owned package custodian, subject to the supplied revision.

Review the preflight and its diagnostics before starting an import. Keep the operation UUID to read progress with get_package_import and to reconcile a retry. Custodian writes use exact identities and revision checks to reject stale changes.

Package writes do not use the processing-plan consent flow. Enable this flag only when the agent may perform these local reads and vault changes. --allow-package-writes does not enable start_processing, and --allow-processing does not enable package writes. Use both flags when both capabilities are needed.

No MCP tool can delete documents, move, rename, tag, restore, prune, pack, repack, change configuration, select credentials, grant processing consent, or return source bytes. Package preflight may upload a local source container, but there is no general document upload tool.

Cache behavior

Result ttlMs cacheScope
server/discover 60000 public
tools/list 60000 public
resources/list 60000 public
resources/templates/list 60000 public
Tool success containing vault or job data 0 private
resources/read 0 private

Catalog results are public only because they contain no vault-derived data and are identical for every caller of that process. HTTP adds Cache-Control: no-store to every response, including errors and otherwise public catalogs.

HTTP limits and unsupported surface

HTTP is stateless and POST-only. Each request contains one JSON-RPC message. There are no GET streams, sessions, Mcp-Session-Id, resume support, or Last-Event-ID. The server allows 10 seconds to receive request headers. After the headers arrive and the request passes the boundary checks, a separate two-minute deadline covers request-body reads, daemon work, and response writes. The public limits are:

Resource Limit
Request body 1 MiB
Combined header names and values 32 KiB
Header field values, counting repeats separately 128
Bearer token 4,096 bytes; empty values, spaces, and control bytes are rejected
Concurrent requests 32 total
HTTP response body 1,114,112 bytes
Header-read timeout 10 seconds
Idle connection timeout 30 seconds

The request Host must be loopback, the concrete listen IP, or an explicitly allowed authority. An absent Origin is valid for non-browser clients. If Origin is present, exactly one plain-HTTP Origin must match the request Host and port. Unsafe or cross-origin requests are rejected before authentication. Forwarded-host headers do not change this decision.

Docbank does not expose MCP prompts, roots, sampling, elicitation, or tasks. It does not negotiate a legacy protocol, open a remote daemon, provide remote daemon configuration, implement OAuth, maintain HTTP sessions, resume streams, or expose a general write surface.

Read calls may reacquire the local daemon and retry once only when transport failure occurs before any response. Failures after a response are not replayed. Daemon acquisition is capped at 45 seconds. Each HTTP request has the two-minute post-header deadline above. Stdio work otherwise runs until completion or client cancellation. Daemon restart, an idle shutdown, or a stale runtime record therefore produces a bounded failure or recovers on the next safe read without terminating stdio with diagnostics on stdout or leaving HTTP pinned to a dead client.

Native export jobs

Photo-export preparation uses the CLI or Photos. MCP supports inspection of retained photo-export plans and jobs.

get_export_plan, get_export_problems, and get_export_status are available with all write flags disabled, over stdio or HTTP. Plan inspection requires a retained plan ID. get_export_plan returns the complete plan, including richer source, role, count, and volume fields when present. Its expires_at is the admission deadline. The plan can stay readable longer while a job retains it. Reading does not extend either deadline.

get_export_problems returns a problems object with plan_id, fingerprint, after, next, total, and items. Omit after for the first page, then pass a nonzero next as after. Zero marks the last page. The tools return private results with ttlMs: 0. MCP may retry a read once when transport fails before any response starts. Domain errors and partial responses are never retried.

Plan reads use the shared API-key owner and cannot inspect browser-owned plans. An expired or removed plan needs a fresh preview with new IDs for a new export. Inspect an existing job through status. Problem details remain frozen after source edits. Totals count unavailable outputs and inventory problems, not selected documents. Originals-only previews normally have none.

The fixed 50-item page must fit within 64 KiB. An export_limit response returns no partial page. HTTP has the same limit and cannot request fewer items. Releasing jobs cannot shrink that page. See retained-plan inspection for offsets, identity fields, and retention behavior.

Start with docbank mcp --allow-export-writes to let a client retain exact originals and manage their export. Review the selection with the operator.

Tool Required arguments and result
preview_export source_operation_id, plan_operation_id, and members. Returns a retained plan.
start_export operation_id, plan_id, and fingerprint. Returns the job; it does not wait for completion.
cancel_export job_id. Permanently stops active work. Returns accepted: true; completed jobs conflict.
download_export job_id, absolute destination_path, optional overwrite (default false). Returns the verified receipt and publication state.
release_export job_id. Deletes a terminal job and its retained archive, returning released: true.

List versions for each selected node. Copy content_version_id to version_id, blob_hash to sha256, and copy node_id and size into each member. This takes one list_document_versions call per node, with more pages if needed. Each preview accepts 1–1,000 retained original versions totaling at most 50 GiB. It can include multiple versions of the same node. Size is required, including zero for an empty original. Optional revision is a current node precondition. Omit it unless needed. A version's historical node revision is not that precondition.

Generate all operation IDs before calling. After export_outcome_unknown, inspect the known job ID or replay the same request and IDs. The first write after a daemon restart can report this even when nothing was sent. Docbank does not reconnect and repeat writes automatically. Preview replay must keep member order and remains subject to its original ten-minute admission window. After a delayed start response, use job status instead of replaying preview. Never reuse a released job ID: its replay record has been deleted.

For export_timeout, export_canceled, or export_failed during start, download, or release, read get_export_status before retrying. Use the start operation ID as the job ID. After a download error, inspect the destination too, because the file may already be saved. After a release error, not found confirms removal.

MCP shares the API-key owner with the CLI. Completed jobs still occupy the two shared job slots until released or expired. Release does not delete originals or local downloads. export_retained means a download ticket or lease still holds the archive. Retry release after it closes. The source and plan records have separate global limits. See export limits and recovery.

To save an export:

  1. Call preview_export with your exact members and two fresh operation IDs.
  2. Review plan.total and plan.role_bytes, then call start_export with a fresh operation ID, plan.id, and plan.fingerprint.
  3. Call get_export_status with that job ID. When it completes, inspect job.receipt.size before choosing a download transport.
  4. Call download_export with the job ID and a destination on the MCP host.
  5. After saving the file, call release_export to free the retained job slot.

The destination parent must exist and resolve outside the Docbank data directory. An existing destination must be a regular file and requires overwrite: true. Verification occurs before publication: the daemon verifies the retained archive, then the MCP process streams it into a private stage and independently verifies the complete bundle against the job and ticket receipts. The result contains no ZIP bytes or download ticket. Download never releases, cancels, or recreates the job automatically.

state: "published" means the verified file is saved. state: "published_durability_unknown" means the file became visible but the subsequent directory sync failed. Both return the receipt. cleanup_failed: true means private staging cleanup failed after publication. The saved file remains. Before publication, ordinary failures preserve the destination and attempt stage cleanup. export_integrity identifies a receipt or archive mismatch, and export_local_io identifies a local file-operation failure. The operator log records the operation and its cause. The client receives a fixed message. A failed stage cleanup can leave a private stage behind and is logged separately. A secondary cleanup failure does not replace the original error.

export_unavailable means the daemon has no export worker. That request made no change. Check the daemon and retry. For export_expired, preview again with new IDs if admission expired, or release a retained job whose archive is missing.

The HTTP two-minute deadline includes daemon verification, transfer, and local verification. Archive size alone cannot predict whether all three fit. For a large job, use docbank export download <job-id> <path> against the same vault or a suitable stdio invocation. A later download obtains a fresh ticket and transfers the whole file again. A lost response or cancellation after publication can leave a verified destination. Inspect that file before retrying with overwrite.

Frozen search reports

Enable report writes to capture exact current versions, review dates, save an evidence ZIP on the machine running MCP, and release unneeded live reports:

docbank mcp --allow-report-writes
# Include original-file exports in the same workflow:
docbank mcp --allow-report-writes --allow-export-writes
Tool Contract
create_report Takes a version 1 request with selected_documents, timezone, and terms. Captures 1–1,000 current document identities and 1–128 term rows.
revise_report Takes report_id and 1–1,000 reviewed date choices. Creates a child, retaining unmentioned parent choices and the original expiration.
download_report Takes report_id, an absolute destination_path, and optional overwrite (default false). Saves a verified ZIP outside the data directory.
release_report Takes report_id. Discards this live packet and date-review evidence and frees its handle slot. History, saved files and published children remain.

These writes require the report flag. The two inspection tools remain available without it and can inspect CLI-created whole-vault or collection reports too. Creation through MCP accepts only exact current document selections. It starts no processing or provider work.

  1. Use list_documents or search to choose node/current-version pairs. For each node, call list_document_versions and match the exact version to obtain blob_hash. get_document inspects a chosen pair. It requires both IDs.
  2. Build selected_documents.documents with each positive node_id, canonical lowercase UUIDv4 version_id, and lowercase SHA-256 sha256. Select each node once. Use the report request format for terms, inclusive date cutoffs, timezone, and optional processing profile.
  3. Call create_report. Omitted coverage_mode means strict. Choose available_only if incomplete evidence is acceptable. A changed selection returns report_selection_changed. Refresh and reselect rather than substituting newer versions automatically.
  4. For needs_review, page through get_report_dates. Keep each member's earlier candidates when candidates_complete is false. Continue with the returned cursor until next_cursor is absent. Review the evidence with the operator, then submit the existing date-choice format to revise_report. Restart date paging on the child. Parent cursors cannot be used on it.
  5. Read counts and coverage through get_report_summary. Download a complete report before it expires. To export the same originals, pass the selected identities and their version-list sizes to preview_export separately.

Creation rejects all_documents: true, collection_ids, and date_choices. Unknown fields and explicit nulls are invalid. Expressions allow 8,192 Unicode characters. Profile and timezone strings allow 128 UTF-8 bytes. A selection's member count is not the coverage scoped count: members without usable dates can remain in an available-only packet without contributing to counted coverage.

Create and revise return compact receipts: report_id, optional parent_id, state, observed_at, expires_at, and unresolved_dates. Complete receipts also contain bundle_bytes and bundle_sha256. Needs-review receipts omit them. A large warning summary does not prevent delivery of the new handle. If full summary inspection returns report_limit, use docbank report show <report-id> --json or read it through HTTP. Dates, revision, and download remain available.

A revision allows 1,000 choices and 4,096 UTF-8 bytes per reason, but the entire MCP message must fit within 1 MiB, including escaping and its envelope. The two individual maxima do not fit together. Choose shorter reasons where appropriate or submit batches to successive children. Docbank never splits a revision for you. For a larger batch, the existing HTTP/CLI revision path accepts 8 MiB.

CLI and MCP share eight report handles. Every revision uses another slot. An initial report plus seven revisions fills those slots if no other reports are retained. All descendants expire 30 minutes after the original observation. Download frees no slot. Release unneeded handles explicitly with release_report, or wait for expiry when capacity is full. The engine also permits two simultaneous builds and 64 handles or pending builds globally. A restart loses live handles, and history receipts do not restore their artifacts.

Writes are never automatically replayed. report_outcome_unknown means a report write may have succeeded without a usable reply. For create or revise, inspect history with the operator using docbank report history --json, or through web/HTTP. History records requests and outcomes but does not establish live availability or reliably identify a lost reply. There is no idempotent replay. A deliberate retry creates another observation or child and uses another slot. The first write after a daemon restart may also return this error on a stale connection.

release_report is destructive and requires --allow-report-writes. It can release complete or review-pending reports; pending date evidence is lost. Success returns report_id, released: true, ttlMs: 0, and cacheScope: "private". Child reports keep their original expiry. Shared memory remains while a child or in-flight operation uses it, so releasing one handle does not guarantee global build or memory capacity.

An active download returns report_retained; retry deliberately after its server reader closes, even if the download call has already returned. After an uncertain release reply, inspect get_report_summary for the same ID. A successful read proves the handle remains. report_unavailable alone is inconclusive: MCP omits HTTP status, and the code can mean either a missing handle or an unavailable reporting service. History does not prove release. Repeating release for an absent handle returns unavailable. A deliberate retry uses the same ID and cannot create a new handle.

Downloads compare the summary, stream size and digest, and independently verified packet before publication. The CLI uses the same verification path. Success reports internally_consistent: true and source_verified: false. This does not establish authenticity of the source vault. The receipt's state is published, or published_durability_unknown if the file was saved but the final directory sync failed. cleanup_failed separately reports a staging cleanup failure. Local causes go to the operator log. If the reply is lost, inspect and verify the destination before retrying.

Read bundle_bytes before choosing a transport. MCP HTTP's two-minute deadline covers transfer, verification, and publication, so large ZIPs may not finish. Use stdio for the same live handle, or docbank report download <report-id> --output report.zip against the same vault. The CLI verifies the existing packet outside the MCP HTTP deadline and does not create another report. See CLI report recovery for inspection, history paging, and recovery after a local save error. ZIPs are capped at 512 MiB, and concurrent MCP downloads share a 1 GiB verification budget. report_limit can also mean that this shared allowance is exhausted. Source changes after capture leave the frozen report's evidence and counts unchanged.