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.

  • Bulk create data source values

    Append many new rows to a data source in one call. Use this whenever the user provides more than one row to add — pasted lists, parsed CSV/JSON content, multi-row asks. Validation runs per-row before any save (missing key, duplicate within batch, duplicate against existing rows); if ANY row fails, NO rows are saved and you get per-row errors back. Fix the rejected rows and retry the whole batch. Do not loop ``create_data_source_value`` for multi-row asks — every single-row call is a full replace-all under the hood. There is no bulk update or bulk delete; this tool only appends. Maximum 500 rows per call. Args: ctx: MCP context (injected by FastMCP). data_source_id: ID of the data source to append to. values: Native list of row objects (NOT a JSON string — unlike the single-row tools). Each row must include the data source's ``key_property`` with a non-empty value, e.g. ``[{"value": "ACME", "label": "Acme Corp"}, {"value": "GLOBEX", "label": "Globex Inc"}]``.

  • Bulk create fields

    Create many fields on a document type in one call. Use this whenever the user describes more than one field they want to add (e.g. "create invoiceNumber, invoiceDate, totalAmount"), or when populating an existing document type from a user description. Cleaner than looping ``create_field`` because the user sees one confirmation. When the document type is brand new and sample documents are uploaded, prefer ``populate_fields_from_documents`` — it infers the schema from actual content. For a single named field, ``create_field`` is fine. For child fields under a ``group`` or ``table`` parent, use ``create_field`` per child (each needs its own ``parent_id``). Tables: this tool can create the table itself (include it in the flat list with ``field_type="table"`` and ``multiple=True``), but it CANNOT create the columns. The backend auto-creates a ``rows`` group child (``field_type="group"``, ``slug="rows"``, ``multiple=True``) under every new table; columns must then be added via ``create_field`` (singular) with ``parent_id`` set to the ``rows`` field id, not the table id. Do not manually create a ``rows`` field. All fields land in the same group (auto-resolved if omitted). Each field's schema mirrors ``create_field`` (slug must be camelCase, alphanumeric, lowercase first letter). Failures are reported per field — partial success is possible. Args: ctx: MCP context (injected by FastMCP). document_type_id: Parent document type ID. fields: Field definitions. Pass as a native list of dicts/models, not a JSON-encoded string. Max 50 per call. field_group_id: Place all fields in a specific group. Auto-resolves to the last existing group (or a new "Details" group) if omitted.

  • 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 api token

    Create a new long-lived Affinda API key for the current user. Returns the key exactly once — there is no way to retrieve it again, so surface it to the user immediately and tell them to save it. Each user can hold at most three keys. If they are already at the limit, this tool returns ``error="max_tokens_reached"`` and the agent should direct the user to revoke an existing key from ``the Settings page (the user-account one at /settings, not org settings) under the "API Keys" card`` in the portal rather than retrying. The agent cannot list, rename, or revoke keys — those stay in the app. The tool takes no arguments: the user is identified from the auth token, and the new key has no name or expiry. Users wanting either should manage the key in the portal afterwards.

  • Create connect token

    Mint an OAuth connect token + URL so the user can authorise a service. Use this when ``list_integration_connections`` shows no usable connection for the service the user wants. The returned ``connect_link_url`` is presented to the user (Affinda's UI renders it as a "Connect" button); once they finish the flow the connection becomes active and can be attached to an integration via ``add_connection_to_integration``. To check whether an existing connection still works rather than creating a new auth flow, use ``test_connection``. Args: ctx: MCP context (injected by FastMCP). connection_id: ID of the connection record to issue a token for.

  • Create data source

    Create an empty data source (lookup table) in an organization. Use this to set up a new enum-style lookup the user will populate afterwards — typical scenarios are "create a Suppliers list", "I need a Currencies data source", or any net-new reference table. The resulting data source is empty; add rows via ``create_data_source_value`` (one row) or ``bulk_create_data_source_values`` (many rows). To attach the data source to a field for extraction, update the field's ``mapping_data_source_id``. The default schema has ``value`` (key), ``label`` (display), and ``description``; pass ``schema_definition`` only when the user genuinely needs extra columns. Args: ctx: MCP context (injected by FastMCP). name: Display name (e.g. ``Suppliers``, ``Currencies``). organization_id: Owning organization ID. key_property: Property that uniquely identifies each row. Default ``value``. Lowercase keys (``email`` not ``Email``); must exist in the schema. display_property: Property shown in the UI. Default ``label``. schema_definition: Optional JSON Schema Draft 7 string. Omit to use the default ``value``/``label``/``description`` shape.

  • Create data source value

    Add one new row to a data source. Use this for conversational, one-at-a-time additions: "add supplier ACME", "append currency JPY". Fails with ``duplicate_key`` if the row's key collides with an existing row — switch to ``update_data_source_value`` to modify the existing row instead. For more than one row in the same request, use ``bulk_create_data_source_values`` — every single-row call is a full replace-all under the hood, so looping this tool is wasteful and increases the chance of clobbering concurrent edits. Args: ctx: MCP context (injected by FastMCP). data_source_id: ID of the data source to append to. value: The new row as a JSON-encoded object string, e.g. ``'{"value": "ACME", "label": "Acme Corp"}'``. Must include a non-empty value for the data source's ``key_property`` — call ``get_data_source`` first if unsure which property that is.

  • Create document type

    Create a new document type (extraction template) in an organization. Use this for any net-new document category the user wants to extract: Invoice, Purchase Order, Bank Statement, Contract, etc. A document type holds the field schema and validation rules used to extract structured data from uploaded documents. Common type names (Invoice, Receipt, Resume, Payslip, ...) silently auto-populate the full schema from a platform template at creation — there is no signal in the response. So after creation, always call ``list_fields``. If fields already exist, do not create the standard fields again and do not call ``populate_fields_from_documents``. If none exist, infer a schema from sample documents with ``populate_fields_from_documents``, or add fields with ``create_field`` / ``bulk_create_fields``. If you just uploaded a sample that has no document type yet, pass its ``document_id``. That assigns the document to the new type. If the type already has fields after create, the document is extracted — do not also call ``reassign_document_type`` for that document. For resumes / CVs, Affinda has a dedicated resume pipeline; use ``create_recruit_workspace`` instead. To make a created type available in a workspace, follow up with ``assign_document_type_to_workspace``. Args: ctx: MCP context (injected by FastMCP). name: Display name (e.g. "Invoice", "Purchase Order"). organization_id: Owning organization ID. disable_confirmation_if_validation_rules_fail: Block manual confirmation when validation fails. Default ``False``. document_id: Optional JSON:API id of a sample document with no type assigned yet. Assigns that document to the new type, and extracts it when the type already has fields.

  • Create field

    Create a single field on a document type. Use this when the user explicitly names ONE field they want extracted (e.g. "add a Vendor Email field"), or when adding a child field under an existing ``group``/``table`` parent. For multiple fields at once use ``bulk_create_fields`` — it's one confirmation, not many. For a brand-new document type with sample documents available, prefer ``populate_fields_from_documents`` (infers the schema from content). For a heading/section to organize fields, use ``create_field_group``, not this tool with ``field_type="group"``. A ``group`` field is for repeating structured data (e.g. line items with multiple=true). ``table`` is preferred over ``group`` when the data is a row/column grid. Parent fields MUST be ``group`` or ``table`` — children with any other parent type will break. Slug must be camelCase, alphanumeric only, lowercase first letter (``invoiceNumber`` — not ``invoice_number`` or ``Invoice Number``). If neither ``field_group_id`` nor ``parent_id`` is provided, the field is placed in the last existing field group, or a new "Details" group is created. Args: ctx: MCP context (injected by FastMCP). slug: camelCase API identifier (e.g. ``invoiceNumber``). label: Human-readable label (e.g. "Invoice Number"). field_type: Data type. Pick ``float`` for any numeric value (currency, quantity, percentage, count) — it is the product's single numeric type. ``integer`` and ``decimal`` are accepted but normalised to ``float`` (the UI cannot display them). Use ``group``/``table`` only for parents of nested children. document_type_id: Parent document type ID. field_group_id: Place under a specific group. Auto-resolved if omitted. parent_id: Set for child fields under a ``group``/``table`` parent. description: Extraction prompt — describe what to look for, where, and alternative labels. Omit for obvious fields. enabled: Default ``True``. Rarely set to ``False`` on create. multiple: ``True`` when the field has multiple distinct values per document (e.g. several work-experience entries). Tables and their row children almost always set this. no_rect: Skip annotation rectangle (calculated/manual fields). manual_entry: Field is filled by the user, not extracted. options: Allowed values for ``options`` field type. transformation_prompt: Natural-language reformat instruction (e.g. "Convert to uppercase"). Sets up an LLM transformation and auto-generates the code. Use only when the user explicitly asks to reformat. mapping_data_source_id: Attach a mapping data source for ``enum`` field extraction. Attaching a data source forces ``field_type`` to ``enum`` (see below) — a data source only functions on an enum field. 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, or omit to keep all significant digits. Ignored for non-numeric field types.

  • Create field group

    Create a field group (heading/section) on a document type. Use this when the user wants to organise fields into named sections in the UI (e.g. "Header", "Line Items", "Payment Details"). Field groups are purely visual — they have no effect on extraction. Move fields into a new group via ``update_field`` with ``field_group_id``. Do NOT confuse this with a ``group``-typed field, which is a repeating-data parent field for nested children. For that, use ``create_field`` with ``field_type="group"``. For a row/column grid, use ``create_field`` with ``field_type="table"`` instead. Args: ctx: MCP context (injected by FastMCP). document_type_id: Parent document type ID. label: Section heading shown in the UI.

  • Create integration

    Create a new integration in an organization. Use this for any net-new integration: a customer wants documents to fan out to Google Sheets, Slack, Salesforce, etc. The integration is created with no Python code and no attached connections. The trigger event and the workspace / document type scope are optional here. Typical sequence after this call: ``update_integration`` to set the code; ``add_connection_to_integration`` to attach a service; ``deploy_integration_version`` to make it live; ``run_integration`` to test against a real document. Create only one integration at a time and wait for the response before starting another. Args: ctx: MCP context (injected by FastMCP). organization_id: Owning organization ID. name: Integration display name. description: Short summary of what the integration does. Optional. 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.

  • Create matching criterion

    Add a matching criterion to a field with an attached data source. Use this to refine or extend how extracted values get mapped to data source records — typical scenarios are adding a second matching path (e.g. exact-match a code AND fuzzy-match a label), cross-field matching (use a "Supplier Code" field's value to look up the Suppliers data source), or tightening matching to ``term`` for codes that must be exact. A default criterion is created automatically when a data source is first attached, so this tool is for adding extra criteria. To change an existing criterion's settings use ``update_matching_criterion``; to remove one use ``delete_matching_criterion``. The field must already have a data source attached. Args: ctx: MCP context (injected by FastMCP). field_id: Field that owns the criterion. Must have a data source attached. source_field_id: Field whose extracted value drives the lookup. Set equal to ``field_id`` for self-matching (the common case), or a different field for cross-field matching. data_source_property: Property in the data source schema to compare against (e.g. ``label``, ``value``, ``code``). match_type: ``match`` (fuzzy, default — tolerates typos), ``match_phrase`` (partial phrase), or ``term`` (exact only — best for codes). required: If ``True``, an extracted value with no match here is rejected rather than returned unmatched. required_strict: Stricter variant of ``required``; enable only on explicit user request. field_attribute: Source-field attribute to read from. Only needed when ``source_field_id`` points to a JSON or ENUM-type field.

  • Create recruit workspace

    Create a fully-configured Recruitment workspace in one call. Use this whenever the user is doing recruitment, hiring, candidate search, resume parsing, CV summarisation, or job-description analysis. It creates a "Recruitment" workspace pre-loaded with four document types from Affinda templates — Resume, Job Description, Redacted Resume, Resume Summary — with the right OCR / splitting / classification / model-memory settings for that domain. After this call the user can immediately upload documents. This is idempotent at the workspace level: if a "Recruitment" workspace already exists in the organization it is updated in place rather than duplicated, so it's safe to call again. For any non-recruitment workspace use ``create_workspace`` and pick settings explicitly. Use this only when the user's intent is clearly resume / hiring related; using it elsewhere creates an oddly-named workspace with templates that don't match the use case. Args: ctx: MCP context (injected by FastMCP). organization_id: Owning organization ID.

  • Create tag

    Create a new tag in a workspace. Use this when the user wants a new label to organise documents — e.g. "create an Urgent tag", "add a tag for Q3 invoices". The tag starts with no documents attached; apply it with ``add_tag_to_documents``. Tag names must be unique within a workspace. Check ``list_tags`` first if you're unsure whether the tag already exists. Args: ctx: MCP context (injected by FastMCP). name: Tag name (e.g. ``Urgent``, ``Q3 Invoices``). Max 256 chars. workspace_id: Workspace the tag belongs to.

  • Create validation rule

    Create a validation rule for a document type. Use this to add a new business-logic check (cross-field, format, range, required, etc.) once you have confirmed via ``list_validation_rules`` that no existing rule already covers the requirement. The system auto-generates the validation code from the prompt after creation. Split distinct logical checks (e.g. "required" + "must be a certain length") into separate rules. When updating an existing rule, use ``update_validation_rule`` and merge the new requirement into the existing prompt. Validation-rule prompts should reference fields by numeric ID using the ``@<field_id>`` syntax (call ``list_fields`` first to get IDs). **For data inside a table or group, always reference the CHILD (cell) field IDs, NOT the parent field ID.** A field is a parent when its ``field_type`` is ``table``, ``table_deprecated``, or ``group`` and its ``children`` list is non-empty; the parent is just the row container and holds no values of its own. A rule written against the parent ID validates the container, not the data, and almost always misbehaves. For a ``lineItems`` table (id=4820) with children ``quantity`` (4822), ``unitPrice`` (4823), ``amount`` (4824): - ✅ ``prompt="@4822 must be > 0"`` and ``field_ids=["4822"]`` - ✅ ``prompt="@4823 * @4822 must equal @4824"`` - ❌ ``prompt="@4820 must not be empty"`` (validates the container) - ❌ ``field_ids=["4820"]`` (the table, not its cells) The same applies to ``group`` parents — reference the children. If the user describes a check at row level ("each line item must have…"), translate it to references on the child cells, not the parent. Say in the prompt what to do when a field is missing, e.g. ``"@4821 is required"`` or ``"@4821 must be present unless @4825 contains 'ACME'"``. The generated code applies exactly that. If the prompt does not say, a check whose fields are missing is skipped. Args: ctx: MCP context (injected by FastMCP). document_type_id: Parent document type ID. prompt: Natural-language rule using ``@<field_id>`` references, e.g. ``"@4821 must be present and @4825 must be > 0"``. field_ids: Fields the rule validates. Pass as a native list, not a JSON string. Optional — fields can also be referenced inline in the prompt. enabled: Default ``True``.

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

Page 1 / 5Next