Protected by default. Agents welcome.

An MCP server for production databases. Every query is scored and gated before it runs, then bounded when it returns.

npm install -g @safe-db/mcp
A terminal showing the safe-db MCP server pivoting a fetched sample, then refusing a DELETE statement: only SELECT statements can run here

All engine, no app

The agent sends SQL text. safe-db parses it into a structured query and compiles that with bound parameters, so the text itself never reaches the database. One SELECT per call.

Every run is scored against its query plan and an adjustable risk gate. Above the gate, the tool returns a reason instead of rows. The agent can rewrite the query. It cannot bypass the gate.

Default sample
A 500-row first look.
Row limit
Larger samples on request.
Sample ceiling
A 10 MiB cap on what is kept.
Query timeout
Queries time out after 10 seconds by default.
Preview
Explore large results without overwhelming the conversation.
Results
Available for 30 minutes, then discarded.
Exports
CSV files stay on disk after the sample expires.

Twenty tools, one gate

A progressive catalog, then a gated query. Pivot, filter, or export the sample. No tool returns the full schema or the full result, and no tool accepts a password or a connection URL.

list_connections
Saved connections, without passwords or URLs.
list_tables
A short list of what you can query.
describe_table
Inspect one table before you query it.
run_query
One gated SELECT, with a short preview.
get_result_rows
More of the same sample, when you need it.
summarize_result
A compact read of the sample you already have.
delete_connection
Removes a saved connection after you confirm.
search_catalog
Find tables and columns by name.
find_join_paths
See how tables connect before you join them.
assess_query
Score a SELECT without running it.
pivot_result
Pivot the sample you already have.
filter_result_rows
Filter that sample without another query.
export_result
Write the sample to a CSV on disk.
list_saved_queries
Queries you saved on this server.
run_saved_query
Run a saved query through the same gate.
save_query
Keep a SELECT for later.
delete_saved_query
Removes a saved query after you confirm.
list_recipes
Saved Explore layouts you can reuse.
apply_recipe
Apply a recipe to the sample you already have.
list_query_history
Recent runs on this server.

Resources and prompts

The same catalog and samples, as readable resources and two short workflows.

safedb://connections
Saved connections, without secrets.
safedb://connections/{connection_id}/tables
The tables on one connection.
safedb://results/{result_id}/summary
A compact read of a fetched sample.
explore-database
From catalog to a gated SELECT.
analyze-result
Summarize, pivot, filter, or export a sample.
{
  "mcpServers": {
    "safe-db": {
      "command": "npx",
      "args": ["-y", "@safe-db/mcp"]
    }
  }
}

Configure once

Add a connection once, then let your agent query it by id.

The password stays in your credential store, out of the config, the tool calls, and the environment.

Where it runs

Bundled Java runtime, nothing to install. Same five databases as the desktop app: PostgreSQL · MySQL · SQL Server · Oracle · Db2.

macOS arm64

Windows x64

Linux x64

Linux arm64

Give the model a database client you don’t have to worry about

One npm package, one CLI command per connection, one line in the client config. The agent can inspect schema, assess a query, and run a gated SELECT. It cannot write.

safe-db is proudly opensource.

GitHub