Skip to content
CLI tool · Databases

DuckDB for AI agents

The DuckDB CLI for AI agents: query CSV and Parquet files with SQL, describe and summarize data, and convert formats, all locally without a server.

duckdbby DuckDB FoundationOfficial MCP option
What it is

What DuckDB does for an agent

DuckDB is an in-process analytical database, and its CLI is a single binary that runs SQL directly over CSV, Parquet, and JSON files. There is no server to start and no data to load first.

That makes it a strong agent tool for data questions: DESCRIBE and SUMMARIZE give a quick profile of a file, and COPY converts between formats.

Official site: duckdb.org

Install

Install DuckDB

The install commands from the official docs. Check it worked with duckdb --version.

Homebrew
brew install duckdb
Windows (WinGet)
winget install DuckDB.cli
Auth

Signing in DuckDB for an agent

No sign-in for local files. Remote storage such as S3 is configured inside DuckDB with CREATE SECRET, which should use credentials from the environment rather than typed-in keys.

Common agent tasks

What agents use DuckDB for

Example commands with placeholder names. Swap in your own project, app, or file names.

  1. Preview a CSV file

    duckdb
    duckdb -c "SELECT * FROM 'data.csv' LIMIT 10"
  2. Show the columns and types of a Parquet file

    duckdb
    duckdb -c "DESCRIBE SELECT * FROM 'events.parquet'"
  3. Profile every column

    duckdb
    duckdb -c "SUMMARIZE SELECT * FROM 'data.csv'"
  4. Get results as JSON

    duckdb
    duckdb -json -c "SELECT country, count(*) AS n FROM 'users.csv' GROUP BY country ORDER BY n DESC"
  5. Convert CSV to Parquet

    duckdb
    duckdb -c "COPY (SELECT * FROM 'data.csv') TO 'data.parquet' (FORMAT parquet)"
Safety

Safety rules for agents

Safe to run without asking

  • SELECT, DESCRIBE, SUMMARIZE over files
  • duckdb -readonly analytics.duckdb

Ask a human first

  • COPY ... TO an existing file (overwrites it)
  • CREATE, INSERT, DELETE in a shared .duckdb file
  • reading remote URLs or buckets the user did not name
  • Write converted output to new file names; COPY TO replaces existing files.
  • Open shared database files with -readonly unless a change was requested.
  • Keep cloud credentials in secrets loaded from the environment, never typed into SQL in a log.
Agent instructions

AGENTS.md or CLAUDE.md snippet

Paste this into the instruction file your agent reads at the start of every session, then adjust the rules to your setup.

AGENTS.md
## DuckDB (duckdb)

Use `duckdb` for analyzing CSV, Parquet, and JSON files with SQL.

- Check it is installed with `duckdb --version`. If it is missing, ask before installing it.
- Auth: none needed.
- Run without asking (read-only): `SELECT, DESCRIBE, SUMMARIZE over files`, `duckdb -readonly analytics.duckdb`.
- Ask a human first (changes or deletes things): `COPY ... TO an existing file (overwrites it)`, `CREATE, INSERT, DELETE in a shared .duckdb file`, `reading remote URLs or buckets the user did not name`.
- Write converted output to new file names; COPY TO replaces existing files.
- Open shared database files with -readonly unless a change was requested.
- Keep cloud credentials in secrets loaded from the environment, never typed into SQL in a log.
- Prefer JSON output where the command supports it, and keep output short.
CLI or MCP server?

DuckDB or an MCP server?

An official MCP option exists. MotherDuck publishes an official MCP server for DuckDB and MotherDuck databases. In a terminal agent, the duckdb CLI does the same job on local files with no extra setup.

Rule of thumb: in a terminal agent that a human has signed in, the CLI is usually faster and cheaper in context. In a chat client without a shell, or when you want a fixed set of typed tools, use an MCP server.

Same category
All Databases tools
FAQ

DuckDB questions

How do I install DuckDB?

Homebrew: brew install duckdb. Other official options: Windows (WinGet). Check the install with duckdb --version, and see the DuckDB Foundation docs for other platforms.

How does an AI agent authenticate DuckDB?

No sign-in for local files. Remote storage such as S3 is configured inside DuckDB with CREATE SECRET, which should use credentials from the environment rather than typed-in keys. There is nothing to set up: an agent can use it as soon as duckdb --version succeeds.

Which DuckDB commands are safe for an agent to run?

Commands that only read state are safe to run without asking: SELECT, DESCRIBE, SUMMARIZE over files; duckdb -readonly analytics.duckdb. Ask a human before anything that changes or deletes something: COPY ... TO an existing file (overwrites it); CREATE, INSERT, DELETE in a shared .duckdb file; reading remote URLs or buckets the user did not name.

Is there an MCP server for DuckDB?

MotherDuck publishes an official MCP server for DuckDB and MotherDuck databases. In a terminal agent, the duckdb CLI does the same job on local files with no extra setup.