# DB Desk — full documentation > A native, keyboard-first database browser for macOS, Windows and Linux. Read-only until you say otherwise, credentials encrypted on your machine, one window for every engine you touch. Engines: PostgreSQL, Amazon Redshift, CockroachDB, Greenplum, MySQL, MariaDB, SingleStore, Microsoft SQL Server, ClickHouse, SQLite, DuckDB, Elasticsearch, InfluxDB 3, libSQL, Cloudflare D1, Oracle, Vertica, Cassandra, Amazon Athena, DynamoDB, BigQuery, Snowflake, MongoDB, Redis / Valkey, MCP servers, HTTP SQL gateways. --- # Getting started Source: https://dbdesk.app/docs/getting-started.html # Getting started ![Connection picker](img/connection-picker.png) ## Requirements - **Node.js 26 LTS** (or any 22.12+; the repo ships `.nvmrc`) - **Python 3.11+** - **Rust stable** (1.77+) and Xcode Command Line Tools on macOS - `psql` and/or `mysql` clients for those connection types (SQLite uses the Python standard library) The server binds to `127.0.0.1` only. Credentials are encrypted at rest with AES-GCM in the app-data directory (see *Data* below) and are never returned to the UI. ## Run from source ```bash # dependencies make install # root npm, ui npm, backend pip # build the page and start the server (opens http://127.0.0.1:8765) make server # or run the desktop shell in development (spawns the Python server itself) npm run app ``` `npm run app` needs Rust and the Tauri system dependencies. On macOS that is Xcode Command Line Tools; on Linux see the Tauri prerequisites. ### UI-only development ```bash python backend/app.py # terminal 1 — API on :8765 npm --prefix ui run dev # terminal 2 — Vite on :5173, proxies /api ``` ## Build the macOS app ```bash make sidecar # PyInstaller one-file server -> src-tauri/binaries/ npm --prefix ui run build npm run tauri build # -> src-tauri/target/release/bundle/dmg/*.dmg ``` The sidecar is a PyInstaller **onedir** tree (no unpack on launch). Tauri ships it as a bundle resource, so it lands in `DB Desk.app/Contents/Resources/sidecar/dbdesk-server/`. The Rust shell shows a splash window immediately, starts the sidecar on a free localhost port, waits until it accepts connections, then navigates the same window to it. The child is killed on exit. The splash is `ui/public/splash.html`. The GitHub Actions workflow builds both architectures on every push: - `macos-13` → `x86_64-apple-darwin` (Intel) - `macos-14` → `aarch64-apple-darwin` (Apple Silicon) Unsigned DMGs run after a right-click → **Open**. For distribution, add the usual signing/notarization secrets (`APPLE_CERTIFICATE`, `APPLE_CERTIFICATE_PASSWORD`, `APPLE_SIGNING_IDENTITY`, `APPLE_ID`, `APPLE_PASSWORD`, `APPLE_TEAM_ID`); Tauri picks them up automatically. ## Updates The app checks GitHub Releases for a signed update manifest when it opens. When a newer version exists, the picker shows **Update available — vX**; **Update now** downloads the `.app.tar.gz`, verifies the minisign signature, replaces the bundle and relaunches. - No Apple Developer account is involved: the updater uses its own minisign keypair. The public key is in `src-tauri/tauri.conf.json`; the private key lives only in the `TAURI_SIGNING_PRIVATE_KEY` CI secret. - Releases are published by `.github/workflows/release.yml` when a `v*` tag is pushed; it reuses the successful `main` build and writes `latest.json`. - The first build with the updater (0.7.1) must be installed manually once; later versions update in place. - Manifest URL: `https://github.com/wzul/dbdesk-app/releases/latest/download/latest.json` ## Data | Platform | Location | |---|---| | macOS | `~/Library/Application Support/DB Desk/data` | | Linux | `~/.local/share/dbdesk/data` (`$XDG_DATA_HOME`) | | Windows | `%APPDATA%\DB Desk\data` | Set `DBDESK_HOME` to override. The directory contains: - `connections.json` — connections, passwords AES-GCM encrypted - `vault.key` — the 32-byte key (0600) - `audit.jsonl`, `approvals.json`, `queries.json`, `views.json` --- # Features Source: https://dbdesk.app/docs/features.html # Features ![DB Desk data grid](img/standalone.png) ![SQL query tab](img/sql-tab.png) - **MCP server for local agents** — Settings → **MCP server** exposes DB Desk to Claude Desktop, Cursor, Hermes or any MCP client over stdio or loopback HTTP. Tools cover connections, databases, tables, columns, indexes, DDL, rows, CSV, SQL and the AI agent. Disabled by default; one toggle generates a bearer token. - **Keyboard shortcuts** — **⌘F** filter/search, **⌘R** refresh, **⌘⏎** run, **⌘S** save SQL, **⌘2 / ⌘T** new SQL tab, **⌘1 / 3 / 4** Data/Structure/Site, **⌘+ / ⌘− / ⌘0** zoom, **⌘/** shortcut list, **⌘,** settings. - **Remembers window size and position** across launches (saved to `window.json` in the app data folder); if the monitor is gone, the app falls back to the default size instead of opening off-screen. - **Settings (⌘,)** — one preferences window: **Appearance** (System / Light / Dark), updates, native notification toggle + test, MCP server, AI provider (base URL/model/key), backup & restore, application-data path and version. Open it with **⌘,**, the gear on the picker, or the gear in the app header. - **AI setup assistant** — **AI setup** on the picker: describe the database (“MySQL on my VPS behind a bastion”) and the agent returns a field-by-field draft; **Use this setup** opens the form prefilled. Passwords are never sent: the draft is sanitized server-side and the form leaves the password blank. - **Ask AI (read-only)** — the header **AI** button opens a prompt bar. It sends the current table/column names and your question to an OpenAI-compatible endpoint (OpenAI, OpenRouter, Ollama, LM Studio, ...), receives one SELECT, runs it read-only and shows the SQL and rows. The panel is a **chat**: press Enter, read the result, then type a follow-up (“pecahkan ikut bulan”) and the previous SQL/answers are carried into the next request. If a statement fails (for example a wrong column name), the error and the relevant schema are sent back once so the model can correct the query. Server-side rules refuse any non-read statement. Configure base URL, model and API key under the AI settings; the key is encrypted at rest and row data is never sent. - **Multi-database agent** — the AI scope bar defaults to every AI-enabled connection. When a question spans databases (“who is in app-db but not the warehouse?”) the agent first requests the missing schemas, then returns one read-only statement per database plus a join. DB Desk runs each statement against its own database, loads the result sets into an in-memory SQLite database and executes the join **locally**. Only schema names, SQL, row counts and error text go to the provider — never the rows. Each answer shows the per-source SQL (copy, or open in SQL when it is the current connection), the local join, the merged table and a short step log. - **Per-connection AI switches** — in the connection form, turn off **AI can see this schema** to hide a database from the agent entirely, or turn off **AI can run read-only queries** to keep it inspect-only. Statements run by the agent are written to the audit log. - **Docked AI and record panels** — the AI chat opens on the right without covering the grid; clicking a row number opens a TablePlus-style **Record** panel on the right with each column name, type and value. **Microsoft SQL Server.** T-SQL is not MySQL with different keywords, and the parts that differ are the parts people notice: - identifiers are bracketed (`[dbo].[orders]`) and literals are `N'…'`, so a Unicode value survives the code-page round trip; - paging uses `ORDER BY … OFFSET n ROWS FETCH NEXT m ROWS ONLY`, which requires an ORDER BY even when you did not pick a column, and TOP cannot be combined with it; - column types come from the catalog (`sys.columns`), because the driver only reports five coarse DB-Library categories; `timestamp` is rendered as `rowversion` since it is a binary counter, not a date; - `contains`/`startswith` pin a collation instead of inheriting the database default, so case-insensitivity does not change per server; - the driver is `pymssql`, which ships wheels for every platform including Windows on ARM and bundles FreeTDS — there is no ODBC driver for the user to install. TLS is a connection setting (`off`, `request`, `require`, `default`); Azure SQL needs `require`. - SQL Server has no read-only transaction mode to switch on, so read-only here means the statement guard plus, ideally, a login whose grants cannot write. - **New connection type cards** — the connection form shows a card per engine and sets the default port when you pick one. MariaDB is stored as MySQL with a `mariadb` flavor. MongoDB has SRV and auth-source options; Redis has a database index. Engines that speak a protocol DB Desk already speaks are names, not new drivers: **PostgreSQL** and everything on the PostgreSQL wire — **Amazon Redshift** (5439), **CockroachDB** (26257), **Greenplum**; **MySQL**, **MariaDB** and **SingleStore**; **Microsoft SQL Server** (bundled FreeTDS, no ODBC driver to install); **ClickHouse**; **SQLite** and **DuckDB** by file; **MongoDB**; **Redis / Valkey**. Three more engines have their own protocol and their own module, because a dialect is not the only thing that differs: - **Oracle** through `python-oracledb`'s *thin* driver — no Instant Client, no `ORACLE_HOME`, nothing to install. Schemas are the owners you can see, the system owners are hidden, and a table is `OWNER.TABLE` in double quotes. `TIMESTAMP` columns and `CLOB` values are read as text, and DDL comes from `DBMS_METADATA.GET_DDL`, which is what Oracle itself considers canonical. - **Vertica** through `vertica_python`, also pure Python. Vertica has no `CREATE INDEX`: a projection *is* the physical design, so the indexes panel lists the projections that cover the table rather than pretending otherwise, and DDL comes from `EXPORT_OBJECTS()`. - **Cassandra** speaks CQL. There is no `OFFSET`, so the grid shows the first N rows and says so instead of paging wrongly; `ORDER BY` only works on clustering columns and the server rejects anything else; column types are CQL types (`list`, `map`) shown as they are; and because Cassandra keeps no DDL text, `CREATE TABLE` is reconstructed from `system_schema`, including the composite partition key and any `CLUSTERING ORDER BY … DESC`. Four cloud warehouses are reached over their own HTTPS APIs. None of them can be exercised without an account, so they are implemented against the published API and are **not yet proven against a live account** — treat them as available to try, not as tested. They take one extra field, **Options (JSON)**: - **Amazon Athena** — user is the access key id, password the secret key, `{"region": "ap-southeast-1", "output": "s3://bucket/prefix"}`. Athena is asynchronous: the query is started, polled and read back, and its result set is written to that S3 prefix, which is why the prefix is required. - **DynamoDB** — `{"region": "ap-southeast-1"}` (plus `endpoint` for DynamoDB Local). A table has no fixed columns, so the attribute list shows the keys and the rows are a `Scan`; the Query tab accepts PartiQL. - **BigQuery** — user is the service-account e-mail and password its private key (PEM), `{"project": "my-project", "dataset": "demo"}`. The JWT is signed locally with `cryptography` and exchanged for a token, so no Google SDK is bundled. - **Snowflake** — host is `account.snowflakecomputing.com`, `{"warehouse": "…", "role": "…", "schema": "…"}`. This one uses Snowflake's own connector, imported only when a Snowflake connection is opened. None of the four is signed in with a saved browser session or an OAuth popup: the credential is a key you paste, encrypted with the rest of the vault. Four engines are reached over HTTP instead, with no driver at all: put the base URL in **Host** and the token in **Password**. - **Elasticsearch** — indices appear as tables, the mapping as columns, documents as rows (nested fields flattened to `a.b`, `_id` shown). The Query tab uses the `_sql` endpoint, which some distributions do not ship. - **InfluxDB 3** — database name plus a token; measurements appear as tables and the Query tab runs SQL. The `system` schema is hidden. `time` is treated as the default sort column. - **libSQL / Turso** — `libsql://` (or the https URL) plus a token; a SQLite-shaped database, so tables, `pragma table_info`, DDL and SQL all work as expected. - **Cloudflare D1** — account id in **User**, database id in **Database**, API token in **Password**. Read-only applies to all of them: a write statement is refused before it leaves the process, because a token that can write has no server-side grant to fall back on. - **MongoDB document browser** — collections appear in the tree; the data grid pages documents, the filter panel accepts column filters or a raw Mongo filter object (`{"age": {"$gt": 18}}`), and the Query tab runs JSON commands (`{"collection": "users", "find": {...}, "sort": {...}, "limit": 50}` or `aggregate`). Double-click a cell to edit a field, **+ Row** inserts a document, and row actions delete. Nested objects/arrays show as compact JSON. Reads use the sampled field list; production writes go through the approval drawer. - **Redis / Valkey browser** — the tree lists the logical databases, the grid scans keys (`key`, `type`, `ttl`, `size`) with a `MATCH` pattern filter, and clicking a key opens a value drawer for strings, hashes, lists, sets, sorted sets and streams. The **Console** tab runs any command (`GET`, `HGETALL`, `SCAN`, ...); read-only connections refuse writes, and production writes ask for approval first. - **Connection picker** — the app opens on a TablePlus-style list: search, groups, type icons, read-only/PROD badges; pick a connection, then the full browser opens. Right-click a connection for **Open / Edit / Clone / Test / Export / Delete**; Clone duplicates the encrypted credentials too. **New connection** goes straight to the form, and the chevron in the header returns to the list. - **Connection rail** — when more than one connection is open, a slim rail appears on the left. Right-click an icon for **Open / Edit connection / Close connection / Close other connections / Close all connections**. With a single connection open the rail hides itself. - **Resume last connection** — after you click the back chevron (or relaunch the app), the picker shows a **Continue where you left off** banner for the last connection you opened. One click returns to that explorer. - **Import / export & QR** — export one connection from the share icon or all of them from the picker as a `.dbdesk` bundle. Passwords are left out by default; tick **Include passwords** to encrypt them with a passphrase (scrypt + AES-GCM). Import accepts a file, pasted bundle or `dbdesk://` link, shows a preview, then merges with new ids. **Show QR** renders a scannable code for a single connection (QR capacity is limited, so large bundles fall back to the file/copy). - **Backup & restore (migration)** — Settings → **Backup all** writes one file with every connection, saved view and saved query. Passwords are optional and encrypted (scrypt + AES-GCM). On the new Mac, **Restore** previews the file, creates the connections, remaps views/queries to the new ids and leaves passwords blank when they were not included. - **Structure grid** — the Structure tab (bottom switcher) shows a TablePlus-style structure grid: `#`, column, data type, character set, collation, nullable, default, extra (auto-increment/identity), foreign key and comment, plus an index grid (`index_name`, algorithm, unique, column). DDL is still available from the **DDL** button but no longer the default view. - **SQL query tabs** — **SQL** (or **⌘T**) opens a dedicated query tab next to the table tabs. Each tab keeps its own SQL text and result set, so a second query does not overwrite the first; close a tab when you are done. - **Bottom data toolbar** — Run, Limit, Filter, row metadata, view/SQL/column actions, More menu and pagination sit under the grid, like TablePlus. - **TablePlus-style filters** — each row has a checkbox, a **Raw SQL / column** picker, a full-width pattern, **Apply**, **−** and **+**. Raw SQL rows append a WHERE expression; column rows keep the operator/value controls. **Apply all** enables every valid row, **Clear** unapplies the filters but keeps their values (press Apply to re-enable), and **SQL** turns the active filters into a SELECT. Saved views keep the flags. - **Flexible export** — export the current table as **CSV**, **JSON** or **SQL INSERTs** from the table right-click menu or the **More** menu. The export respects the active filters and sort and caps at 50k rows (200k server cap). - **Quick panel (⌘P / Ctrl+P)** — jump to a table, view, schema, function or connection, or run actions such as **New SQL tab**, **Toggle theme**, **Settings** and **Close connection**. Arrow keys + Enter work. - **SQL editor** — syntax highlighting for keywords, strings, numbers, comments and function calls. Autocomplete is **alias-aware** (`c.` lists the columns of the table aliased `c`), knows every table referenced in `FROM`/`JOIN`, includes table names, columns and functions, and supports fuzzy matching with a source label. `⌘Space` / `Ctrl+Space` opens the list manually; `↑`/`↓` + `Tab`/`Enter` accepts. - **JSON editor** — double-click a JSON/JSONB cell for a large modal with **Format**, **NULL**, Cancel and Save; invalid JSON is rejected. - **AI autocomplete (on by default)** — once an AI provider is configured, press **⌘I** / **Ctrl+I** in the SQL editor; turn it off under **Settings → AI provider** if you prefer. The configured model returns a continuation at the caret; **Tab** inserts it and **Esc** dismisses it. Only the SQL text and schema metadata are sent — never rows or secrets. - **Model detection** — in **Settings → AI provider**, enter the base URL and API key and press **Detect models**. The model field turns into a picker of the models the provider reports, with **Type** to go back to a custom name. - **Saved query buttons** — the SQL toolbar has **Save** (name + current SQL) and **Saved** (opens the snippet list); the same snippets are available to the MCP agent through `queries_list` / `query_save` / `query_delete`. - Everything the plugin page does: - connections (PostgreSQL, Redshift, CockroachDB, Greenplum, MySQL/MariaDB, SingleStore, SQL Server, ClickHouse, SQLite, DuckDB, Elasticsearch, InfluxDB 3, libSQL, Cloudflare D1, Oracle, Vertica, Cassandra, Amazon Athena, DynamoDB, BigQuery, Snowflake, MongoDB, Redis/Valkey) with SSH tunnels, custom tunnel commands, MCP query tools and HTTP gateways - schema tree, typed data grid, inline editing, filters, tabs, saved views - SQL runner, autocomplete, formatter, history, saved queries, charts - structure grid (columns + indexes) with on-demand DDL, cross-connection diff, add/drop/rename column, index editor - CSV import and whole-table export - serialized-PHP tools and the WordPress Site tab - read-only guard, production approvals and the write audit log - Activity drawer Notes for the standalone build: - **Native macOS notifications** — approval requests and production writes show a system notification while the app is running. Nothing is sent to Telegram or any external service. Approve writes in the **Approvals** drawer; test with **Settings → Notifications → Test**. Because the build is ad-hoc signed (no Apple Developer ID), macOS ties the notification permission to the current signature and drops it after every update. Open **System Settings → Notifications → DB Desk**, enable it and choose **Alerts**; the Settings panel has a shortcut plus diagnostics. The **Fallback** test posts through Script Editor for setups where native delivery still fails. With a Developer ID build the permission survives updates. - **MCP connections work directly.** Add the streamable-HTTP endpoint (e.g. `https://mcp.example.com/mcp`), the tool name and SQL argument, then **Authorize**: DB Desk runs OAuth 2.1 with PKCE through a loopback redirect, opens the system browser, stores the tokens encrypted and refreshes them automatically. No token pasting. Unauthenticated MCP servers also work; Hermes-style named MCP servers still work in the plugin. - SQLite needs the file on this machine (no upload). --- # MCP server Source: https://dbdesk.app/docs/mcp.html # MCP server DB Desk can act as a Model Context Protocol server so a **local** agent can drive the same connections the app uses. Nothing is exposed until you enable it in **Settings → MCP server**. ### Transports **stdio** (Claude Desktop, Cursor, most clients): the bundled sidecar runs as a bridge and talks to the open app. ```json { "mcpServers": { "dbdesk": { "command": "/Applications/DB Desk.app/Contents/Resources/sidecar/dbdesk-server/dbdesk-server", "args": ["mcp"], "env": { "DBDESK_HOME": "/Users/you/Library/Application Support/DB Desk" } } } } ``` Use **Copy stdio config** in Settings to get the exact paths for your install. **HTTP** (Streamable HTTP, JSON-RPC 2.0): `POST http://127.0.0.1:/mcp` with `Authorization: Bearer `. Use **Copy HTTP config**. The app must be open. The bridge discovers the port from `/data/runtime.json`; the token lives in `/data/mcp.json` (mode 0600). ### Connecting to an MCP server 1. Paste the Streamable-HTTP URL and click **Authorize**. 2. Click **Detect tools**. DB Desk calls `tools/list` and shows the tools that look like SQL runners (usually names ending in `_query`), with the detected dialect and database name. 3. Pick one. DB Desk fills the **SQL argument** (usually `sql`), the dialect and the **Database label**. For an MCP connection the **Database** field is only a display label — the tool you pick determines the real database. If the tool itself needs a database argument, put it in **Extra arguments**, for example `{"database":"analytics"}`. ### Tools | Tool | What it does | |---|---| | `connections_list` | saved connections (no passwords or tokens) | | `databases_list` | databases reachable through a connection | | `tables_list` | schemas + tables/views | | `table_columns` / `table_indexes` / `table_ddl` | structure | | `table_rows` | rows with filters, order, limit, offset | | `table_csv` | CSV text (capped, reports `truncated`) | | `query` | one SQL statement, audited as `mcp_query` | | `ask_data` | DB Desk's AI agent, including multi-database local joins | | `connection_draft` | propose a connection; the user reviews it and types the password | | `connection_update` | edit non-secret fields (host, port, db, user, group, SSH) | | `connection_delete` | queue deletion for approval | | `connection_test` | open the saved connection and return server details | | `views_list` / `view_create` / `view_delete` | manage saved views | | `queries_list` / `query_save` / `query_delete` | manage the SQL snippets in the Queries drawer | | `app_status` | version, data path, counts, AI model, MCP and notification state | | `settings_update` | toggle notifications, set the AI model, turn MCP writes off | ### Connection drafts An agent cannot receive or send database passwords. `connection_draft` stores a pending draft; the picker shows **Agent drafted “…”** with **Review**. The normal connection form opens prefilled, the user types the password, and saving marks the draft applied. Drafts never contain secret-like keys. ### Destructive actions `connection_delete` and production `connection_update` create entries in **Approvals**. Nothing changes until the user approves; the audit log records both the request and the result. `settings_update` cannot enable writes, change the AI base URL/key or read the MCP token. ### Writes - A **read-only** connection only accepts `SELECT`/`WITH`/`SHOW`/`EXPLAIN`. - A writable connection can run writes when **Allow writes** is on (it is on when you first enable MCP; turn it off if the agent should be read-only). - Production writes use the existing audit + native notification path. - Every MCP statement is written to the audit log with action `mcp_query`. ### Connection access model The connection picker is **not** an access gate. MCP clients talk to the local service directly, so when the server is enabled, **every saved connection is reachable** — even one you never opened in the picker. A tunnel or pool is opened on demand by the backend when a tool first uses that connection. Opening a table in the UI and exposing a connection to MCP are separate things. To restrict what an agent can touch: - turn the **MCP server** off when you are not using it; - keep connections **read-only**, or give their database user limited grants; - turn **Allow writes** off for an agent that should only read; - delete connections you do not want exposed; - quit DB Desk — both stdio and HTTP transports stop immediately. ### Writes - A **read-only** connection only accepts `SELECT`/`WITH`/`SHOW`/`EXPLAIN`. - A writable connection can run writes when **Allow writes** is on. - Production writes are written to the audit log and send the native notification. They do **not** raise the approval drawer — keep the MCP token private and prefer read-only connections for agents. - Every MCP statement is written to the audit log with action `mcp_query`. ### Security - The HTTP endpoint binds to the app's loopback socket only. - Requests require the bearer token; rotate it from Settings at any time. - Tool results never include passwords, API keys or SSH material. - Disable the server (or quit the app) and both transports stop immediately. --- # Security Source: https://dbdesk.app/docs/security.html # Security & privacy [What leaves your machine](#what-leaves-your-machine-measured) · [Report a vulnerability](../SECURITY.md) · [Privacy statement](../PRIVACY.md) A reader-facing summary lives at ; this file is the technical version, and it lists the gaps as well as the controls. ## AI privacy - **Prompts are built from allowlists, not connection records.** Data questions send table/column names, the question and previous SQL only — never rows, passwords, tokens, SSH keys, headers or tunnel env. The agent catalog carries only id, display name, group, kind and database name; hosts and users are omitted. - **Cross-database rows stay local.** Result sets are loaded into in-memory SQLite and joined on this Mac. The join query and row counts are visible to the model; the cell values are not. - **AI setup** sends only your message and generic instructions. The returned draft is sanitized: keys containing `password`, `token`, `secret`, `key`, `header`, `env`, `auth` or `cookie` are dropped. - **AI autocomplete** is **on by default** once an AI provider is configured; turn it off at **Settings → AI provider → AI autocomplete**. When you press **⌘I**, it sends the SQL text around the caret plus dialect, database name and the table/column names and types referenced in the query. It never sends rows, result sets, passwords, API keys, SSH material or tunnel env, and the server rejects the request unless the toggle is on. - **Model detection** calls `GET /models` with your API key to list model names. The key stays on this Mac; only the model IDs are shown. - **Secrets at rest** stay AES-GCM encrypted and are decrypted only to open the database connection. - **Local-only option**: point the base URL at Ollama/LM Studio on `127.0.0.1` and nothing leaves the Mac. - The test suite asserts that a saved password never appears in an AI payload and that setup drafts cannot carry secrets. ## What leaves your machine (measured) | What you do | Outbound network | |---|---| | Open the app, browse the tree, view tables | none | | Run a query, edit a row, export CSV | none | | Save or edit a connection | none | | Use AI (only once a provider key is configured) | your endpoint: `api.openai.com`, your own gateway, or Ollama on `127.0.0.1` | | Check for updates | `github.com`, for the signed release manifest | Measured against 0.13.12 with `scripts/egress-check.py`: a session that created a connection, opened a table, ran an aggregate query and opened Settings issued **35 HTTP requests, all to `127.0.0.1`**, and the backend held **no outbound TCP connection**. The script drives the real UI, so the measurement can be repeated on any build. ## Threat model **What DB Desk is trusted with.** Database credentials; the authority of the user the database connection runs as; whatever the user types into the SQL editor; a shell command if an SSH tunnel is configured. **Trust boundaries.** 1. *Your machine* — everything under the app data folder is readable by your user, and so is the vault key next to it. Encryption at rest protects a copied file, a stray backup or a sync client; it does not protect against code running as you. 2. *The UI* — treated as untrusted by the backend. Read-only, statement limits and production approvals are enforced in the API, not in the browser. The UI is served over loopback and, in server mode, behind a login with CSRF tokens. 3. *Outbound* — the database, an optional AI endpoint, and the updater. Nothing else; see the table above. 4. *The model provider* — sees schema, SQL and your question. Never rows, never secrets. **In scope for an attacker model.** A malicious database or a hostile server on the other end of a connection (crafted table names, absurd column counts, slow queries); a stolen laptop with the data folder on it; a compromised AI endpoint returning malicious drafts; a tampered update manifest. **Explicitly not defended against.** Malware already running as your user (it can read the vault key and the audit log); an operator pasting `DROP TABLE` into a connection whose user has the right to run it; a database user with more privilege than the task needs. ## Security DB Desk executes SQL with the credentials you configure, and a custom tunnel command is a shell command you supply. Treat a connection as code execution on this machine. Read-only is the default and enforced by the backend, but it is a guardrail, not a sandbox. The strongest control available to you is the database user itself: a `GRANT SELECT`-only role makes every guardrail above redundant, and the app runs normally that way. --- # Development Source: https://dbdesk.app/docs/development.html # Development ## Performance - **Persistent connections.** PostgreSQL uses `psycopg` and MySQL/MariaDB uses `PyMySQL` when installed, keeping one pooled connection per configured connection (serialized with a per-connection lock). Measured against local containers, a table page dropped from ~95 ms to ~1.6 ms per call. The `psql`/`mysql` CLIs remain as a fallback when the drivers are missing (the Hermes runtime does not ship them). - **Column metadata cache.** `/columns` and `/table/rows` share a 60-second cache with in-flight coalescing, so a table open runs one metadata query instead of two and repeat views never touch the database. - **Fast launch.** The sidecar is a onedir build (no extraction) and the splash window appears immediately while the backend starts. - **Statement timeouts** are set on the session (`statement_timeout` / `MAX_EXECUTION_TIME` / `max_statement_time`), so a runaway query cannot block the UI forever. ## Tests ```bash npm --prefix ui run build python -m unittest discover -s tests -v ``` The smoke test drives the real FastAPI app with an in-memory/temporary SQLite database, so no server is required. ## Layout ``` backend/app.py FastAPI app: /api/* + static UI + /health backend/dbdesk_api.py adapters (standalone copy of the plugin backend) backend/dbdesk-server.spec PyInstaller one-file build ui/src/plugin.js DB Desk page (same file as the Hermes plugin) ui/src/sdk-shim.jsx the few Hermes SDK pieces the page imports ui/src/main.jsx shell: connection picker vs the page, toasts, theme ui/src/launcher.jsx TablePlus-style connection list src-tauri/ Tauri v2 shell, config, icons, capabilities src-tauri/sidecar/ staged onedir sidecar (gitignored, built by script) scripts/build-sidecar.sh PyInstaller onedir -> src-tauri/sidecar/dbdesk-server/ tests/test_standalone.py server smoke tests ``` `ui/src/plugin.js` and `backend/dbdesk_api.py` are copies; the sync script refreshes them from a local Hermes checkout: ```bash scripts/sync-plugin.sh /path/to/.hermes/plugins/dbdesk ``` --- # Signing Source: https://dbdesk.app/docs/signing.html # Signing & notarization The default CI builds are **unsigned** and free: they run on your own Mac after the steps below. Signing + notarization is only needed for clean distribution to other people, and requires a paid Apple Developer account. ### Install an unsigned build (no Apple Developer account) **Build it on the Mac that will run it** — locally built apps are not quarantined, so Gatekeeper does not complain at all: ```bash git clone https://github.com/wzul/dbdesk-app cd dbdesk-app make install # Node, Python deps make bundle # Python + Rust toolchain required open "src-tauri/target/release/bundle/macos/DB Desk.app" ``` **Or download the CI DMG**, drag **DB Desk** to Applications, then: - macOS 15+: open it once, then **System Settings → Privacy & Security → Open Anyway**; or - remove the quarantine flag: ```bash xattr -dr com.apple.quarantine "/Applications/DB Desk.app" ``` Only do this for a build you trust (this repository's CI or your own). ### What you need 1. **Apple Developer Program** membership (paid, currently US$99/year). 2. A **Developer ID Application** certificate — not “Apple Development”. 3. Your **Team ID** (developer.apple.com → Membership). 4. Notarization credentials: either an **app-specific password** for your Apple ID, or an **App Store Connect API key**. ### Create the certificate On a Mac, either: - Xcode → Settings → Accounts → select your team → **Manage Certificates** → **+** → **Developer ID Application**, or - developer.apple.com → Certificates, Identifiers & Profiles → **+** → **Developer ID Application** (upload a CSR made with Keychain Access). Then export it: Keychain Access → **My Certificates** → right-click `Developer ID Application: …` → **Export** → `.p12` with a password. ```bash security find-identity -v -p codesigning # "Developer ID Application: Your Name (ABCDE12345)" ``` ### Add the GitHub secrets ```bash # certificate (.p12) as base64 base64 -i DeveloperID.p12 | gh secret set APPLE_CERTIFICATE gh secret set APPLE_CERTIFICATE_PASSWORD # the .p12 password gh secret set APPLE_SIGNING_IDENTITY --body "Developer ID Application: Your Name (ABCDE12345)" gh secret set APPLE_TEAM_ID --body "ABCDE12345" # notarization: Apple ID + app-specific password (appleid.apple.com → Sign-in # and Security → App-Specific Passwords) gh secret set APPLE_ID --body "you@example.com" gh secret set APPLE_PASSWORD ``` API-key alternative (better for CI, no password/2FA): ```bash gh secret set APPLE_API_ISSUER --body "" gh secret set APPLE_API_KEY --body "" # write AuthKey_.p8 from a secret to a file before the build step ``` Tauri reads these environment variables directly; the workflow already passes them through, and only signs when `APPLE_SIGNING_IDENTITY` is set. ### What the workflow does 1. Imports the `.p12` and signs `dbdesk-server` on its own with hardened runtime and the entitlements below (nested binaries must be signed before notarizing the app). 2. `tauri build` signs `DB Desk.app` (hardened runtime), notarizes it with `notarytool`, and staples the ticket. 3. Verifies with `codesign` and `spctl`. 4. Produces `DB Desk__.dmg`. ### Entitlements `src-tauri/entitlements.plist` disables **library validation**: ```xml com.apple.security.cs.disable-library-validation ``` The Python sidecar is a PyInstaller one-file binary. On launch it extracts its dylibs to a temp directory and `dlopen()`s them. Hardened runtime (required for notarization) refuses to load libraries not signed by the same Team ID, so without this entitlement the notarized app starts and then the backend dies. `com.apple.security.cs.allow-unsigned-executable-memory` covers Python extensions that map executable memory at runtime. ### Verify a build ```bash codesign --verify --deep --strict --verbose=2 "DB Desk.app" codesign -dv --verbose=4 "DB Desk.app" # TeamIdentifier + hardened runtime spctl --assess --type execute --verbose=2 "DB Desk.app" # accepted / notarized xcrun stapler validate "DB Desk.app" ``` If the DMG itself is not stapled (the app inside is), submit and staple it once: ```bash xcrun notarytool submit "DB Desk_0.1.0_aarch64.dmg" \ --apple-id "$APPLE_ID" --team-id "$APPLE_TEAM_ID" --password "$APPLE_PASSWORD" --wait xcrun stapler staple "DB Desk_0.1.0_aarch64.dmg" ``` ### Local signed build ```bash export APPLE_SIGNING_IDENTITY="Developer ID Application: Your Name (ABCDE12345)" export APPLE_ID="you@example.com" APPLE_PASSWORD="app-specific-password" APPLE_TEAM_ID="ABCDE12345" make bundle ``` Keep the `.p12` and passwords out of the repo; the certificate can be revoked from developer.apple.com if it leaks. ## Verifying a release Every release publishes `SHA256SUMS.txt`, a Sigstore bundle for it (`SHA256SUMS.txt.bundle`), and a build-provenance attestation stored by GitHub. Nothing here asks you to trust a key we hold: the signature names the workflow that produced the file. ```bash TAG=v0.13.12 BASE=https://github.com/wzul/dbdesk-app/releases/download/$TAG # 1. checksums and signature curl -LO "$BASE/SHA256SUMS.txt" -LO "$BASE/SHA256SUMS.txt.bundle" # 2. which workflow signed it — keyless, so this is the whole identity cosign verify-blob \ --bundle SHA256SUMS.txt.bundle \ --certificate-identity-regexp '^https://github.com/wzul/dbdesk-app/.github/workflows/release.yml@refs/.*$' \ --certificate-oidc-issuer https://token.actions.githubusercontent.com \ SHA256SUMS.txt # 3. the asset you downloaded matches the signed list sha256sum --ignore-missing -c SHA256SUMS.txt # 4. and where it was built gh attestation verify DB.Desk_${TAG#v}_aarch64.dmg --repo wzul/dbdesk-app ``` If step 2 prints `Verified OK`, the checksum list came from this repository's release workflow and has not been altered since. If step 3 prints `OK` for your file, the file is the one that list describes. A dry run of the same steps without publishing a release: ```bash gh workflow run release.yml --repo wzul/dbdesk-app # workflow_dispatch, dry_run=true ``` --- # Troubleshooting Source: https://dbdesk.app/docs/troubleshooting.html # Troubleshooting ## ClickHouse behind Cloudflare Access ClickHouse uses its HTTP interface, so a Zero Trust application works without a tunnel: 1. In Cloudflare Zero Trust create a **service token** (Access → Service Auth). 2. Add a ClickHouse connection: **host** = the public hostname (a full `https://…` URL is accepted and normalized), **port** `443`, **SSL mode** `require`. An `https://` host implies `require` and port 443; port 443 also implies https (unless SSL mode is `disable`). 3. Set **HTTP path** if the endpoint is mounted on a subpath (default `/`). 4. Paste the headers into **Custom HTTP headers**, one per line: ``` CF-Access-Client-Id: .access CF-Access-Client-Secret: ``` 5. **Test**, then save. If Cloudflare returns **error 1010** (Bot Fight Mode), it is rejecting the `Python-urllib` browser signature. DB Desk now sends a browser User-Agent by default; you can override it with a `User-Agent: …` line in the custom headers. Headers are AES-GCM encrypted in the connection store; values are never returned to the UI or AI prompts. The edit form lists the saved header **names** and an empty box: typing new lines **replaces** the saved set, leaving it blank keeps it, and **Remove saved headers** clears it. Headers are only included in exports/backups when you tick **Include passwords**. `Host`, `Content-Length`, `Connection` and `Transfer-Encoding` are rejected so the HTTP client keeps control of the transport. The same fields can carry other proxy headers (e.g. an API gateway token). ## Common errors **MCP: `unknown tool "query"`** — the server does not expose a tool with that literal name. Open the connection, click **Detect tools**, and pick the tool that runs SQL (often `_query`). The tool determines the database; the **Database** field is only a display label. **MySQL MCP: `Error 1064 ... near 'schema'`** — fixed in 0.13.5. Update the app; the tree aliases `schema` with backticks. **MCP connection shows "No tables"** — check the detected **SQL dialect** (PostgreSQL / MySQL / ClickHouse) and that the chosen tool is the read-only SQL runner. The tree queries `information_schema`/`pg_class`, so the tool must allow those reads. **Notifications do not appear** — after an update macOS resets the permission. Open **System Settings → Notifications → DB Desk** and allow alerts; then use **Settings → Notifications → Test**. **macOS says the app is damaged or from an unidentified developer** — the build is ad-hoc signed. Right-click the app → **Open** once, or run `xattr -dr com.apple.quarantine /Applications/DB\ Desk.app`.