Affinda MCP

Extract and validate data from documents and manage Affinda workspaces, document types, fields and integrations through Affinda's hosted MCP server.

Tools

This is a reference catalogue. Tools cannot be configured or run from this page.

  • Get data source

    Get one data source by ID — name, schema, and key/display properties. Use this when you already know the ``data_source_id`` and need its metadata: typically to read ``key_property`` before adding/updating rows, to inspect the schema before deciding which property to match against, or to confirm the data source exists. Returns ``data=null`` with ``error="not_found"`` if the ID does not match. For the rows stored inside the data source use ``list_data_source_values``. To enumerate data sources in an organization use ``list_data_sources``. Args: ctx: MCP context (injected by FastMCP). data_source_id: ID of the data source to fetch.

  • Get document

    Get one document by ID — state, workspace, document type, and basic metadata. Use this when you already have a ``document_id`` and need a lightweight summary, e.g. to confirm a document exists, check its processing state, or look up which workspace and document type it belongs to. Returns ``data=null`` with ``error="not_found"`` if no document matches. For extracted field values (text, parsed values, confidence) use ``get_document_extraction`` instead. To enumerate documents, use ``list_documents``. Args: ctx: MCP context (injected by FastMCP). document_id: ID of the document to fetch.

  • Get document extraction

    Get the extracted data for one document — raw text plus all field values. Use this to review how a specific document was extracted: every field value with its confidence score, preserving nested structure (groups, tables). Typical scenarios are answering "what did we extract from this doc?", spot-checking a document the user is looking at, or confirming a value before suggesting a fix. To diagnose *why* a document was extracted a certain way, check ``reference_document_id`` in the response: when set, extraction was guided by that model-memory document, used as an in-context example. Call this tool again with that ID to see the example's confirmed (ground-truth) values — a surprising extraction often traces back to how the equivalent field was verified on the reference document. Review one document at a time. Do NOT loop this over many documents for bulk export — direct the user to the "Download extraction" UI in the workspace's documents view instead. To spot-check one field across many documents, use ``list_recent_field_annotations``. For just state and metadata (no extraction), use ``get_document``. Only works once the document has finished processing and been classified. Args: ctx: MCP context (injected by FastMCP). document_id: ID of the document to inspect.

  • Get document page images

    View a document's pages as rendered images — see the actual document, not just OCR text. Use this when the visual appearance of the document matters and text alone is ambiguous: layout questions, checkboxes and selection marks, signatures, stamps, handwriting, logos, or diagnosing why extraction misread something. The images show each page as it appears in the document review UI. With ``show_annotations`` the extracted annotations are drawn on top of each page as colored rectangles tagged with their field slug — use this to check *where* a value was read from: wrong instance picked, value attributed to the wrong field, or table rows/columns mapped incorrectly. On dense documents, pass ``field_slugs`` to only draw the fields you are debugging (a table's slug also draws its cells). Images are expensive (in tokens) — request only the pages you need, at most 5 per call. For extracted values and raw text, use ``get_document_extraction`` instead; only reach for images when text output isn't enough. Args: ctx: MCP context (injected by FastMCP). document_id: ID of the document to view. page_indices: Zero-based page indices to fetch (e.g. ``[0]`` for the first page). Omit to get the first 5 pages. show_annotations: Draw the extracted annotations on the page images as rectangles labelled with their field slug. field_slugs: Only draw annotations for these field slugs (implies ``show_annotations``). Omit to draw all annotated fields.

  • Get document type

    Get one document type by ID — name, organization, and counts only. Use this when you already know the ``document_type_id`` and need a lightweight summary, e.g. to confirm the type exists or display headline counts. Returns ``data=null`` with ``error="not_found"`` if no document type matches. For settings (validation behaviour, redact button, auto-refresh) call ``get_document_type_details`` instead. For its fields, call ``list_fields``. To enumerate types in an org, use ``list_document_types``. Args: ctx: MCP context (injected by FastMCP). document_type_id: ID of the document type to fetch.

  • Get document type details

    Get a document type's full configuration — settings + counts. Use this whenever you need to read or reason about document-type settings: validation-blocking confirmation, the redact button, and auto-refresh of validation results. Typical scenarios are answering "what's the current config?" and reading the current value before computing a patch for ``update_document_type``. For just the headline counts (no settings) prefer ``get_document_type``. Fields and validation rules live on separate endpoints — call ``list_fields`` or ``list_validation_rules``. Args: ctx: MCP context (injected by FastMCP). document_type_id: ID of the document type to fetch.

  • Get field

    Get one field by ID — full settings, formatter, and relationships. Use this when you already know the ``field_id`` and need details that ``list_fields`` doesn't surface compactly (formatter config, transformation config, attached data source). Returns ``data=null`` with ``error="not_found"`` if no field matches. To enumerate every field on a document type, use ``list_fields`` instead — it groups results and shows hierarchy. To modify a field after reading, use ``update_field``. Args: ctx: MCP context (injected by FastMCP). field_id: ID of the field to fetch.

  • Get field group

    Get one field group by ID — label, position, parent document type. Use this when you already know the ``field_group_id`` and want a direct lookup. Most callers should prefer ``list_fields``, which returns every group on a document type along with its fields in one call — usually what's actually needed. Args: ctx: MCP context (injected by FastMCP). field_group_id: ID of the field group to fetch.

  • Get integration

    Get one integration by ID — full configuration, code, and connections. Use this whenever you need to read the current Python code or the attached connections. Critical before calling ``update_integration`` with ``python_code``: that field replaces the entire file with no partial-edit option, so you must read the existing code first and compose a complete replacement. Also use it to confirm trigger event, workspace / document-type scoping, and deployed state. To enumerate integrations in an organization, use ``list_integrations``. Returns ``data=null`` with ``error="not_found"`` if the ID is unknown. Args: ctx: MCP context (injected by FastMCP). integration_id: ID of the integration to fetch.

  • Get integration run

    Get one integration run by ID — full, untruncated logs and output. Use this when diagnosing a failing integration. ``list_integration_runs`` truncates logs to 10,000 characters, which often hides the actual error; this tool returns the complete log stream and is the right starting point for any "why did my integration fail?" investigation. To find recent run IDs for an integration, call ``list_integration_runs`` first, then drill into the failed run with this tool. Returns ``data=null`` with ``error="not_found"`` if the run ID is unknown. Args: ctx: MCP context (injected by FastMCP). integration_run_id: ID of the integration run to fetch.

  • Get usage

    Get daily credits consumption for an organization over a date range. Use this to answer "how many credits have we used?", to break usage down by day, or to attribute spend to one workspace or document type. Returns a ``total`` plus a per-day ``items`` list; days with zero usage are omitted. Optionally scope with ``workspace_id`` or ``document_type_id`` — but not both, since the API aggregates each axis independently and combining them is silently invalid. The caller must be an admin or owner of the organization; non-admins receive ``error="forbidden"``. There is no per-user breakdown and no sub-daily granularity — both are deliberate limits of the underlying report. Args: ctx: MCP context (injected by FastMCP). organization_id: Organization to report usage for. workspace_id: Optional. Scope to one workspace; mutually exclusive with ``document_type_id``. document_type_id: Optional. Scope to one document type; mutually exclusive with ``workspace_id``. start_date: Inclusive ``YYYY-MM-DD``. Defaults to one month before ``end_date``. end_date: Inclusive ``YYYY-MM-DD``. Defaults to today.

  • Get validation rule

    Get one validation rule by ID — prompt, enabled, fields, missing-data option. Use this when you already know the ``validation_rule_id`` and need to inspect or quote the existing prompt before patching it via ``update_validation_rule``. Returns ``data=null`` with ``error="not_found"`` if no rule matches. To enumerate every rule on a document type, use ``list_validation_rules`` instead. Args: ctx: MCP context (injected by FastMCP). validation_rule_id: ID of the validation rule to fetch.

  • Get workspace

    Get one workspace by ID — name, organization, and document counts only. Use this when you already know the workspace_id and need a lightweight summary, e.g. to confirm the workspace exists or to display headline counts. Returns ``data=null`` with ``error="not_found"`` if no workspace matches the ID. For OCR / splitting / classification / model-memory settings, call ``get_workspace_details`` instead — that surface includes the full configuration. To enumerate workspaces in an organization, use ``list_workspaces``. Args: ctx: MCP context (injected by FastMCP). workspace_id: Internal numeric ID returned by list_workspaces, not the alphabetic identifier.

  • Get workspace details

    Get a workspace's full configuration — settings + counts. Use this whenever you need to read or reason about workspace settings: OCR mode, document splitting, classification, model-memory strategy, duplicate rejection, and validation flags. Typical scenarios are answering "what's the current config?", deciding whether to suggest a settings change, and reading the current value before computing a patch for ``update_workspace``. For just the headline counts (no settings) prefer ``get_workspace``; it does fewer joins on the API side. Args: ctx: MCP context (injected by FastMCP). workspace_id: Internal numeric ID returned by list_workspaces, not the alphabetic identifier.

  • List data sources

    List data sources (lookup tables) defined on an organization. Use this to discover the ``data_source_id`` for downstream tools, or to show the user what lookup tables already exist in their org. Data sources are organization-scoped enum-style records (suppliers, currencies, charge types, ...) that can be attached to fields for constrained extraction. Returns a lean summary with ``id``, ``name``, schema, and document-type usage count. For the rows inside a data source use ``list_data_source_values``; to fetch one data source by ID use ``get_data_source``. Args: ctx: MCP context (injected by FastMCP). organization_id: Organization to scope the list to. Required. limit: Cap on returned items. Default 20 — usually enough.

  • List data source values

    List the rows (records) stored in a data source. Use this to inspect the actual contents of a lookup table — typical scenarios are "what suppliers are in this list?", finding the row to update or delete by its key, or sanity-checking a recently-populated data source. Each row is returned as a raw dict matching the data source's schema. For data source metadata (name, schema, key property) use ``get_data_source``. To enumerate data sources themselves use ``list_data_sources``. Args: ctx: MCP context (injected by FastMCP). data_source_id: ID of the data source whose rows to read. limit: Cap on returned rows. Default 100.

  • List documents

    List documents in a workspace with their state and basic metadata. Use this to find documents by workspace, narrow by state, or run a full-text search across file names and extracted text — for example, "show me documents in review" or "find docs mentioning Acme". For one document by ID, use ``get_document``. For extracted field values, use ``get_document_extraction``. To wait for in-flight processing to finish before listing, use ``wait_for_document_processing`` instead of polling this tool. Args: ctx: MCP context (injected by FastMCP). workspace_id: Workspace to scope the query to. state: One of ``review``, ``validated``, ``archived``, ``rejected``. Omit to include all states (including ``processing``). search_text: Full-text query against file name and extracted text. limit: Cap on returned items. Default 20.

  • List document splitters

    List document splitters available to an organization. Use this whenever you need a ``document_splitter_id`` to pass into ``create_workspace`` or ``update_workspace`` with splitting enabled. The list includes global splitters (notably "General Document Splitter", a safe default) and any organization-specific splitters the customer has trained. There is no separate "get splitter" tool — for splitter details, find the entry in this list. Args: ctx: MCP context (injected by FastMCP). organization_id: Organization to scope the list to. Required by the API for access control even when listing global splitters.

  • List document types

    List document types in an organization. Use this to discover existing document types — for example, to find a ``document_type_id`` to pass into other tools, to check whether a similar type already exists before creating a new one, or to show the user what's configured. Each item includes document counts and a fields count for a quick activity overview. For the full settings of a single type (validation toggles, redact button, refresh behaviour) use ``get_document_type_details``. For its fields and field groups use ``list_fields``. Args: ctx: MCP context (injected by FastMCP). organization_id: Organization to scope the list to. Required. limit: Cap on returned items. Default 50 — fits most orgs.

  • List fields

    List a document type's full field schema, grouped by field group. Use this whenever you need the field layout: discovering field IDs to pass into other tools, checking for pre-populated template fields after ``create_document_type``, reading positions before reordering, or finding numeric IDs to embed in validation rule prompts (the ``@<field_id>`` syntax). Returns each field group with its fields, plus the child IDs of any ``group``/``table`` parents. For a single field by ID, use ``get_field``. For just the document type's settings (no fields), use ``get_document_type_details``. Validation rules live separately — call ``list_validation_rules``. Args: ctx: MCP context (injected by FastMCP). document_type_id: Document type whose schema to fetch.

Page 1 / 2Next