
SQLX
io.github.OtterMind由 GitHub 账号 OtterMind 发布v0.1.22更新于 Nov 7, 2026
Run SQL on 30+ databases through saved, encrypted connections; credentials stay local.
概览
SQLX 让助手通过本地加密保存的连接,对 30 多种数据库执行 SQL 和数据库命令。
- 可以做什么
- 对 30 多种引擎执行 SQL 语句或 Redis、MongoDB 命令,包括 MySQL、PostgreSQL、Oracle、SQL Server、ClickHouse、Redis、MongoDB 以及本地 SQLite、DuckDB、H2 文件
- 创建、列出、查看、修改、测试、导入和删除已保存的数据源
- 批量执行多条语句并返回结构化 JSON 结果,大结果集写入本地文件并可分页读取
- 根据查询结果创建图表和仪表板,并重新运行已保存图表的 SQL
- 打开本地页面查看结果,或让用户在对话之外输入密码
- 适用场景
- 适合助手需要直接查询或检查数据库、跨引擎比对数据,或基于 SQL 结果快速生成图表和报告而无需另装客户端的场景。
- 运行要求
- 以本地进程运行;CLI 可通过 npx(仅安装器需要 Node.js 22 以上)、平台安装脚本或预编译包安装。数据库 worker 和私有 JRE 在首次使用时下载,需要网络访问。每个连接需要主机、端口、数据库和凭据,可通过具名环境变量、隐藏式交互提示或标准输入的连接 JSON 提供。数据默认存放在 ~/.sqlx。
安装
在 SourceWeft 中
- 打开 控制台中的 SQLX,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。
其他 MCP 客户端
参照 仓库 中的启动说明。
README
SQLX
Connect to MySQL, MariaDB, TiDB, GreatSQL, OceanBase, PostgreSQL, CockroachDB, YugabyteDB, openGauss, Oracle, SQL Server, ClickHouse, Trino, Presto, StarRocks, Apache Doris, TDengine, Dameng, KingbaseES, Apache Kylin, XuguDB, IBM Db2, IBM Informix, SUNDB, GBase 8s, Redis and MongoDB, or open a local SQLite, DuckDB or H2 file, from your terminal or from your agent. Connections are saved encrypted, one invocation runs one or more statements or commands, and the results come back complete and structured.
Quick start
Using an agent? See Use with your agent: install one plugin or extension and the agent calls SQLX directly.
Install the CLI
Three channels, pick one: prebuilt packages from GitHub Releases, the npx installer, or the platform install scripts.
macOS and Linux
The installer selects your platform, downloads the executable and verifies its SHA-256. It installs to ~/.local/bin; add that directory to your shell's persistent PATH. SQLX_INSTALL_DIR chooses another directory and SQLX_VERSION selects a release version.
Windows x64
Run in PowerShell:
Add %LOCALAPPDATA%\Programs\SQLX to your user PATH for future sessions. Neither installer overwrites an unrelated executable already named sqlx; use a different install directory in that case.
Prebuilt targets are macOS ARM64/x64, Linux ARM64/x64 and Windows x64; the Linux baseline is Ubuntu 24.04. Release users do not need Rust, Java or database drivers: database workers and a private JRE are downloaded only when needed.
Node.js (npx)
macOS, Linux and Windows x64 with Node.js 22 or newer:
The installer verifies the release manifest, SHA256SUMS and the downloaded archive before installing. It uses the same user-level location as the platform installers and installs the Skill into ./sqlx, which no agent watches: --target codex, --target claude, --target dsh, --target pi or --target <directory> place the Skill where it is actually discovered, and --cli-only installs the CLI alone. Any other first argument is run as a SQLX command instead of installing, so npx -y @ottermind/sqlx@latest mcp starts the MCP server. Node.js is needed only by the installer, never by the CLI.
Updates
The CLI updates its own executable:
sqlx update install --version <version> installs an exact stable version. Updates do not stop running SQL or the UI service, do not modify saved connections, and do not update Skills or plugins automatically; use sqlx skill update for managed Skills, and an installed UI plugin keeps the version you selected (the default interface moves with the CLI release).
Interactive use checks in the background at most once per day and only prints a notice on stderr. Piped and CI commands skip that check, and SQLX_NO_UPDATE_CHECK=1 disables it. Source builds and package-manager-owned paths keep their own installation method.
Use with your agent
All four are ready as soon as they are installed: the plugin or extension installs the sqlx CLI
itself when it is missing, so you never install it separately. Codex and Claude additionally
require the CLI to meet the plugin's minimum version and refuse to start an older incompatible MCP
server silently.
Each of them also leaves the Skill installed, because the CLI alone gives an agent the tools but none of the engine knowledge. A plugin installs the Skill into that agent's own directory on first launch when it is not there yet, and says so on stderr while it does.
Codex
The plugin starts sqlx mcp over MCP. Read-only operations run directly; the two execution tools (sqlx_sql_execute and sqlx_sql_view) are marked destructive and Codex asks for approval by default.
Claude Code
Headless runs need an explicit tool allowlist:
DeepSeek Harness
Plugins belong to a profile: install it into the profile you use, then restart dsh.
Pi
Any other MCP client
A client with no plugin system takes the server straight from the published package. It installs
the sqlx CLI itself on first use, so this is the whole setup:
Point command at an installed binary instead to start without npx; a GUI application often has
no ~/.local/bin on its PATH, so give the absolute path (~/.local/bin/sqlx on macOS and Linux,
%LOCALAPPDATA%\Programs\SQLX\sqlx.exe on Windows) and keep "args": ["mcp"].
Such a client receives no Skill, so its agent runs the tools without the engine recipes. Install it
where the client reads instructions from with sqlx skill install --path <directory>.
SQLX is also listed in the MCP Registry as
io.github.OtterMind/sqlx, which points at a container image for clients that install from there:
docker run -i --rm ghcr.io/ottermind/sqlx:latest. A container reaches only the SQL-execution path
— the credential page, the result page and the local workbench are served on the container's own
127.0.0.1, and the data directory lives inside it, so mount a volume at /root/.sqlx to keep
saved connections. Prefer the package above when the user should type credentials or read results.
Skill only
For another agent, pass its skill directory with sqlx skill install --path <directory>.
Connections and SQL
Create a connection
--id and --datasource accept a stable datasource UUID or its unique name.
To let the user type the password in a local page, so it never enters the conversation or a tool response:
To edit an existing connection and keep its saved password unless you replace it: sqlx datasource update --id dev --ui.
Connections do not use TLS unless you ask for it: --tls defaults to disable. Add --tls verify-full to verify the database certificate; a database that serves no certificate your machine trusts then fails with invalid peer certificate: UnknownIssuer (MySQL), error performing TLS handshake (PostgreSQL) or a closed connection (Oracle), which is the usual case for a local container. Either choice is also available as an update:
Credentials
Credentials come from named environment variables, hidden interactive prompts, or a connection JSON object on stdin. Never put a literal password in a command argument.
Datasource responses omit usernames, passwords and vendor properties.
Importing connections
A tool that already stores connections can hand all of them over in one versioned document, so a migration never needs a password in a command argument. examples/import-connections.json is a runnable starting point:
Each connection is the same object --connection-stdin accepts. merge (the default) adds new names and updates existing ones in place while keeping their IDs, and it never deletes a stored connection. Every entry is validated on its own, so an unsupported engine or an incomplete connection is reported in skipped with its reason instead of failing the document:
--dry-run validates and reports without storing anything, --strict refuses the whole document when any entry is invalid, and --file <path> reads the document from a file for callers that cannot pipe stdin. The store is written once, so an import is never half applied.
total counts every connection the import considered: the connections already stored plus the document's entries, including the ones it skipped. With one stored connection and two entries, one of them invalid, the response reports total: 3, added: 1 and one skipped entry.
Commands
Execution behavior
Each invocation owns one database connection. Repeated --command arguments execute in order, initially with autocommit, and stop at the first error; there is no implicit all-or-nothing transaction. Temporary tables and session variables do not survive another invocation. Do not submit client directives such as GO, DELIMITER or psql backslash commands.
--command is the current flag and --sql is still accepted as an alias.
Output is one JSON object with one item per executed statement: results[].stmt identifies the statement, cols lists the columns as [name, type] pairs (base64, boolean and json join as a third entry when values are not plain text), rows holds positional values and count holds the driver's row count. Duplicate labels remain distinct. Numbers are encoded as strings to preserve integer and decimal precision, and binary data uses Base64. A failed statement carries its own error with an outcome; statements that never ran are listed in skipped; the object ends with success, which is also the process exit status.
Only a preview travels through standard output. A result set with more rows than preview-rows (10 by default) or more than 16 KiB of values is written completely to results/<id>/<statement>-<result>.jsonl inside the result directory, and its item carries a file path plus the object's id. Read more rows from that file, or page them with sqlx results rows --id <id> --offset 100. The default result directory is a private directory inside the system temporary directory, so results disappear when the machine reboots; sqlx setting set results-dir ~/sqlx-results keeps them, and sqlx setting set results-retention-hours 0 stops the 24-hour cleanup.
A caller that cannot read files needs the whole result in one answer: --full prints every row and stores nothing, sqlx setting set result-mode full makes that the default for this machine, and the MCP tool sqlx_sql_execute takes "full": true for one call. A large result then fills the caller's own output budget, which is why the preview is the default.
--events prints the raw worker event stream instead (protocol_version, datasource_id, events, success) for scripts that parse it, and never stores anything. --preview <rows> overrides the preview size for one call.
Check the final success flag and the exit status, and never replay an uncertain write automatically.
Local pages
Let the user inspect results in a browser and enter the password there.
SQLX executes once and returns a local URL. The page loads the results automatically, supports multiple result sets and pagination, and preserves exact values. Reloading, paging or reopening the page reads the cached result; Refresh on the page reruns the original SQL batch against the database, so any writes in that batch run again. A successful refresh replaces the displayed snapshot at the same URL; a failure keeps the previous result and does not roll back database changes. Results are retained locally for 24 hours.
sqlx ui opens the local workbench, sqlx ui status and sqlx ui stop inspect or stop the service, and --no-open returns a link without launching a browser. The workbench also renders the charts and dashboards created with sqlx analytics (see Local analytics); that command needs no running service. Pages are reachable only on the machine running SQLX, load an HttpOnly browser session automatically, and the service stays up until sqlx ui stop.
Typing the password into the page keeps credentials out of the conversation, but it does not isolate them from an agent that can read files or control the browser as the same operating-system user. See the local UI design for the interface and storage boundaries.
Choose your UI
Installing does not activate a plugin; after selecting it, reload an open page or run sqlx ui. CLI updates keep the version of a plugin you installed and move the default interface to the version of the release, and switching versions needs sqlx ui stop first. Plugins run locally and can access entered credentials and displayed data, so install interfaces from authors you trust: a checksum proves the downloaded bytes are intact, not that the author is trustworthy.
To build your own interface, see the UI plugin guide, the typed browser SDK and the independent terminal UI example. Users need no Node.js runtime.
Data and downloads
User data lives in ~/.sqlx/; use --data-dir or SQLX_DATA_DIR for another location. Settings are stored in ~/.sqlx/settings.json and managed with sqlx setting list|get|set|unset; SQLX_PREVIEW_ROWS, SQLX_RESULTS_DIR, SQLX_RESULTS_RETENTION_HOURS and SQLX_RESULT_MODE override the file for one environment, and a command line flag overrides both. Stored results live in the result directory described above, keep 24 hours by default and stay under 1 GiB in total; older results are removed before the next command runs, and page results from --view are managed by the local service. Saved connections use AES-256-GCM with an independently generated local key: back up the key together with the encrypted data, because losing the key prevents decryption. Device identity is generated locally and this version uploads no device information.
The main executable contains no database drivers; each database's worker is downloaded on first use. MySQL, MariaDB, TiDB, GreatSQL, OceanBase, StarRocks and Apache Doris share the MySQL worker, Redis, MongoDB, SQLite and DuckDB run in their own native workers, PostgreSQL, CockroachDB and YugabyteDB share the PostgreSQL worker, and Oracle, SQL Server, ClickHouse, Trino, Presto, TDengine, openGauss, Dameng, KingbaseES, H2, Hive, Apache Kylin, XuguDB, IBM Db2, IBM Informix, SUNDB and GBase 8s use the JDBC worker (the database table lists which worker serves which database). Downloaded resources come from the fixed release manifest of the running CLI version and are verified before use; --manifest <https-url> selects another manifest or a local test server.
Downloads happen on first use and are cached afterwards. Each one prints Downloading … with speed and estimated time, and a final Downloaded … in 12.3s (390 KB/s) line on stderr; the progress line is refreshed only when stderr is a terminal, so piped JSON stays clean. An interrupted transfer is retried up to three times, and rerunning a failed command reuses every component that is already installed. To avoid waiting inside the first query or page:
The database references explain each SQL operation's purpose, parameters, result and official documentation link.
Troubleshooting
Build from source
Source development requires Git, Rust 1.95, Node.js 22 and the platform's native build tools; Node.js only builds UI plugin assets. For Oracle or SQL Server development, also install a Java 17 JDK and Maven.
On macOS or Linux:
On Windows PowerShell:
Keep the checkout at that location, or copy the CLI and both native workers into a dedicated directory and update PATH and SQLX_WORKER_DIR accordingly. This source build makes MySQL and PostgreSQL usable without a published worker manifest.
For Oracle and SQL Server, build the JDBC worker and place its driver JARs alongside those workers. On macOS or Linux:
On Windows PowerShell:
Java 17 must be on PATH, or SQLX_JAVA_BIN can point to its executable. These manual dependencies are only needed for source development; a binary release downloads its private Java runtime and drivers automatically.
Development and validation
For local native workers, set SQLX_WORKER_DIR to the absolute target/debug directory. For JDBC development, that directory also contains sqlx-jdbc.jar and ojdbc.jar or mssql-jdbc.jar; SQLX_JAVA_BIN can select Java 17 explicitly. These overrides are for development, not prerequisites for release users. The fixture scripts use dedicated test containers and test-only credentials.
Drivers you provide
Most JDBC drivers ship with the release and are downloaded on first use. Vendors that do not allow their driver to be redistributed are not packaged: IBM Db2, IBM Informix, SUNDB and GBase 8s connect with a driver you install once from the vendor.
sqlx driver add copies the jar into <data-dir>/drivers/<engine>/, checks that it really carries the
engine's driver class, and every later command loads it from there. A jar you provide also wins over a
released component, which is how a newer vendor driver is used before the release catches up. Running a
statement for one of these engines without a driver explains the exact command to run:
scripts/release-driver-check.sh <engine> <jar> <data-dir> <connection-json> <statement> runs the same
path a release user takes — install the jar, then execute with no development overrides, so the CLI
resolves the JRE and the JDBC runner from the published manifest. It needs a release whose JDBC runner
already knows the engine, so run it against a published version rather than from a feature branch.
Where the drivers come from:
Releases and documentation
- Packages and checksums: GitHub Releases
- Release notes: docs/release-notes.md
- Design and implementation boundaries: docs/design.md
- Update behavior and recovery: docs/updates.md
- Local interface and plugins: docs/local-ui.md, docs/ui-plugins.md
- Agent integrations: integrations/README.md, Skill
Not included: SQL-file input, persistent sessions, configurable transaction and error modes, result-file export, unattended update installation, and telemetry.
License
This public source repository retains the modified Chat2DB license for adapted code. It is not the unmodified Apache 2.0 license. See LICENSE and NOTICE; third-party dependencies retain their own licenses.
来源:README.md,提交 dce98e1
工具
0版本历史
3- v0.1.22最新Nov 7, 2026
- v0.1.21Oct 15, 2026
- v0.1.20Oct 13, 2026
评分
已满足适用检查项的 40%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分
请在仓库或注册中心条目中声明许可证。