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.

  • Add connection to integration

    Attach an existing service connection to an integration. Use this once the integration is created and the user has an authenticated connection for the target service: it gives the integration's Lambda code permission to call that service via the connection's ``account_id``. Idempotent — adding an already-attached connection is a no-op. Other attached connections are preserved. Find ``connection_id`` via ``list_integration_connections``; if no suitable connection exists, run an OAuth flow first via ``list_pipedream_apps`` and ``create_connect_token``. To detach, use ``remove_connection_from_integration``. Args: ctx: MCP context (injected by FastMCP). integration_id: Integration to attach the connection to. connection_id: Connection to attach.

  • Add tag to documents

    Apply an existing tag to one or more documents. Use this to label documents — e.g. "tag these three invoices as Urgent". Documents that already carry the tag are unaffected (the operation is idempotent). All documents must belong to the same workspace as the tag. The tag must already exist — find its ID with ``list_tags`` or create it first with ``create_tag``. Args: ctx: MCP context (injected by FastMCP). tag_id: ID of the tag to apply. document_ids: Documents to tag.

  • Archive documents

    Move documents to ``archived`` state. Use this to clear processed documents out of the active list without rejecting them — e.g. "archive last quarter's invoices". Archived documents stay searchable and retrievable but are filtered out of default workspace views. To flag documents as unusable, use ``reject_documents``. To sign off on documents in review, use ``confirm_documents``. Archiving is not deletion: there is no hard-delete tool in the public API. Args: ctx: MCP context (injected by FastMCP). document_ids: Documents to archive.

  • Assign document type to workspace

    Make a document type available for use in a workspace. Use this immediately after creating a document type while the user is on a workspace, or whenever the user wants an existing type to be usable in a different workspace. After assignment, documents uploaded to the workspace can be classified as this type and extracted with its field schema. This does not move the type — types belong to an organization, and a type can be assigned to many workspaces. To remove the assignment later, manage it via the workspace's classification settings; there is no separate unassign tool. To delete the type entirely, use ``delete_document_type``. Args: ctx: MCP context (injected by FastMCP). document_type_id: ID of the document type to assign. workspace_id: ID of the workspace that should use it.

  • Confirm documents

    Mark documents as validated, moving them from ``review`` to ``validated``. Use this when the user has reviewed extracted values and wants to sign off on a batch — e.g. "confirm these five invoices". Depending on the workspace's model-memory strategy, confirmed documents may also be added to model memory and used as future training examples. To reject obviously bad documents, use ``reject_documents``. To remove documents from active work without rejecting them, use ``archive_documents``. To change a misclassified document's type, use ``reassign_document_type``. Args: ctx: MCP context (injected by FastMCP). document_ids: Documents to confirm. Must already be in ``review``.

  • Create validation run

    Run a validation rule against a document and refresh its results. Use this immediately after ``create_validation_rule`` or ``update_validation_rule`` so the user sees fresh validation results in the UI without manually re-validating each document. Executes the rule's logic against the document's annotations and creates/updates validation results. For creating or modifying the rule itself use ``create_validation_rule`` / ``update_validation_rule``; this tool only triggers an evaluation pass. If ``document_id`` is omitted the tool auto-picks one document of the rule's document type — convenient for quick spot-checks but won't cover the whole backlog. Pass an explicit ``document_id`` for targeted reruns. Args: ctx: MCP context (injected by FastMCP). validation_rule_id: Rule to evaluate. document_id: Specific document to validate. If omitted, one is chosen automatically from the rule's document type. document_type_id: Override the auto-resolved document type when picking a document. Ignored when ``document_id`` is given.

  • Reassign document type

    Reassign documents to a different document type in the same workspace. Use this when classification has put documents under the wrong type — e.g. invoices misclassified as receipts — and you want to fix the type and re-extract under the correct field schema. The target ``document_type_id`` must already be assigned to the documents' workspace (see ``assign_document_type_to_workspace``). Documents stay in their current workspace; this tool does not move documents between workspaces (no public API supports that). To reject rather than reassign, use ``reject_documents``. Args: ctx: MCP context (injected by FastMCP). document_ids: Documents to reassign. document_type_id: New document type. Must be assigned to the same workspace the documents live in. reparse: Re-extract under the new type's fields. Default ``True``; set ``False`` only to change classification metadata without triggering a new extraction run.

  • Reject documents

    Move documents to ``rejected`` state. Use this when documents are unusable or out-of-scope — e.g. wrong document type with no good reassignment, scan too poor to extract, or a junk upload. Rejected documents are excluded from model memory. To accept documents instead, use ``confirm_documents``. To remove completed documents from active work without flagging them as bad, use ``archive_documents``. To re-classify a misclassified document rather than rejecting it, use ``reassign_document_type``. Args: ctx: MCP context (injected by FastMCP). document_ids: Documents to reject.

  • Remove connection from integration

    Detach a service connection from an integration. Use this when an integration should no longer have access to a particular service — for example, swapping accounts or cleaning up after a failed setup. Other attached connections are preserved. Removing a connection that wasn't attached is a no-op. The connection itself remains in the organization and can be used by other integrations; this only severs the link. To delete the underlying connection entirely, do that from the connections UI. To attach, use ``add_connection_to_integration``. Args: ctx: MCP context (injected by FastMCP). integration_id: Integration to detach the connection from. connection_id: Connection to detach.

  • Remove tag from documents

    Take a tag off one or more documents. Use this to un-label documents — e.g. "remove the Urgent tag from these invoices". The tag itself is kept and stays available for other documents; documents that don't carry the tag are unaffected. To delete the tag everywhere in one step, use ``delete_tag`` instead. Args: ctx: MCP context (injected by FastMCP). tag_id: ID of the tag to remove. document_ids: Documents to remove the tag from.

  • Set integration secret

    Create or update a secret on an integration. The value is stored only as an environment variable on the Lambda function — never in the database. Use this whenever the user provides a credential value (API key, token, password, etc.) that the integration code will need at runtime. NEVER embed such values directly in ``python_code`` — call this tool instead, then read the secret in code via ``os.environ["NAME"]``. The same tool handles both create and update: if a secret with this name already exists for the integration, its value is rotated. The integration must be deployed (have a Lambda) before the value reaches AWS; for pre-deploy integrations the name is recorded and the value is applied on the next deploy. Constraints: - ``name`` must match ``[A-Z][A-Z0-9_]*`` — uppercase letters, digits, underscores, starting with a letter. - ``AFFINDA_API_TOKEN`` and ``AFFINDA_API_BASE_URL`` are reserved. This tool is for the manual-credential path (e.g. a raw API key the user pasted). When auth is being handled through a Pipedream connection, use ``add_connection_to_integration`` instead — that flow does not need a secret. Args: ctx: MCP context (injected by FastMCP). integration_id: Integration to attach the secret to. name: Environment variable name, e.g. ``"STRIPE_API_KEY"``. value: The secret value. Stored only as a Lambda env var.

  • Update data source

    Update top-level settings on a data source (name, key, display property). Use this for metadata changes: renaming the data source, switching which schema property is the unique key, or changing which property is shown in the UI. Only the parameters you provide are sent; omitted parameters are untouched. This tool does NOT add, change, or remove rows — for row mutations use ``create_data_source_value``, ``update_data_source_value``, ``delete_data_source_value``, or ``bulk_create_data_source_values``. Schema changes (adding columns) must be done in the Affinda UI. Args: ctx: MCP context (injected by FastMCP). data_source_id: ID of the data source to update. name: New display name. key_property: New unique-key property. Must already exist in the schema and be unique across rows; renaming the key on a populated data source can break existing row lookups. display_property: New UI display property.

  • Update data source value

    Update one row in a data source by its key — partial merge. Use this to change fields on an existing row: "rename ACME's label", "set GLOBEX's currency to USD". Only fields you pass are written; unspecified fields keep their current values. Fails with ``not_found`` if no row matches ``key``. For inserting a brand-new row use ``create_data_source_value``; for removing a row use ``delete_data_source_value``. There is no bulk update tool — for many edits, call this per row. Args: ctx: MCP context (injected by FastMCP). data_source_id: ID of the data source. key: Value of the data source's ``key_property`` for the target row. Look up the row via ``list_data_source_values`` if needed. value: Partial row as a JSON-encoded object string, e.g. ``'{"label": "New Label"}'``. If this object includes the ``key_property`` itself the row's key is renamed; the call fails with ``duplicate_key`` if the new key collides.

  • Update document type

    Update one or more settings on an existing document type. Use this to rename a type or toggle its UX/validation behaviour after creation. Only the parameters you provide are sent to the API; omitted parameters are untouched. Read the current state with ``get_document_type_details`` first if you need to reason about deltas. For the initial create use ``create_document_type``. To change which workspace a type belongs to, use ``assign_document_type_to_workspace`` — that's a relationship op, not a setting. Field-schema changes go through ``create_field`` / ``update_field`` / ``delete_field``. Args: ctx: MCP context (injected by FastMCP). document_type_id: ID of the document type to update. name: New display name. disable_confirmation_if_validation_rules_fail: Block confirmation when validation fails. show_redact_button: Show the redaction button in the UI. auto_refresh_validation_results: Re-run validation when the document changes.

  • Update field

    Update one or more settings on an existing field. Use this for any change to a field after creation: rename, retype, reorder, move between field groups, edit the extraction prompt, toggle ``enabled`` / ``multiple`` / display flags, attach or detach a mapping data source, or set a transformation. Only the parameters you provide are sent to the API; omitted parameters are untouched. Structural restrictions (enforced here — call will be rejected): - Cannot change ``field_type`` to ``group`` or ``table``. - Cannot change ``field_type`` away from ``group`` or ``table``. Both directions break the child-field relationships and leave annotations referencing parents that no longer accept children. For restructures of that shape, ``delete_field`` and recreate. Hierarchical reshaping (changing nesting parents) is also unsupported — there's deliberately no ``parent_id`` parameter here. Reassigning a field's parent breaks annotations; delete and recreate instead. For data-source attachment, this tool is correct (pass ``mapping_data_source_id``); pass the literal string ``"null"`` to detach. Some attributes (``multiple``, ``no_rect``, ``description``) are locked once a document type has trained a model. Args: ctx: MCP context (injected by FastMCP). field_id: ID of the field to update. slug: New camelCase API identifier. label: New human-readable label. field_type: New data type. Cannot be ``group`` or ``table``, and cannot be used to retype a field whose current type is ``group`` or ``table`` (see restrictions above). ``integer`` and ``decimal`` are accepted but normalised to ``float`` (the product's single numeric type — the UI cannot display the others). Beware: changing type may invalidate existing extractions. description: New extraction prompt. enabled: Toggle the field on/off. multiple: Toggle multi-value extraction. no_rect: Toggle rectangle requirement. return_first_instance_only: Return only first match when ``multiple=True``. manual_entry: Toggle manual-entry mode. auto_confirm_if_validation_rules_pass: Auto-confirm extractions that pass all validation rules. display_enum_value: Show enum value rather than its label. hide_enum_detail: Hide extra enum metadata in UI. drop_null: Omit null values from extraction results. display_raw_text: Show raw extracted text in UI. options: New allowed values for ``options`` fields. transformation_prompt: Natural-language reformat instruction; sets up an LLM transformation and triggers code generation. position: 0-based display order within the field group. Use to reorder fields. field_group_id: Move the field into a different group. mapping_data_source_id: Attach a data source. Attaching forces ``field_type`` to ``enum`` (a data source only functions on an enum field). Pass the literal string ``"null"`` to detach — detach leaves the field type untouched. decimal_places: For numeric (``float``) fields only — how many decimal places to round/display the value to. Use ``0`` for counts/quantities, ``2`` for currency. Only set this on a field that is (or is being set to) ``float``; the backend rejects a number formatter on other field types. Note this replaces the field's number formatter config.

  • Update integration

    Update one or more settings — including code — on an integration. Use this for any change after creation: rename, swap trigger event, rescope to a different workspace or document type, toggle enabled, or replace the Python code. Only the parameters you provide are sent; omitted parameters are untouched. ``python_code`` replaces the entire file; there is no partial-edit or diff tool. A typical code-update flow reads the current code with ``get_integration``, submits the complete replacement here, then deploys it with ``deploy_integration_version``. The saved code is not live until deployed, and ``run_integration`` executes the deployed version. For the initial create, use ``create_integration``. To attach or detach connections, use ``add_connection_to_integration`` / ``remove_connection_from_integration`` — connections are a relationship, not a setting. Args: ctx: MCP context (injected by FastMCP). integration_id: ID of the integration to update. name: New display name. description: New description. python_code: New full-file Python source. Replaces the whole file. enabled: ``True`` to enable, ``False`` to disable. event: Trigger event — ``document.parse.completed`` or ``document.validate.completed``. workspace_id: Scope to a specific workspace. document_type_id: Scope to a specific document type.

  • Update matching criterion

    Update settings on an existing matching criterion. Use this to retune lookup behaviour: switch ``match_type`` from fuzzy to exact for codes, point at a different ``data_source_property``, flip ``required`` on or off, or repoint a cross-field criterion at a different source field. Only the parameters you provide are sent; omitted parameters are untouched. For adding a new criterion use ``create_matching_criterion``; for removing one use ``delete_matching_criterion``. This tool does not change which data source is attached to the field — that's a field update, not a matching-criterion update. Args: ctx: MCP context (injected by FastMCP). matching_criterion_id: ID of the criterion to update. data_source_property: New data source property to match against. match_type: ``match`` (fuzzy), ``match_phrase`` (partial), or ``term`` (exact). required: If ``True``, unmatched extractions are rejected. required_strict: Stricter variant of ``required``. field_attribute: Source-field attribute (JSON / ENUM source fields). source_field_id: Repoint matching at a different source field.

  • Update organization

    Rename an organization. Use this only when the user explicitly asks to rename their organization (e.g. company rebrand, fixing a typo from signup). The name shown across the Affinda UI updates accordingly. The caller must have admin or owner rights on the organization; otherwise the API rejects the update. This tool only changes the display name. There are no per-organization processing settings — workspace-level configuration belongs on the workspace, so for OCR / splitting / classification changes use ``update_workspace`` instead. Args: ctx: MCP context (injected by FastMCP). organization_id: ID of the organization to rename. name: New display name.

  • Update tag

    Rename a tag. Use this when the user wants to change a tag's name — e.g. "rename the Urgent tag to High Priority". The rename applies everywhere at once: every document carrying the tag shows the new name immediately. A tag cannot be moved to a different workspace; create a new tag there instead. To change which documents carry the tag, use ``add_tag_to_documents`` / ``remove_tag_from_documents``. Args: ctx: MCP context (injected by FastMCP). tag_id: ID of the tag to rename. name: New tag name. Max 256 chars.

  • Update validation rule

    Update one or more settings on an existing validation rule. Use this when the user asks to MODIFY a rule (change its prompt, enable/disable it, change the field set). When the user wants to extend an existing rule's logic, read the current ``prompt`` via ``get_validation_rule`` first and merge the new requirement into a single combined prompt — do NOT create a parallel rule. Only the parameters you provide are sent; omitted parameters are untouched. For brand-new checks not already covered by an existing rule, use ``create_validation_rule``. To remove a rule, use ``delete_validation_rule``. To re-run validation against a document after changes, use ``create_validation_run``. Always reference fields in ``prompt`` via the ``@<field_id>`` syntax, not plain text — call ``list_fields`` for IDs. **For data inside a table or group, reference the CHILD (cell) field IDs, NOT the parent field ID.** Parent fields (``field_type`` in ``{table, table_deprecated, group}`` with a non-empty ``children`` list) are the row / container; only children hold actual cell values. A rule against the parent ID validates the container, not the data. For a ``lineItems`` table (id=4820) with cell children ``quantity`` (4822), ``unitPrice`` (4823), ``amount`` (4824): - ✅ ``prompt="@4822 must be > 0"`` and ``field_ids=["4822"]`` - ❌ ``prompt="@4820 must not be empty"`` and ``field_ids=["4820"]`` Same applies to ``group`` parents. Translate row-level user phrasing ("each line item must…", "every row's…") into references on the cell children, never the parent. Args: ctx: MCP context (injected by FastMCP). validation_rule_id: ID of the rule to update. prompt: New natural-language rule, with ``@<field_id>`` references. field_ids: New list of fields the rule validates. Pass as a native list, not a JSON string. enabled: Toggle the rule on/off. generate_code: Force regeneration of the validation code from the prompt. Default ``False``.

Page 1 / 2Next