
Give an AI agent SQL over your CSV files, not your computer. Out of the box it can't write, can't reach the network, can't leave its folder, and can't pour a whole table into the context.
A database is something you load your data into. csvql is a query you run on the data where it already lives.
csvql (published as csvql-query on npm and PyPI, csvql on Homebrew) runs SELECT on CSV files where they sit: no import, no ingest, no server. It ships as an MCP server, so an agent can ask a question of a gigabyte file and get back a few hundred tokens instead of the file. Safe by construction, not by configuration: the SQL has no write statements and the binary has no network code. It is about as fast as DuckDB and polars on raw CSV and uses 3 to 11x less memory.
$ csvql "SELECT cab_type, COUNT(*) FROM 'trips.csv' GROUP BY cab_type"
cab_type,COUNT(*)
green,32447
yellow,967553
Website · Quick Start · For agents · Install · Performance · SQL · Docs
Why this exists
Agents are getting access to company data. The usual paths are a database connection or uploading files to the model. Both move the data. csvql is the third option: run it next to the data, on your own box, and let the agent query it there. Everything below is checkable in the source.
- Read-only by construction. The parser has no
INSERT, UPDATE, DELETE or DROP. Nothing writes to an input file.
- No network. No
std.net, std.http or socket call in the codebase. No telemetry, no update check. strace -f -e trace=network shows an empty trace.
- Sandboxed by default for agents.
csvql --mcp only opens files under its working directory and refuses to start in the filesystem root; --root /data picks the folders instead, and --root / allows everything. /etc/passwd and ../ traversal fail with PathOutsideAllowedRoot.
- Private columns stay private.
--deny-columns email,ssn refuses any query that reads those columns, in SELECT, WHERE, ORDER BY or a subquery, and SELECT * leaves them out. The agent can still run AVG(salary) GROUP BY dept. Names match as whole words, so list variants such as customer_ssn too.
- Bounded output. MCP results are capped at about 100 rows / 12 KB per call. A careless
SELECT * cannot flood the context. The cap is per call, so an agent that pages with OFFSET can still read a whole table; keep data it must never see out with --deny-columns. A JOIN that produces more than 10 million rows is refused in --mcp mode (--max-join-rows changes it), so one runaway query cannot exhaust memory.
- Flat memory. An aggregate holds a running accumulator, not a dataset: 74 MB on a 0.7 GB file and 74 MB on an 8 GB one. It fits on the small VM beside the data.
- Auditable.
--audit <file> appends one JSONL record per query, including refused ones with the error name. Over SSH you inherit your existing keys, bastion and logs.
Full posture, including two known gaps on macOS and Windows: SECURITY.md.
What it does not do
- It is not a database. No
UNION, no window functions, no RIGHT/FULL/CROSS JOIN (inner and left hash joins only). The only subquery shape is col IN (SELECT ...). These error rather than return wrong data. If you need full SQL, use DuckDB.
- Scalar functions in
WHERE are limited to DATEDIFF, DATEADD and EXTRACT. Others (UPPER, ROUND, ...) are SELECT-only and currently fail in WHERE with a misleading ColumnNotFound.
- Excel files are read, not streamed.
FROM 'sales.xlsx' queries the first sheet (dates come out as YYYY-MM-DD, formulas as their saved value), but the sheet is unpacked in memory first: a 9 MB, 300k row workbook takes about 230 MB and 0.6 s. Other sheets, .xls and .xlsb are not supported.
- Quoted CSV is about 3x slower than unquoted. Quotes disable the 16-byte skip the scanner relies on.
MEDIAN buffers every value in a group, so on 20M rows it is 5x slower than DuckDB (#205). High-cardinality GROUP BY (millions of groups) is also slower.
- Input is CSV, TSV or
.xlsx. No Parquet, no JSON or JSONL input; JSON and JSONL are output formats only.
Full list with tracking issues: SQL_REFERENCE.md#known-limitations.
Quick Start