dbrex
Allows querying ClickHouse databases by running SQL statements from files or the CLI, with connection management and result storage.
Allows querying MySQL databases by running SQL statements from files or the CLI, with connection management and result storage.
Allows querying Trino databases, including SSO-authenticated connections, by running SQL statements from files or the CLI.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@dbrexrun the SQL in sales_report.sql on the prod connection"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
DbRex
Query databases from .sql files in VSCode, and let an AI work the same
connections through MCP.
Deep beta. This is early, pre-release software under active development. Interfaces, the connection file format and the on-disk layout of
~/.dbrexcan all change without a migration path. There is no published release yet — you build it from source. Do not point it at anything you cannot afford to have a query run against.
Connections, credentials and results live in a small local daemon (dbrexd), not
in the editor. The editor is one client; a terminal is another; an AI agent over
MCP is a third. Closing the window closes a display, not the machinery — an
agent keeps working.
Ctrl+Enterruns the statement under the cursor,Ctrl+Shift+Enterthe file.-- @conn: nameand-- @limit: nsteer individual statements.DbRex: Copy MCP Setup Command gives you the one line that connects an agent.
Passwords are never accepted from an agent: the daemon routes the prompt to this window or to a terminal, and only those may answer.
MySQL, ClickHouse, Trino (including SSO) and S3-compatible object stores.
Buckets browse out of the box over plain HTTPS. Querying files needs DuckDB,
which is a 70 MB native component, so it is not bundled — run dbrex install-duckdb once if you want it.
Install
curl -sSL https://raw.githubusercontent.com/gr4c2-2000/dbrex/main/install.sh | shChecks for a Node 18 or newer, builds from source, installs the dbrex command
into ~/.dbrex/bin and links it into ~/.local/bin, then installs the VSCode
extension if it finds an editor. --cli-only skips the extension.
The CLI half needs no editor. That is deliberate: the daemon is meant to outlive the editor, so it has to be installable without one.
From a clone:
./install.shRelated MCP server: MCP Database Query Server
Layout
packages/core shared types, connection specs, SQL statement splitting
packages/daemon dbrexd — sessions, providers, secret vault, result store
packages/client the protocol clients speak to the daemon
packages/cli dbrex — terminal client and the MCP stdio bridge
packages/extension the VSCode extension, which ships the daemon and the CLI
(its `webview/` holds the result panel front-end)Build
npm install
npm run typecheck
npm test
npm run buildPackage the extension:
cd packages/extension
npx @vscode/vsce package --no-dependencies --allow-missing-repository --out dbrex.vsix
code --install-extension dbrex.vsixCLI
dbrex shell [conn] interactive session; Tab completes from the server
dbrex status is the daemon up, is the vault unlocked
dbrex connections list connections and what they are for
dbrex query <conn> <sql> run one statement and print the rows
dbrex query <conn> -f <file.sql> run a file, honouring -- @conn / -- @limit
dbrex browse <conn> [path...] walk the schema tree
dbrex unlock unlock the secret vault for this daemon
dbrex set-password <conn> store a password for a connection
dbrex results [n] recent stored results
dbrex install-duckdb add DuckDB, needed to query object stores
dbrex mcp serve MCP over stdio (for AI agents)
dbrex stop stop the daemonOutput
A terminal gets a table sized to it, with numbers right-aligned and NULL dimmed
so it cannot be mistaken for the string "NULL". A pipe gets TSV and no summary
line, because the next thing in the pipe is a program. --format overrides
either: table, json, csv, tsv or vertical.
dbrex query prod "SELECT ..." --format json | jq '.[0].hits'
dbrex query prod "SELECT ..." --format vertical # one field per lineA table that does not fit shrinks its widest columns and marks what it cut. It never drops a column: a missing column reads as "the query returned no such column", which is not a thing a database tool may imply.
Verifying an installation
npm test proves the code is self-consistent. make verify proves two things
it cannot, in containers that have never seen dbrex:
make verify-installrunsinstall.shon a machine with no build and nothing on PATH, then checks thatdbrexanswers — including after its build directory is deleted, and when it is installed a second time.make verify-runqueries real MySQL, ClickHouse and MinIO.
They are separate because a working build is no evidence that an installation works. Requires Docker; everything they start is thrown away afterwards.
make verifyConfiguration
Connections live in ~/.dbrex/connections.json, or in a workspace's own
.dbrex/connections.json. Passwords do not: they go to the daemon's encrypted
vault, an environment variable, or a command (op read ...), whichever the
connection declares.
License
MIT. See LICENSE.
This server cannot be deployed
Maintenance
Related MCP Connectors
- OleanderOAuthdev.oleander
The all-in-one data stack for agents. Upload files, run SQL, evolve tables, and render charts.
Remote data science agents for Snowflake, Databricks & BigQuery in Claude/Cursor via MCP
- dataOAuthco.thinair
PostgreSQL, MySQL, and SQL Server in one session. 26 read-only MCP tools for AI agents.
Query 40 databases from Claude, ChatGPT, or Cursor — on any device. Read-only, encrypted, audited.
Related MCP Servers
- AlicenseBqualityDmaintenanceEnables AI assistants and IDEs to execute SQL queries on local DuckDB databases, in-memory databases, or cloud-stored databases with support for flexible connections and configurable result limits.11MIT
- FlicenseNot gradedqualityDmaintenanceEnables AI agents to query and explore databases including SQLite, PostgreSQL, MySQL, and SQL Server through a secure, read-only workflow. It provides tools for listing connections, inspecting table schemas, and executing SELECT statements directly within VS Code.1-
- AlicenseNot gradedqualityAmaintenanceQuery local CSV, Parquet, JSON and TSV files with real SQL via DuckDB. Gives your AI coding tool ground-truth data access instead of hallucinated answers.4MIT
- FlicenseNot gradedqualityAmaintenanceConnects AI coding assistants like Claude Code, Cursor, and Windsurf to enterprise data sources (databases, files, APIs, etc.) via a single binary, with 45+ connector categories and built-in memory tools.1-