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.

  • List pipedream apps

    Search the catalogue of Pipedream apps available for new connections. Use this when ``list_integration_connections`` returns no connection for the service the user wants (e.g. they ask to push to Notion but no Notion connection exists). Find the right ``name_slug`` here, then pass it into ``create_connect_token`` to start the OAuth flow. Search is imprecise — prefer short, simple terms (``"sheets"`` rather than ``"google sheets"``). Already-connected services are returned by ``list_integration_connections``, not this tool. Args: ctx: MCP context (injected by FastMCP). search_query: Optional substring to filter app names. Omit to list everything.

  • List recent field annotations

    Spot-check how one field is being extracted across recent documents. Use this for short, focused quality checks on a single field — e.g. after tweaking its description, transformation, data source, or validation rules and wanting a quick read on how it behaves now. Returns the newest annotations first (one row per annotation; fields with ``multiple=True`` can yield several per document). Query one field at a time; do NOT call in parallel across fields. This is NOT a bulk export — for extracted data across many docs or fields, point users at the "Download extraction" UI. For all fields on one document, use ``get_document_extraction`` instead. Args: ctx: MCP context (injected by FastMCP). field_id: Field to query. filter_by: Document subset — ``any`` (default), ``review``, ``validated``, or ``in_model_memory``. limit: Cap on returned annotations. Default 25, hard-capped at 100. Keep this small for spot-checks.

  • List tags

    List the tags defined in a workspace. Use this to discover the ``tag_id`` for downstream tools, to check whether a tag with a given name already exists before creating one, or to show the user what tags are available. Tags are workspace-scoped labels that can be applied to any number of documents. To apply or remove a tag on documents use ``add_tag_to_documents`` / ``remove_tag_from_documents``. To see which tags a specific document carries, use ``get_document``. Args: ctx: MCP context (injected by FastMCP). workspace_id: Workspace to scope the list to. Required. limit: Cap on returned items. Default 100 — usually enough.

  • List validation rules

    List validation rules attached to a document type. Use this BEFORE creating a new validation rule — document types often have existing rules (including disabled ones) that already match the user's intent. If a matching rule exists, enable / tweak it via ``update_validation_rule`` rather than duplicating. Also use this to discover rule IDs for ``update_validation_rule`` / ``delete_validation_rule``. For one rule by ID, use ``get_validation_rule``. For the document type's fields (often needed when authoring rule prompts) use ``list_fields``. Args: ctx: MCP context (injected by FastMCP). document_type_id: Document type to scope the list to. limit: Cap on returned items. Default 100.

  • List workspaces

    List workspaces in an organization. Use this to discover existing workspaces — for example, to find the right workspace_id to pass into other tools, or to show the user what they already have set up. Each item includes document counts so you can also use this for a quick activity overview. For full settings (OCR mode, splitting, classification, model memory) use ``get_workspace_details`` on a specific workspace; ``list_workspaces`` intentionally returns a lean view. Args: ctx: MCP context (injected by FastMCP). organization_id: Organization to list workspaces for. Use the organization's ID, not its identifier. Required. limit: Cap on returned items. Default 20 — enough for most orgs.

  • Populate fields from documents

    Infer and create the field schema for a document type from sample documents. Use this when the document type has **no fields yet** and you have one or more processed documents of that type. Call ``list_fields`` first; if any fields already exist, do **not** call this tool — it duplicates them. Use ``create_field`` / ``bulk_create_fields`` to add named extras instead. Pass 1–10 document IDs. The ML pipeline reads the source files, suggests names / types / structure (including tables and nested groups), writes those fields onto the type, then extracts the samples. Do **not** use this to invent a schema from a verbal description with no samples — that is ``bulk_create_fields`` / ``create_field``. Documents must have finished load/OCR (and splitting/classification if those are enabled) before you pass their IDs. Wait with ``wait_for_document_processing``. Extra IDs beyond 10 are ignored; pass the most representative samples. After this succeeds, call ``list_fields`` and show the user what was created so they can refine. Args: ctx: MCP context (injected by FastMCP). document_type_id: Document type that currently has no fields. document_ids: Processed document IDs to analyse. At least one required; capped at 10. instructions: Short natural-language steer (≤15 words), e.g. "focus on financial fields". Optional.

  • 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.

  • Revert integration version

    Roll an integration back to a previous version and redeploy it. Use this when a recent deploy introduced a regression and the user wants to restore a known-good version. The selected version's code becomes both the working code on the integration and the live deployed version in one step — there is no separate redeploy needed. Find ``version_id`` via ``list_integration_versions`` (the ``is_published`` flag marks the currently-live one — pick a different snapshot to revert to). To deploy newly-edited code rather than an older snapshot, use ``deploy_integration_version``. Args: ctx: MCP context (injected by FastMCP). integration_id: Integration to revert. version_id: ID of the version snapshot to restore.

  • Run integration

    Execute an integration against one document as a test run. Use this to verify a freshly-deployed integration before enabling it for live traffic, or to re-test after a fix. The run executes the currently-deployed version, so it must be preceded by a successful ``deploy_integration_version`` for the latest code to take effect. The run is flagged as a test and does not count as a production invocation. ``document_id`` must be the **numeric** document ID (e.g. ``"1000003"``), not the alphabetic identifier / slug. Inspect the resulting run with ``get_integration_run`` for full logs; ``list_integration_runs`` shows history with truncated logs. Args: ctx: MCP context (injected by FastMCP). integration_id: Integration to run. document_id: Numeric document ID to feed into the run.

  • 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.

  • Test connection

    Verify a service connection's credentials are still valid. Use this when an integration starts failing with auth-style errors, or when you want to confirm an OAuth flow finished successfully before relying on the connection. Returns ``is_valid=True`` if the upstream service accepts the stored credentials. To start a fresh OAuth flow rather than test an existing one, use ``create_connect_token``. To run an integration's Python code against a document, use ``run_integration`` — that exercises the full pipeline, not just credentials. Args: ctx: MCP context (injected by FastMCP). connection_id: ID of the connection to test.

  • 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.

PreviousPage 4 / 5Next