
csvql
io.github.melihbirim由 GitHub 帳號 melihbirim 發布v3.0.2更新於 Nov 4, 2026
Read-only SQL on CSV files for AI agents. No writes, no network; --root confines file access.
概覽
對本機 CSV、TSV 與 XLSX 檔案執行唯讀 SQL,讓助理就地查詢資料,不必匯入或上傳檔案。
- 可以做什麼
- 對 CSV、TSV 與 XLSX(第一個工作表)檔案執行唯讀 SQL,支援合併、彙總、篩選與日期函式
- 查詢前檢視檔案的欄位名稱與少量範例資料列
- 列出某個目錄中可用的 CSV 檔案
- 以 JSON 回傳結果,每次呼叫約限制在 100 列 / 12 KB,避免大表佔滿上下文
- 適用情境
- 當助理需要回答關於本機或伺服器上 CSV、試算表檔案的問題時適用,希望就地查詢,而不是上傳檔案或開放一般資料庫連線。
- 執行需求
- 需要在本機安裝執行檔(Homebrew、預先編譯版本或 Claude Desktop 的一鍵 MCP 套件);不需要帳號、API 金鑰或網路。啟動時必須指定資料夾,可透過安裝指令或 --root 參數設定,因為它拒絕在檔案系統根目錄啟動。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 csvql,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。
其他 MCP 客戶端
參照 儲存庫 中的啟動說明。
README
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 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.
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,DELETEorDROP. Nothing writes to an input file. - No network. No
std.net,std.httpor socket call in the codebase. No telemetry, no update check.strace -f -e trace=networkshows an empty trace. - Sandboxed by default for agents.
csvql --mcponly opens files under its working directory and refuses to start in the filesystem root;--root /datapicks the folders instead, and--root /allows everything./etc/passwdand../traversal fail withPathOutsideAllowedRoot. - Private columns stay private.
--deny-columns email,ssnrefuses any query that reads those columns, in SELECT, WHERE, ORDER BY or a subquery, andSELECT *leaves them out. The agent can still runAVG(salary) GROUP BY dept. - 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 withOFFSETcan still read a whole table; keep data it must never see out with--deny-columns. - 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. 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, noRIGHT/FULL/CROSS JOIN(inner and left hash joins only). The only subquery shape iscol IN (SELECT ...). These error rather than return wrong data. If you need full SQL, use DuckDB. - Scalar functions in
WHEREare limited toDATEDIFF,DATEADDandEXTRACT. Others (UPPER,ROUND, ...) areSELECT-only and currently fail inWHEREwith a misleadingColumnNotFound. - Excel files are read, not streamed.
FROM 'sales.xlsx'queries the first sheet (dates come out asYYYY-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,.xlsand.xlsbare not supported. - Quoted CSV is about 3x slower than unquoted. Quotes disable the 16-byte skip the scanner relies on.
MEDIANbuffers every value in a group, so on 20M rows it is 5x slower than DuckDB (#205). High-cardinalityGROUP BY(millions of groups) is also slower.- CSV only. JSON and JSONL are output formats, not input formats.
Full list with tracking issues: SQL_REFERENCE.md#known-limitations.
Quick Start
Flags: -d/--delimiter, --json, --jsonl, --markdown, --no-header, --no-input-header (headerless files get c1..cN), -o/--output, --threads, --strict, --schema, --root, --deny-columns, --audit, --mcp. Details in csvql --help. Simple mode: SIMPLE_QUERY_LANGUAGE.md.
For agents (MCP)
Setup
It runs claude mcp add if the Claude Code CLI is present and merges an mcpServers.csvql entry into the Claude Desktop config, preserving your other servers. Claude Desktop starts MCP servers in /, so the Desktop entry gets --root set to the folder you ran install from (or --root <folder>). Without a --root, csvql --mcp refuses to start in the filesystem root. Restart Claude afterward.
Without MCP, a Claude Code skill teaches the agent to use the csvql CLI whenever a CSV comes up: claude plugin marketplace add melihbirim/csvql then claude plugin install csvql@csvql.
Alternatives: a one-click csvql-<platform>.mcpb bundle for Claude Desktop on the Releases page (Settings → Extensions), which asks for the data folder on install, or a manual entry:
VS Code (Copilot) takes the same command/args under servers in .vscode/mcp.json with "type": "stdio".
Tools
The agent writes ordinary SQL against single-quoted paths:
Remote and on-prem
Run csvql on the server next to the data and connect over SSH. Only the SQL and the small result cross the wire. No open port, no reverse proxy, no new credentials:
Without --root, --mcp is confined to the directory it was started in. Set --root explicitly when an agent or another user can reach csvql, since that directory depends on how the client launches the server. Pair it with an unprivileged OS user and a read-only mount. Checklist: SECURITY.md#hardening-for-on-prem-and-remote-access.
What an agent can do, out of the box
Default settings, no hardening flags. DuckDB is the CLI an agent with a shell would call; it can be locked down with SET enable_external_access = false and read-only mode, but only if someone remembers to.
Check the DuckDB column yourself: duckdb -c "COPY (SELECT 1) TO 'x.csv'" and duckdb -c "SELECT current_setting('enable_external_access')".
Token cost
Five questions about a taxi dataset cost about 640 tokens over MCP, tool schema included, and the cost does not change with file size. Pasting the 417 MB file would cost about 230 million tokens, which is a feasibility argument, not a savings figure. An agent that already has a shell and runs duckdb -csv uses slightly fewer tokens than csvql over MCP, because MCP returns JSON. The case for csvql with agents is --root, read-only execution, the output cap and memory, not token count. Measure it: bench/bench_tokens.py.
Installation
Homebrew (macOS / Linux):
Prebuilt binaries from GitHub Releases:
Windows (x86_64): download csvql-windows-x86_64.zip from the same page and put csvql-windows-x86_64.exe on your PATH.
Libraries, same engine, no subprocess:
From source, Zig 0.15.2:
Shell completions for bash and zsh live in completions/. They complete the flags in csvql --help, the install subcommand and file paths.
Performance
Same GROUP BY department on raw CSV, one process per engine, Apple M2 Pro with 16 GB. Peak memory and wall time:
Memory is flat because an aggregate holds an accumulator, not a dataset. That holds for aggregates, not for ORDER BY, which has to keep rows. Speed is in the same band as the other two: csvql is 2 to 5x ahead on scans, filters and small files, far ahead on joins against raw CSV, level with polars on COUNT(*) and top-N, and behind DuckDB on MEDIAN and on GROUP BY with millions of groups. None of that matters on an agent's timescale. The memory does, because it decides what box csvql can run on.
Every number has a reproduce script. Full tables, including quoted CSV, wide files, joins, subqueries and the losses: BENCHMARKS.md.
SQL
Files: .csv, .tsv (with -d '\t') and .xlsx (first sheet). SELECT / FROM / WHERE / GROUP BY / HAVING / ORDER BY / LIMIT / OFFSET, JOIN and LEFT JOIN (chained), col IN (SELECT ...), LIKE / ILIKE / BETWEEN / IS NULL / AND / OR / NOT, DISTINCT, CASE WHEN, arithmetic (+ - * / in SELECT, WHERE, inside aggregates and over their results: SUM(price * qty), WHERE price * qty > 100, SUM(a) / COUNT(*)), column names with spaces as "First Name", `First Name` or [First Name]. Aggregates: COUNT, SUM, AVG, MIN, MAX, VARIANCE, STDDEV, MEDIAN, QUANTILE, MODE, GROUP_CONCAT, COUNT(DISTINCT). Scalars in SELECT: string (UPPER, LOWER, TRIM, LENGTH, REVERSE, CONCAT, LTRIM, RTRIM, LEFT, RIGHT, REPEAT, POSITION, INSTR, SUBSTR, REPLACE, SPLIT_PART, LPAD, RPAD), math (ABS, SIGN, CEIL, FLOOR, MOD, ROUND, TRUNC, SQRT, POWER, LN, LOG, EXP, GREATEST, LEAST), CAST, COALESCE, NULLIF, IFNULL, dates (STRFTIME, DATE_PART, EXTRACT, DATEDIFF, DATEADD, CURRENT_DATE, NOW(), CURRENT_TIMESTAMP).
Full syntax and limitations: SQL_REFERENCE.md. What is differentially tested against DuckDB: CORRECTNESS.md.
Documentation
Planned
- HTTP/SSE MCP transport, so one csvql can serve a team as a shared service (#60).
MEDIANin O(groups) memory (#205).
Shipped features are in the release notes. Good first issues are scoped with file pointers and done-when criteria.
License
MIT, see LICENSE.md.
來源:README.md,提交 7363889
工具
0版本歷史
5- v3.0.2最新Nov 4, 2026
- v3.0.1Nov 3, 2026
- v2.10.0Oct 30, 2026
- v2.9.0Oct 7, 2026
- v2.7.0Sep 16, 2026
評分
已滿足適用檢查項的 50%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
- 近 30 天內可連通25 分
請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。
- 已宣告認證方式10 分
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
- 已列出工具15 分
請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。
- 描述必需15 分
- 圖示10 分
- 文件15 分
- 授權條款10 分
