DuckDB as the Query Engine for Agent Data Workloads
DuckDB and MCP let AI agents query governed analytics without touching production databases.

For AI agents on Supabase, the safe analytical access pattern is governed Parquet datasets queried through DuckDB and exposed through MCP. DuckDB’s embedded execution and native file support make it well matched to this pattern. Dreambase implements it through pre-modeled datasets and a single MCP server, but trustworthy answers depend on upstream metric definitions and access controls.
Why AI agents create a new category of data access problem
AI agents mix relational queries with AI operations in loops, rather than following a fixed batch or transaction path. The NUS/NeurEngine paper formalizes these AI×DB workloads as iterative, concurrent, and shareable. An agent adapts its next request to earlier results, explores several solution paths in parallel, and may retrieve data or compute intermediates that other executions also need. This execution model makes coordination across steps as important as the speed of any individual query.
Production systems still separate these operations through an export-execute-import pattern. Data leaves the database for an external runtime, undergoes processing, and returns, adding latency and redundant movement at each handoff. Separate runtimes also lack shared management of intermediates across concurrent executions. When agents query production databases directly, each request consumes resources and exposes live transactional state. Adding agents therefore multiplies both resource demand and exposure.
What DuckDB actually is architecturally, and why that matters for agents
DuckDB is an in-process OLAP engine. It runs inside the calling process, with no server, no port, and no separate infrastructure to provision. Its execution architecture combines vectorized columnar processing with default multithreading, late materialization, a cost-based query optimizer, and automatic spill-to-disk. These analytical execution mechanisms matter when a request scans, joins, or aggregates large amounts of data.
An agent can create and use its own DuckDB instance without waiting for a person to provision a service. There is no database-server credential to rotate, port to open, or cluster to establish before the first local query. This separates the ability to run SQL from the permission to read particular data, which still requires authorization.
This distinction also changes the deployment unit for short, frequent analytical requests. A server-based engine needs a service up and running even when an agent has only a few queries to run. DuckDB instead makes analytical execution part of the agent’s own runtime. The architectural advantage is that an analytical task can start without a separate infrastructure project.
Native open-format support as the reason agents can skip ETL entirely
Once the engine can start locally, the next constraint is whether it can read the supplied data. DuckDB reads Parquet, JSON, and CSV natively, with Iceberg and Arrow supported through installable extensions. An agent receiving a governed dataset in these formats can query it without first building a transformation pipeline. The distinction is important because upstream modeling still happens. What disappears is the additional ETL step between the refined dataset and the agent’s query.
Parquet is particularly well suited to this arrangement because its compact columnar layout supports analytical scans. DuckDB supplies the SQL layer for joins, aggregations, filters, window functions, and time-series transforms. The integration removes the human engineering step that would otherwise stand between an agent receiving data and answering a question about it.
However, immutable Parquet files do not solve every write requirement. The DuckDB-Iceberg extension supports INSERT, UPDATE, and DELETE for Iceberg v2 tables, although UPDATE and DELETE require non-partitioned, non-sorted tables and use merge-on-read semantics only. This provides a write path distinct from querying a fixed analytical snapshot. DuckDB-Wasm also supports the Iceberg extension in-browser, including reads and writes through Iceberg REST Catalogs without local installation. The format and runtime therefore determine the available interaction, rather than forcing every agent workflow into read-only Parquet access.
How MCP closes the last mile between an LLM and a governed dataset
A queryable dataset still needs an interface that an LLM can use within defined permissions. MCP servers provide that interface by exposing tools as a structured API. An agent calls the tools the server offers instead of building ad hoc paths to get into live systems. In a governed deployment, those tools let agents see only pre-approved metrics, reports, or fields. MCP supplies the wire, while the upstream semantic model determines what the data means.
This division is central to choosing an MCP server for Supabase analytics. A connector alone does not establish that raw records have been cleaned, metrics reconciled, or row-level access controls applied to the served dataset. The server’s exposed datasets and authorization boundary determine which data an agent can receive when it has permission to invoke a tool.
The July 28, 2026 revision of the MCP spec makes the protocol layer stateless and adds header-based routing. It also formally deprecates Dynamic Client Registration in favor of Client ID Metadata Documents, introduced in the 2025-11-25 spec. Stateless operation supports horizontally scaled servers and serverless deployment over Streamable HTTP, with SSE becoming the legacy transport. For analytical workloads, the practical pattern is headless MCP, where scripts, webhooks, or cron coordinate an autonomous client with background tools. Every endpoint should have OAuth or JWT middleware, and each agent context should be sandboxed to limit escalation through confused-deputy or prompt-injection attacks.
How to let AI agents query Supabase data without direct production database access
For teams already using Postgres, analytical access can extend from that foundation without requiring a new warehouse. The pg_duckdb extension runs one DuckDB instance per Postgres backend, in-process. It executes supported queries through DuckDB, either reading Postgres heap tables through a bridge or using DuckDB’s readers for Parquet, CSV, and Iceberg in object storage. This makes the integration useful, but it does not make analytical load harmless to the host database.
The safety constraint is to run pg_duckdb on a dedicated analytics read replica. A heavy analytical query on the production backend competes with transactional work for CPU, memory, and network. Moving that work to a replica separates the analytical execution from the production instance. For Supabase teams, this is one way to give agents analytical context without letting them query the production Postgres instance. A governed Parquet export served through MCP provides another.
Dreambase materializes pre-calculated metrics and modeled datasets as governed Parquet files queryable through DuckDB and exposes them through a single MCP server. Agents get refined analytical data without a connection to production Supabase. Unlike the replica path, this places the modeled dataset itself at the access boundary. The agent can query the data it gets right away, without an export-execute-import loop against live transactional state.
Why pre-calculated, governed datasets are a better unit than on-demand queries for agents
The strongest case for pre-calculated datasets is consistency. An agent querying raw tables gets the data’s current state without any guarantee that its definition of revenue matches the board report. One engineer may write SUM(revenue), and another may write SUM(amount_captured). Both expressions can run successfully yet mean different things to the business.
A semantic layer resolves that ambiguity before the agent asks its question. It defines calculations such as MRR or LTV centrally, so a change reaches dashboards, agents, and reports through the same definition. The metrics layer pattern, sometimes called headless BI, puts those definitions in code once and shares them with the systems that use them. DuckDB with dbt supports this approach through SQL models run against Parquet materializations or pg_duckdb. The dashboard and MCP server can then expose the same modeled view.
Pre-modeling is also the governance rationale behind implementations such as Dreambase, where agents receive refined Parquet tables. The NUS/NeurEngine paper identifies shared management of relational intermediates and AI artifacts as a core design principle for concurrent workloads. Governed datasets apply that reuse principle at a practical boundary, although they do not reproduce a research engine’s full orchestration. Their remaining trade-off is freshness. A governed refresh cadence sets a limit on how stale the data can be and makes that clear, while ad hoc metric definitions can drift apart without anyone seeing the difference.
The emerging per-agent database pattern and what it implies for data infrastructure
A new approach to embedded execution gives each agent its own DuckDB instance. Instead of sending all queries to a central engine, agents exchange immutable, versioned analytical slices. Joe’s Quack architecture, “To Every Agent Its Own Database”, describes this peer model. Each peer has a dedicated embedded instance and communicates directly with other peers through loopback TCP ports. This is an emerging architectural direction.
The important governance mechanism is the identity of the exchanged slice. Quack uses a SliceRef containing catalog_id, dataset, DuckLake snapshot_id, contract_digest of its semantic model, and a slice_digest. The contract_digest makes a change to the semantic model visible in the identifier. As a result, semantic drift becomes structurally detectable rather than depending on an agent noticing that two results mean different things. Immutable slices also provide a unit for chaining results between agents without treating a shared mutable table as the exchange mechanism.
Quack-Cluster combines DuckDB with Ray, using a FastAPI/SQLGlot coordinator to parse queries and generate distributed execution plans. Each Ray Worker embeds DuckDB to process fragments, with Apache Arrow used for partial result aggregation. It reads Parquet and CSV from S3, GCS, or local filesystems. Whether execution is shared, per-agent, or distributed, the implication is the same. Pre-modeled, versioned data is still a stable base to work from even when the query engine moves.
Where DuckDB fits in the real-time analytics spectrum and the concurrency ceiling to plan around
DuckDB’s embedded design supports deep analytical work and is simple to deploy, but it has limits on multi-user concurrency. Queries running in a single instance share its memory and cores. DuckDB also supports a single writer process at a time, while permitting multiple writer threads within that process. These limits distinguish an embedded engine from a scale-out serving layer. Many simultaneous analytical users can contend even when each individual query is efficient.
Agent workloads make that boundary particularly important because parallel exploration is part of their execution model. A shared instance may face many requests from one agent workflow as well as requests from other agents. A dedicated read replica protects production resources, but it does not itself remove contention within DuckDB. At that point, the available paths include a scale-out layer, a second engine reading the same Iceberg tables, or MotherDuck’s per-user compute isolation. The new per-agent pattern is another way to deploy the engine, with governed slices setting the boundary for what agents exchange.
DuckDB suits interactive analytical work, but petabyte-scale event-stream ingestion at millisecond latency is a different requirement. For latency-critical agent context, the relevant criteria are latency and ingestion SLOs, vector and hybrid search maturity, JSON handling, and billing granularity. DuckDB’s analytical and JSON capabilities do not remove the need to evaluate real-time vector retrieval separately.
For Supabase teams, the planning takeaway is to separate data governance from compute placement. Governed Parquet datasets queried through DuckDB provide analytical depth without exposing production tables, while the deployment model determines how concurrent requests receive resources. Pre-modeled datasets also limit what can be queried through the engine. Plan the refresh cadence, permissions, and concurrency boundary together, so DuckDB’s simplicity remains an advantage as agent demand grows.


