Skip to main content
Glama

import_data

Destructive

Imports rows from CSV or JSON files into one Directus collection or multiple related collections at once; supports merge/upsert, dry-run previews, and confirmed deletion.

Instructions

Imports rows from a CSV or JSON file into one collection, or into several related collections at once from a flat multi-collection file. Use it when the data is in a file; bulk_operations takes payloads already in memory and create_item a single row. Subject to the Directus IMPORT_MAX_FILE_SIZE limit (50mb by default).

Single-collection: pass collection, and the file is a plain array of rows. Batch (Directus 12.2+): omit collection, and the file MUST be a JSON array of { "collection": string, "items": object[] } entries, e.g. [{"collection":"authors","items":[{"name":"Ann"}]},{"collection":"articles","items":[{"title":"Hi","author":1}]}]

Writes immediately and is not a transaction, so a failure partway leaves earlier rows imported. mode merge upserts instead of inserting, dry_run reports the changes without writing, and only dangerously_allow_delete together with confirm lets rows absent from the file be deleted.

Tool call template

This tool declares no required parameters. Add optional parameters from the input schema as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {},
    "name": "import_data"
  }
}

Input Schema

NameRequiredDescriptionDefault
modeNoBatch import only. 'add' inserts, 'merge' upserts. Default: add.
confirmNoConfirm a destructive import
dry_runNoBatch import only. Report the changes without writing.
filenameNoFilename for the upload; its extension selects the parser (.csv or .json)
file_dataNoBase64-encoded file contents (alternative to file_path)
file_pathNoPath to a local .csv or .json file
collectionNoTarget collection. Omit for a multi-collection batch import, in which case the file must be an array of { collection, items } entries rather than a bare row array.
dangerously_allow_deleteNoBatch import only. Permit deletion of rows absent from the file. Requires confirm.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv12.3.3

TDQS

A4.8/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Beyond annotations that flag destructiveness, the description discloses important traits: the operation is not transactional and partial failures leave earlier rows imported; merge mode upserts; dry_run reports changes without writing; deletion requires both dangerously_allow_delete and confirm; and the 50mb default file-size limit. These are material behavioral details an agent cannot infer from annotations alone.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is front-loaded with the core action and alternatives, then organizes single-collection versus batch behavior and safety caveats into clear paragraphs. It is somewhat long, but each section adds useful information for a complex, destructive tool; the JSON example is justified by the non-obvious batch format.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For an 8-parameter, destructive import tool with no output schema, the description covers the essential call variants (single vs batch), required file formats, mode semantics, dry-run behavior, deletion safeguards, and non-atomicity. No output schema is present, so the lack of explicit return-value documentation is acceptable; the definition is complete enough to invoke safely.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so parameter documentation already has a solid baseline, but the description adds meaningful interaction details: omitting collection switches to batch mode with a required JSON array shape, mode merge upserts, dry_run reports without writing, and dangerously_allow_delete requires confirm. The example batch payload clarifies the expected file structure beyond what the schema text conveys.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states a specific verb and resource: imports rows from CSV or JSON files into one or several collections. It explicitly distinguishes file-based import from siblings bulk_operations (in-memory payloads) and create_item (single row), so an agent can select the right tool without opening schemas.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

It gives explicit when-to-use guidance: use import_data when data is in a file, bulk_operations for in-memory payloads, and create_item for a single row. It also distinguishes single-collection versus batch modes and states the version and file format requirements for batch imports.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.