DBA Brain
Monitors MySQL instances as database targets, collecting health metrics, grading them against policies, running scheduled SQL, verifying backups by restore, producing reports/SLA data, and feeding alerts.
Monitors PostgreSQL instances as database targets, collecting health metrics, grading them against policies, running scheduled SQL, verifying backups by restore, producing reports/SLA data, and feeding alerts.
Delivers alerts and reports to Telegram and accepts gated chat commands; optionally lets the AI assistant answer DBA and DevOps questions in Telegram.
This server has a remotely hosted endpoint. Open its connector listing for connection details, authentication requirements, and setup instructions:
DBA Brain
dbabrain.dev · PyPI ·
Downloads · pip install dbabrain ·
MCP: mcpservers.org ·
Glama ·
Glama connector
An open-source DBA tool for DBAs, SREs and DevOps engineers. It collects health metrics from your SQL Server, Oracle, PostgreSQL and MySQL instances, grades them against policies you write, runs your scheduled SQL, takes backups and proves them by restoring them, checks objectives against real measurement history, and tells you about it — on a schedule, without an agent on any monitored machine.
It sends nothing you did not switch on. No telemetry, no usage reporting, no update check. It connects to the databases and hosts you list; with a dbabrain key, once a day to dbabrain.dev to check that key (the key alone, nothing about your databases); and only if you turn each on, to a chat service and to the AI - through dbabrain.dev, or a model's API on your own key. Nothing else. dbabrain.dev collects none of your data: the key has two jobs only - to authenticate the node and to relay its assistant's AI turns - and dbabrain.dev keeps your email, the key's fingerprint and term, and each AI turn's tokens and cost; never a question, an answer, or anything from your databases.
Better with an AI, complete without one. dbabrain is the harness an AI model works through: get
a free dbabrain key (dbabrain key-request, an email sign-in on dbabrain.dev) and its assistant -
answering through dbabrain.dev, no Anthropic key of yours needed - supports the DBA's and the DevOps engineer's
daily work on databases and servers - it reads what is happening (alerts, backups, jobs, metrics, a
read-only query on the server), explains it, and says the exact command for the next step, in
Telegram or in a terminal; it also guides a new install. It only reads, through the same commands a
person runs. An AI client can also drive it directly over MCP
(dbabrain mcp serve). Leave the AI off, which is the default, and every collection, backup, report
and alert runs exactly the same.
How a model reaches your estate - no public IP, no inbound port, no server of yours on the internet. In every way below the connection is opened FROM your machine, outward; nothing on the internet connects in, and the commands run on your machine with your credentials:
Way | What runs where | What the network needs |
The assistant ( | Your node sends the question to dbabrain.dev, which passes it to the model's API (or, with | Outbound HTTPS to |
An AI app on the same machine (Claude Desktop, Claude Code, any MCP client) | The app starts | Nothing from dbabrain; the app talks to its own model |
claude.ai on the web or a phone |
| Outbound HTTPS/WebSocket to |
Only dbabrain mcp serve --http - serving MCP yourself - needs an address others can reach, and it
is behind a bearer token. What leaves in each case, and what is redacted first:
docs/security.md, docs/07_telegram_app.md,
docs/16_mcp_app.md.
What it does | |
Health metrics | Around ninety metrics across four engines: availability, capacity, performance, recoverability, security, maintenance. Collected and normalised into one shape. |
Graded, not dumped | Every measurement is graded against a policy you wrote. You read a verdict (OK, WARNING, CRITICAL) and pull the evidence only for what came back bad. |
Backups proven by restore | Runs backups, restores them onto a disposable target, verifies the result and records what was proven and when. The restore is the proof. |
Scheduled SQL | Your own SQL, on a schedule or on request, against approved targets, delivered as text or a spreadsheet. The SQL is a reviewable file, never a string in configuration. |
Reports | Fleet inventory, per-server metrics, index usage and SLA pages, with a freshness gate so a stale number is never reported as a current one. |
SLA / SLO | Indicators computed from stored measurement history, objectives evaluated with an error budget, and how much of it is left. |
Alerts and chat commands | Telegram delivery, one message at a time. Commands people send back are gated by the person's clearance and the chat's. |
Configuration as code | Every decision is a JSON file you keep in version control. A threshold change is a diff and a review, not an edit to somebody's script. |
Secrets kept encrypted | PBKDF2-HMAC-SHA256 and Fernet. The passphrase is supplied at run time and never written to disk, a log or the store. A password travels on stdin, never as a command-line word. |
AI assistant (optional) | Day-to-day support for the DBA and the DevOps engineer, on the databases and servers dbabrain watches. Ask in Telegram or at the terminal - why is this alert firing, did last night's backups run, which jobs failed, what is slow on this server, which query regressed - and it finds the answer itself: the metrics, runs, backups and restores in dbabrain's store, the configuration and the logs, a read-only query on the server. It analyses queries - the heaviest by CPU, reads and duration, ad-hoc and single-use plans, plan regressions and plan changes (Query Store) - and indexes (usage, unused, fragmented, invalid). It explains what it found and what to do, and gives the exact command for the next step (a CLI line or a |
Two ways to read what it is, and both are accurate:
A database tool for SRE / DevOps | Nothing is installed on a monitored machine — it reaches instances and hosts the way an operator does, over a connection and a credential you already have. Every decision is a JSON file you keep in version control, so a threshold change is a diff and a review rather than an edit to somebody's script. It schedules itself, or your scheduler drives it. |
A harness for an AI model | Every capability is one command that takes one JSON object and answers with one, with the same seven keys always present. There is no separate agent API: the command a person runs is byte-for-byte the command an agent runs - its own assistant, an MCP client, or a coding agent in a shell. The model reads graded verdicts instead of raw rows, and every action it proposes is one a person can audit. |
The second is not a later ambition. It is why the shape is what it is — and it is the supported path today, because the console that would let a person add an instance in a browser is not finished yet (see Two ways to drive it).
One code path is the point, not a convenience. An agent cannot reach a capability a human
cannot audit, because there is only one of each. Every run is a row in job_runs and a line in a
log with the same shape whoever started it, so "what did the agent do last night" is the same
query as "what did the daemon do last night".
Status
1.0 - in production. The main functions are stable and run in production - on an estate of many SQL Server instances, with a few Oracle and PostgreSQL instances under modest workloads. MySQL and heavier workloads are supported, with less production mileage so far. Reports of how it behaves on other estates are welcome (GitHub issues).
Related MCP server: MCP Database Manager
The goal
To be a tool a DBA, a DevOps engineer or an SRE can rely on — one that works alongside an AI agent and saves a large amount of its tokens, and works just as well with no agent at all.
Three commitments, and they are meant to be held to:
Reliable | Every operation is typed, logged and repeatable. A scheduled run that failed can be replayed by hand from the same JSON request. Backups are not reported as successful — they are restored, and the restore is the proof. |
Cheap for an agent to use | An agent working a database from a shell pays, in context, for every raw result set it reads — on every check, most of them healthy. Here it sends a small request and reads a graded verdict, then pulls the evidence only for what came back bad. |
Not dependent on one | No model is required. The assistant makes setup and day-to-day questions easier; without it, no model is contacted, and the daemon, the schedules, the reports and the alerts all still run. The model is a caller, never a component the estate depends on. |
The shape of that, because it is the whole argument in one picture:
WITHOUT a tool WITH DBA Brain
agent -> raw SQL -> agent agent -> DBA Brain -> database
"check this database" "check this database"
-> SELECT ... dm_os_wait_stats -> one JSON request
<- every row, into the context
-> SELECT ... sys.databases <- one graded envelope:
<- every row, into the context 41 checks, 40 OK,
-> SELECT ... backupset 1 WARNING: appdb
<- every row, into the context log backup 31h old
-> ... once per check, per run
<- all of it, healthy or not -> fetch the evidence for
the ONE that came back bad
The model reads the evidence and
derives the verdict, every time. The verdict was derived in
It pays for the 95% that was fine. reviewed SQL, once, by a person.The saving is not compression — it is not sending what nobody needed to read. Grading a metric is a fixed decision that belongs in SQL somebody reviewed, not a judgement re-made by a model on every cycle from raw rows. The agent's context is then spent on the thing that is actually hard: what to do about the one check that failed.
And the target that is not met yet: a person who has never seen this project should go from
pip install dbabrain to a collecting install by pointing an AI agent at these docs — no estate
bundle from another machine, and no assumption that they already know what a database ought to be
checked for. Today that path expects more DBA knowledge than it should. Closing that gap is the
current priority; see docs/first_run.md for where it stands.
What it is not
It is not an AI that runs your estate on its own — it is the harness a model works through. The scheduler, the grading, the backups and the alerts are code and reviewed SQL; no model decides any of them, and none is needed for them. The optional assistant answers through dbabrain.dev once the node has a dbabrain key (or on your own Anthropic key), reads through read-only tools, and proposes commands for a person to run. Every capability takes one JSON object and answers with one, and that shape is what lets a human, a shell script, a chat command and a model drive the same operation without a translation layer. The distinction is worth keeping: an operation that does not reason is one you can audit, and the judgement about whether to restore production stays with whoever is accountable for it.
It does not replace incident analysis, change approval, or runbooks. It supports them. A restore drill proves a backup is restorable; deciding to restore production is still yours.
It is not a dashboard product. It has a web console for reading reports and editing configuration, but the primary interface is a CLI and its primary output is a record in a database you own.
It installs nothing on your databases. No agent, no extension, no stored procedure. It logs in with a read-only account and asks questions.
Who it is for
A DBA or small team responsible for a handful to a few dozen instances across more than one engine, tired of it living in twelve cron jobs and a folder of scripts. If you have one PostgreSQL cluster and a hosted monitoring product you are happy with, this is more machinery than you need.
Two more, deliberately:
The person who gets paged about a database without being a DBA — the DevOps or SRE owner of a
service, in a company that has no DBA at all. They need the same operations and should not have to
design a monitoring strategy to get them, so the shipped catalogue is meant to be that
expertise: adopting this should be configuring an estate, not deciding what a healthy database
looks like. That is the intent — docs/first_run.md is honest about how far it holds today.
Whoever is building an agent that has to touch a database and does not want to hand it a shell.
The alternative to a typed operation is an agent composing SQL and psql invocations from prose,
where the blast radius is whatever it happened to write. Here what it can do is the set of commands
that exist: each one reviewed when it was written, each one logged the way a human's run is.
How it works
One run, end to end
Whoever starts it — the daemon, a person, a chat command or an AI agent — a run takes the same
path. The app hands one JSON request to transport, which starts the shared operations CLI; that
CLI reaches the database or host and answers with one JSON envelope. Results land in the runtime
store, and reports and alerts are built from there.
Every command answers in the same envelope, whether the work succeeded or not:
{
"success": true,
"operation": "restore-full",
"message": "Restored SALESDB_STG to 2026-08-07 01:40:00.",
"error": null,
"error_kind": null,
"data": { },
"metrics": { "duration_ms": 41230 }
}From a measurement to an alert
1. Collect | 2. Normalise | 3. Grade | 4. Store | 5. Report / alert / SLA |
around ninety metrics, four engines | one shape for every engine | against your policy in | the runtime store | by severity and error budget |
A backup is proven by restoring it
1. Backup | 2. Copy | 3. Restore | 4. Verify | 5. Record | 6. Clean up |
full / diff / log | to a disposable target | latest or a point in time | the result | what was proven, and when | and apply retention |
Each engine, step by step on dbabrain.dev: SQL Server · PostgreSQL · Oracle RMAN.
Capabilities
Ordered to match the reference docs; the ORD number links to each one.
Sixteen components of two kinds. An app (11: jobs - run as dbabrain daemon -, metrics, sql_tasks, reports, telegram, backup_restore, sla, sre, control, webhost, mcp) does one job, has its own cli.py, and never imports another app. A shared layer (5: db, logging_ops, common, lib, transport) is what every app stands on, and never imports an app. The root package dbabrain is neither: it is the dbabrain entry point and only dispatches. The same table, and who may import or run whom, is in docs/rules.md.
ORD | Component | Kind | Package / config | Responsibility |
Runtime store | shared layer |
| The database the toolkit keeps its own data in — job runs, measurements, report state, the delivery queue, restore history. SQLite to start, PostgreSQL when you outgrow it; the backend is one word in one file. | |
Logging engine | shared layer |
| Scoped application logs, runtime logs, shared errors, and daily archives. | |
App command daemon | app |
| The scheduler: runs each app on its own interval inside its allowed hours, skips one that is still running, and forwards the secret passphrase to every child process. | |
Metrics engine | app |
| Around ninety metrics across four engines — availability, capacity, performance, recoverability, security, maintenance — collected and normalised into one shape. | |
SQL task runner | app |
| Your own SQL, on a schedule or on request, against approved targets, delivered as text or a spreadsheet. The SQL is a reviewable file, never a string in configuration. | |
Reports | app |
| Turns measurements into scheduled reports and inventory pages, with a freshness gate so a stale number is never reported as a current one. | |
Chat delivery and commands | app |
| Delivers the outgoing queue one message at a time, and executes the commands people send back — gated by the person's clearance and the chat's. | |
Backup / restore | app |
| Runs backups, restores them onto a disposable target, verifies the result, and records what was proven and when. | |
SLA / SLO compliance | app |
| Computes indicators from stored measurement history, evaluates objectives with an error budget, and reports what is left of it. | |
SRE | app |
| Provisions the disposable lab databases that drills and rehearsals need — single instances or small HA clusters, in Docker or on VMs. | |
Control | app |
| Builds and deploys the toolkit to another node, and watches the toolkit itself — the one app that reports on the others. | |
Web host | app |
| Serves the rendered reports over HTTP and hosts the console. Publishes files; never generates them. | |
Common — shared operations | shared layer |
| Reaching a host, running SQL, moving a file, rotating a password, confirming something dangerous. Every command takes one JSON object. Invoked as a CLI, never imported. | |
Lib — shared rules | shared layer |
| Values and rules that are pure functions of their arguments: time windows, notify routing, severity, formatting. Imports nothing from the rest of the project. Only ever imported, never run as a CLI. | |
MCP server | app |
| dbabrain for Claude Desktop and Claude Code on your own machine: every | |
Transport — the one client | shared layer |
| Starts |
Sixteen components, and the list is closed. Eleven apps and five shared layers, as the Kind column says; anything new is one of them or a seventeenth ORD with its own directory and its own doc.
Every component has a doc, and every doc has a component. One
docs/NN_*.mdper package, both directions, enforced bytests/test_docs_cover_every_component.py. A component is not finished until its doc exists.That is a claim few projects can make, and it was written the hard way: one shared layer reached 46 modules and roughly 6,500 lines with no documentation and a fully green suite, because nothing connected the two directories.
Install
Python 3.12+. Every database driver is an extra, so a DBA who runs only PostgreSQL is not made to install an ODBC driver and an Oracle client to start.
python -m venv .venv
.venv/bin/pip install 'dbabrain[postgres]' # Windows: .venv\Scripts\pipExtra | For |
| PostgreSQL — pure Python, nothing else to install |
| MySQL / MariaDB — pure Python |
| Oracle — no client library needed for 12.1 and newer |
| SQL Server — also needs Microsoft's system ODBC driver |
| OS-level metrics and maintenance on Linux / Windows targets |
| everything |
Full instructions, including the two prerequisites that are not pip-installable and the container
image: docs/installation.md.
Upgrading an installed root: pip install --upgrade dbabrain, then
python -m dbabrain.common.cli upgrade-config '{}' # the plan: what moves, file by file
python -m dbabrain.common.cli upgrade-config '{"dry_run": false}' # apply; each file is copied firstA release that renames or moves a field keeps reading the old shape, so nothing breaks if you skip
this - your files just stay in the old shape. init and import-data say when there is something
to move. A record whose two spellings disagree is reported and its file left alone.
What it produces
Before installing anything, look at the output. examples/showcase/ holds
the four report families a live estate publishes — fleet inventory, per-server metrics, index usage,
SLA — captured whole, with every name that belongs to that estate replaced by a stable fake one.
Real fleets, real fragmentation, real verdicts; nothing invented and nothing traceable.
Four of those pages, as pictures — click one to open it full size:

Fleet inventory: every instance, its health, and a priority list of what to act on first, each with a recommended next step.

Server metrics: one card per health area, showing the worst reading, the rule that graded it and what it means.

SLA / SLO compliance: a verdict per engine, computed from stored history with no database connections.

Index usage: total, unused, cold and droppable indexes per instance, with how long the counters cover.
A repository cannot show you an HTML page — GitHub renders .html as source — so they are published
as a site by .github/workflows/pages.yml, or you can serve the
folder yourself:
cd examples/showcase
python -m http.server 8000 # then open http://localhost:8000/Most of those pages open straight from disk. The fleet metrics page does not: it is one page for the
whole estate and fetches one series file per server as you pick it, and a browser refuses that from
a file:// page. That is the browser's rule, not a defect in the copy.
Five minutes
A throwaway container, a least-privilege login, seven real measurements — and nothing to uninstall afterwards:
examples/postgres-quickstart/ — needs no system packages.
examples/sqlserver-quickstart/ — same shape, and it finds
a real problem with the instance, then clears it once you fix it.
cd examples/postgres-quickstart
docker compose up -d
python -m dbabrain.db.cli --config config.json init
python -m dbabrain.metrics.cli --config config.json collect --dry-run
python -m dbabrain.metrics.cli --config config.json collect
python -m dbabrain.metrics.cli --config config.json reportTwo ways to drive it
After pip install, someone has to describe the estate — which instances exist, which credentials
reach them, where alerts go. There are two ways to do that, and they differ only in who writes the
files.
Who configures it | Status | |
A person, in a browser | A web console: add an instance the way a database client does — host, port, user, password — and it collects | Planned. The console ships and edits configuration; the add-an-instance flow does not |
An agent, writing JSON | Every decision is a file. An agent writes them and runs three commands | This is the supported path today |
The agent path is the supported one on purpose: the configuration surface has to be settled before something generates it, and a console that writes files nobody has agreed the shape of becomes a second source of truth. The console itself ships — it serves the reports and edits configuration — but adding an instance from a host, a port and a password is not in it yet.
Both paths are written out step by step, with what to assert after each one, in
docs/first_run.md. It is written to be followed by a program and to be
readable by a person, because until the console lands they do the same thing.
From nothing to a running estate
Every command below is real and in this release. The long form, with what each step proves and what
bites people, is examples/standing-up-a-node.md.
Two things belong in every shell that runs these:
export DBABRAIN_SECRET_KEY="<your passphrase>" # or --key / --key-base64 per command
export PYTHONIOENCODING=utf-8 # a Windows console is cp1252 and dies on the emoji1. Install, and write the starting files
pip install "dbabrain[postgres,mssql,ssh,winrm]"
mkdir my-estate && cd my-estate
dbabrain guide # writes nothing; says what the next steps are
dbabrain init # config.json, data/*.json, secrets/secret_text.json[winrm] is not optional if you monitor a Windows host outside a domain: without pypsrp the OS
collectors fall back to a local shell that cannot authenticate, and the run looks fine while proving
nothing.
2. The store
python -m dbabrain.db.cli --config config.json init
python -m dbabrain.db.cli --config config.json check # tables, schema_versionSQLite under runtime/ by default — nothing else to install. data/store_config.json is where you
move to PostgreSQL later; db use-store sqlite|postgres switches it.
3. Prove the schedule runs before configuring anything
python -m dbabrain.jobs.cli --config config.json --onceEvery shipped command must reach status=done on a root where nothing is configured, reporting
what is missing rather than failing. The web host is skipped by --once on purpose — it is a
long-running service. If something errors here, stop: it will not get better once there is data.
4. Add a database — one command, not four hand-edits
python -m dbabrain.common.cli instance-add - <<'JSON'
{"server_id": "ACME-192-0-2-9", "db_type": "sqlserver", "ip": "192.0.2.9",
"port": 1433, "service_name": "MSSQLSERVER", "major_version": 16,
"site": "ACME", "environment": "prod", "username": "dba_monitor", "password": "<the password>"}
JSONIt writes the inventory record, the credential and the encrypted secret together; the password
never reaches the disk in the clear. Read it from stdin (-) rather than passing it inline, or the
password is in your shell history and in argv.
Three fields fail in ways that do not name themselves:
service_nameis a label, not a database. Metric collection connects tomasteron SQL Server, always. Naming a database here fails every target withCannot open database (4060).major_versionpicks the query variant. Wrong version, wrong SQL, confusing errors.default_credential_nameis a reference, not a password.
Adding it is all there is: enabled defaults on and the flags cascade
enabled → metrics → reports → alerts, so the instance is collected and appears on the fleet
inventory, its own metrics page, the index report and SLA with no second switch. To keep one
registered but off the reports, say "reports": {"enabled": false} — that keeps it collected.
For an OS-only host (no database), add cmd_access with method: "ssh" or "winrm", a
credential_name, and auth_type stated explicitly — it defaults to key. method: "local"
with a remote host reports the local machine's CPU under that host's name, and is refused.
python -m dbabrain.common.cli list-targets '{}' # what is registered
python -m dbabrain.common.cli check-secret '{}' # can each credential actually authenticate
python -m dbabrain.metrics.cli --config config.json collect --dry-run
python -m dbabrain.metrics.cli --config config.json collect5. Start the daemon
Start-Process -FilePath ".venv\Scripts\dbabrain.exe" `
-ArgumentList "daemon","--config","config.json" `
-WorkingDirectory (Get-Location) -WindowStyle HiddenSet timezone in config.json to your own zone before this. It decides what a time_window's
from_hour/to_hour mean, and the default is UTC — on a +07 estate that puts the heavy nightly
metrics (DATABASE_CHECKDB, MAINTENANCE_INDEX_*, OS_REBOOT_PENDING) in the middle of the
working day.
The reports and the console come up on http://<host>:8080/report_dba/ and /dbabrain/.
6. Telegram — the bot, its groups, and who may command it
# 1. the token, straight into the encrypted store - stdin only, never inline
python -m dbabrain.common.cli secret-set - <<'JSON'
{"ref": "TELEGRAM_BOT_TOKEN", "value": "<token from BotFather>"}
JSON
# 2. who the token belongs to
python -m dbabrain.telegram.cli --config config.json bot-info
# 3. add the bot to your groups as an ADMIN, post one message in each, then discover them
python -m dbabrain.telegram.cli --config config.json save-updates
# 4. give each discovered group a level, and yourself the level that may run commands
python -m dbabrain.telegram.cli --config config.json group-level --group -1001234567890 --level 40
python -m dbabrain.telegram.cli --config config.json user-level --user @you --level 100
# 5. prove the routing before trusting it - `route` takes the level as a positional argument
python -m dbabrain.telegram.cli --config config.json route warning
python -m dbabrain.telegram.cli --config config.json send-message --chat-id -1001234567890 --text "hello"A non-admin bot cannot read group messages unless privacy mode is off — that is the usual reason
save-updates finds nothing. Alerts ship on; nothing can be sent before a token exists and a
group has a level, so storing the token is the switch. The explicit level_chat_map wins over a
group's own notify_level, so change both or neither.
Never type a password into a bot command line. A command line is stored — in Telegram's history
and in this node's tables. Answer secret prompts at the prompt (they are stored masked) or use a
secret_ref.
7. Backups
Backups are declared in data/restore_config.json under backups, each with its jobs and a
cleanup_retention in seconds — the field is required, because a backup directory nobody prunes
fills a disk and "keep forever" should be something somebody wrote down.
python -m dbabrain.backup_restore.cli --config config.json list-backups # what is configured
python -m dbabrain.backup_restore.cli --config config.json backup # run what is due
python -m dbabrain.backup_restore.cli --config config.json prune-backups # apply retentionOne backup from a self-contained spec, without configuring anything:
python -m dbabrain.common.cli backup-database @request.json
python -m dbabrain.common.cli list-backup-files @request.json # full / diff / log, per engine8. Restore, and the drill that proves a backup is real
Restores are declared beside the backups under restores. A restore is how you learn a backup is a
backup rather than a file.
python -m dbabrain.backup_restore.cli --config config.json restore-latest # newest FULL, with recovery
python -m dbabrain.backup_restore.cli --config config.json restore-workflow # copy, restore, then clean up
python -m dbabrain.backup_restore.cli --config config.json restore-workflow --restore-id <id> --point-in-time "2026-09-25 12:00:00 +07:00"A physical restore carries the source's logins with it. After a drill the target answers to the source's password, so the credential you stored for the target goes stale — re-point it or rotate it, and expect that the first collection after a drill fails until you do.
Both halves run on the schedule as APP-BACKUP-RESTORE; an install with nothing configured reports
"nothing configured" and finishes done.
9. Check what you built
python -m dbabrain.common.cli self-status '{}' # this node, and the URLs it serves
python -m dbabrain.reports.cli --config config.json inventory-workflow --days 7 --beauty 1
python -m dbabrain.sla.cli --config config.json validateThe fleet page should list every instance you registered, each row linking to its own metrics page and — for SQL Server targets, once the nightly index metric has run — its index report.
How it is configured
Everything is JSON you own. A new threshold, target, route, schedule or severity belongs in
data/*.json, never as a literal in Python — the design assumes the person affected by a setting
can read it, change it, and be reviewed on the change.
config.json → where runtime output goes, and which declaration files to read
data/*.json → what to run, monitor, report and deliver
secrets/ → the plaintext source of the encrypted secret store (git-ignored)
assets/ → the SQL and scripts that implement itEvery configuration file has a *.example.json beside it, complete enough to copy, rename and
edit, with a notes array explaining what it decides and why.
The tool finds its configuration by a stated order, not by where its code sits on disk:
DBABRAIN_HOME, then the working directory if it holds data/ or config.json, then the package
location. That is what makes an installed copy work, and it is why standing in an example
directory is enough to run against it.
Secrets
Passwords and tokens live encrypted in data/encrypted_secret_text.json — PBKDF2-HMAC-SHA256 over
a per-file salt, sealed with Fernet. The passphrase is supplied at run time and is never written to
disk, a log, or the store. Configuration names a reference; the value is resolved from the
environment first and the encrypted store second, so an organisation with an external secret
manager never has to use the built-in one.
A request carrying a password is passed on stdin, never as a command-line word — argv is world-readable in the process table.
See docs/security.md, which also covers the least-privilege login the
toolkit needs on each engine, the audit trail, and running with no outbound network access.
How it is put together
Sixteen components - eleven apps and five shared layers - and rules about who may call whom, four of them below - with a guard test beside each rule, because a diagram describes what someone intended and a test describes what is true this morning.
commonmay not be imported — it is only ever run as a CLI.libmay not run a CLI — it is only ever imported. No app imports another app. No shared layer imports an app.
See docs/architecture.md.
Documentation
Start here | |
pip and Docker, the engine extras, the ODBC and Oracle prerequisites | |
From | |
Where configuration lives, and what every file decides | |
Secrets, least privilege, the audit trail, air-gapped operation | |
The components, the layers, and the rules that keep them apart | |
Worked configurations you can copy whole | |
The pages a real estate publishes, scrubbed — what the output actually looks like |
Component reference | |
Store backends, schema, migration, troubleshooting | |
Log scopes, files, and archive behaviour | |
Scheduling, time windows, timeouts, key forwarding | |
The metric catalogue per engine, and least-privilege setup | |
SQL task configuration, parameters, and execution | |
Report creation, schedules, and finding delivery | |
Delivery, bot commands, and permissions | |
Backup, restore, verification, and history | |
Objectives, indicators, and error budgets | |
Lab provisioning, HA topologies, and delegated workflows | |
Build, deploy, and watching the toolkit itself | |
Serving reports, the stable | |
The shared operations layer, command by command | |
The pure rules layer, the purity guarantee, and the module index | |
The one client of | |
dbabrain as an MCP server for Claude Desktop and Claude Code | |
Every rule the project keeps, numbered, with the test that guards it |
Project | |
How to contribute, and the rules that exist because something broke | |
Reporting a vulnerability | |
What changed, written for someone deciding whether to upgrade | |
Tests
The suite is offline: no database, no network, no delivery. That is why it runs anywhere and why you can refactor with it.
.venv/bin/python -m pytest tests -q # full suite
.venv/bin/python -m pytest tests/test_<area>.py -q # while developingTests read as prose — a module docstring explaining why the behaviour matters, then test names that are sentences.
Contact: investors, sponsors and developers welcome
DBA Brain is free, open source, and maintained by one person - and open to people who want to build
it further together. Investors and sponsors: talk about investment, partnership or sponsorship.
Developers: engines, metrics, reports, fixes - read CONTRIBUTING.md and open
an issue or a pull request, or write first. Get in touch directly:
Website | |
Phone | +84 888 783 789 (0888 783 789) |
For bugs and feature requests, please use GitHub issues. For a security problem, follow
SECURITY.md rather than email.
License
Apache License 2.0. See NOTICE.
Available Tools
94 toolsapp-command-setBDestructiveInspect
Change one scheduled app command's schedule or state, field by field.
Inputs: request (required). Returns: result
backup-databaseADestructiveInspect
Run one backup (full, diff or log) on the host the database runs on, and report whether it really completed.
Inputs: request (required). Returns: result
backup-stopBDestructiveInspect
Stop one running backup on its host: its process tree first, then its database sessions.
Inputs: request (required). Returns: result
build-showcaseADestructiveInspect
Copy the published HTML reports into a folder with every estate identifier replaced by a stable fake one, for showing to outsiders.
Inputs: request. Returns: result
check-configARead-onlyInspect
Check this node's config files, from config alone (connecting nowhere) - check objects: required fields and values against the reference this version ships; references: pointers from one file into another that land nowhere; credentials: every target resolves a login. To prove a password really works, use check-secret.
Inputs: request (required). Returns: result
check-identifiersARead-onlyInspect
Scan a folder tree for this estate's real identifiers (addresses, server_ids, credentials, people) before files are shared or published.
Inputs: request. Returns: result
check-secretARead-onlyInspect
Prove stored secrets by using them: log in to the host or database each one belongs to and report which authenticate.
Inputs: request. Returns: result
check-secret-literalsBRead-onlyInspect
Scan a folder tree for secret values from this node's store written in plain text.
Inputs: request. Returns: result
copy-filesADestructiveInspect
Copy named files from one host to another directly (host to host, nothing removed) - the backup repository copy, optionally encrypted on the way.
Inputs: request (required). Returns: result
copy-schemaADestructiveInspect
Reproduce one SQL Server schema from one instance on another - tables, indexes, constraints, modules, data of catalogue tables - printing the plan unless plan is false.
Inputs: request. Returns: result
create-db-dockerADestructiveInspect
Build one lab database instance in Docker (PostgreSQL, MySQL, SQL Server, Oracle), here or on an Ubuntu host over SSH.
Inputs: request (required). Returns: result
create-table-from-xlsxCDestructiveInspect
Load a spreadsheet or CSV into a new table on one server.
Inputs: request. Returns: result
credential-removeADestructiveInspect
Remove one login from users.json by its credential_name - a plan unless apply. The instance itself goes by instance-remove.
Inputs: request (required). Returns: result
db-activityARead-onlyInspect
Show what a server runs now: running requests, who blocks whom, current waits, and the top queries since their plans were cached.
Inputs: request. Returns: result
db-statusARead-onlyInspect
Check one instance's state at the depth asked - reachable, each database queryable - with one answer shape whatever the engine; a real statement is run, not just a state column read.
Inputs: request. Returns: result
delete-empty-foldersADestructiveInspect
Delete a list of folders, each only if it is empty (hidden entries count), deepest first; never recursive, and the first not deleted stops the list.
Inputs: request (required). Returns: result
delete-fileADestructiveInspect
Delete one stray file by force, inside a folder it must be under. For files whose name, bytes and sha256 must match a record first, use delete-verified-files.
Inputs: request (required). Returns: result
delete-verified-filesADestructiveInspect
Delete a list of files, each only if its name, size and sha256 on the host match the request; no wildcards, each inside its required folder, and the first that does not match stops the list. A one-item list deletes one file.
Inputs: request (required). Returns: result
describe-objectARead-onlyInspect
Explain what a config object's fields mean - a shared block (time_window, notify, cmd_access ...) or a whole record (backup_entry, sql_command, db_instance ...).
Inputs: request. Returns: result
disable-jobADestructiveInspect
Disable one SQL Server Agent job so its schedule stops firing - an emergency action, confirmed and with a reason.
Inputs: request. Returns: result
due-checkARead-onlyInspect
Say whether a schedule would run now and, if not, why - evaluated by the same rule the scheduler uses.
Inputs: request. Returns: result
encrypt-fileADestructiveInspect
Encrypt one file with age where it lies on the repository host, for a key's public half.
Inputs: request (required). Returns: result
encrypt-secretADestructiveInspect
Encrypt the plaintext secret file into the encrypted store this node reads; run it after every edit of the plaintext file.
Inputs: request. Returns: result
entry-removeADestructiveInspect
Remove one record from any data/*.json list, found by matching fields - a plan unless apply. For an instance or a login, instance-remove and credential-remove also clear what points at it.
Inputs: request (required). Returns: result
export-dataADestructiveInspect
Write this node's whole configuration (optionally its secrets and assets) to one bundle file, for import-data on another machine.
Inputs: request. Returns: result
fetch-fileADestructiveInspect
Copy one named file from a host to this node. For a packed backup archive whose SHA-256 must match at both ends use pull-file; host to host, relay-file.
Inputs: request. Returns: result
file-checksumARead-onlyInspect
Hash files on the host that holds them (or on this node) and return one sha256 each.
Inputs: request. Returns: result
finish-stagingADestructiveInspect
After the backup files have travelled (copy-files), give each its source's times and open the staging folder to the engine that restores from it.
Inputs: request (required). Returns: result
guideADestructiveInspect
Print this build's operating guide for agents and operators, or write it as AGENTS.md.
Inputs: request. Returns: result
host-factsBRead-onlyInspect
Read one host's state - OS, uptime, CPU, memory, disks - and the state of the services named; changes nothing.
Inputs: request. Returns: result
host-restartADestructiveInspect
Restart a whole host and prove it came back with its named services running.
Inputs: request. Returns: result
host-serviceADestructiveInspect
Start, stop or restart named services on a host and wait for the state asked. To restart the whole machine use host-restart.
Inputs: request. Returns: result
import-dataADestructiveInspect
Apply a bundle written by export-data to a tool root, so this machine runs the same estate - a plan when plan_only.
Inputs: request. Returns: result
initADestructiveInspect
Create a new dbabrain tool root in a directory: config, a SQLite store, an empty inventory and the files to edit next; nothing is overwritten without force.
Inputs: request. Returns: result
instance-activeADestructiveInspect
Switch one registered instance on or off for every app at once (its active flag); nothing is removed.
Inputs: request (required). Returns: result
instance-addBDestructiveInspect
Register a new database instance and its login in this node's inventory (db_instances.json, users.json).
Inputs: request (required). Returns: result
instance-removeADestructiveInspect
Remove one server's record from db_instances.json - a plan unless apply. To remove only its login use credential-remove; any other list record, entry-remove.
Inputs: request (required). Returns: result
inventory-summaryADestructiveInspect
Render the inventory's dated *-summary.md (every instance, its engine and state), optionally merging a health overlay into the inventory JSON first.
Inputs: request. Returns: result
key-requestADestructiveInspect
Get or renew this node's dbabrain key: an email sign-in on dbabrain.dev approved in a browser; the new key is kept in the encrypted store, replacing any old one.
Inputs: request. Returns: result
key-statusARead-onlyInspect
Read this node's dbabrain key offline (holder, expiry) and ask dbabrain.dev whether it is still good.
Inputs: request. Returns: result
kill-spidADestructiveInspect
Kill one SQL Server session by its spid - an emergency action, confirmed and with a reason.
Inputs: request. Returns: result
lift-exampleBDestructiveInspect
Copy one config file into its shipped *.example.json, with this estate's values replaced.
Inputs: request (required). Returns: result
list-backup-filesARead-onlyInspect
List the backup files a directory holds, by database and kind (full, diff, log) with their times - action list; or prune-plan: which of them a retention rule would remove (a plan only, nothing is deleted).
Inputs: request (required). Returns: result
list-filesARead-onlyInspect
List every entry under a folder on a host - kind, bytes, modified time - without hashing. For backup files by database and kind use list-backup-files; on a Windows share, smb-list.
Inputs: request (required). Returns: result
list-objectsARead-onlyInspect
List what an instance holds, with the state the engine reports - kind databases (online, restoring, read-only ...), schemas of one database, or jobs of the instance's own scheduler (SQL Server Agent, Oracle's scheduler, pg_cron) and whether each is enabled.
Inputs: request (required). Returns: result
list-targetsARead-onlyInspect
List every server this node can address - its server_id, engine, host and whether it is active. Start here: every other tool names a server by this server_id.
Inputs: request. Returns: result
metric-batchBDestructiveInspect
Run one target's metric items one after another and return each raw answer - the metrics app's own execution step.
Inputs: request (required). Returns: result
metric-envBDestructiveInspect
Set or remove the inputs a collector script reads for one instance (a folder, a service list, a port) in its metrics.collector_env.
Inputs: request (required). Returns: result
metric-severityBDestructiveInspect
Remap how one metric's statuses are graded for one instance (for example warning -> ok), one remap or a list of them.
Inputs: request. Returns: result
metric-toggleADestructiveInspect
Switch a metric, a collector type or all metrics on or off for one instance.
Inputs: request (required). Returns: result
move-db-dockerBDestructiveInspect
Move one lab database Docker instance, data included, to another host.
Inputs: request (required). Returns: result
object-sourceBRead-onlyInspect
Return the definition of a procedure, function, view or trigger by name (on Oracle also a package or type).
Inputs: request. Returns: result
pack-backupBDestructiveInspect
Pack a backup folder (or a list of its files) into one tar or zip on the host that holds it, hashed there - so a backup set travels as one file (then pull-file / push-file).
Inputs: request. Returns: result
pack-filesADestructiveInspect
Pack named files on a host into one archive and return its SHA-256 - files you name one by one. For a whole backup folder use pack-backup.
Inputs: request. Returns: result
prepare-stagingADestructiveInspect
Make a restore's staging folder ready and say which backup files still have to travel there; copies and removes nothing.
Inputs: request. Returns: result
probe-hostBRead-onlyInspect
Probe a host for its management ports (SSH, WinRM, RDP ...) to see how it can be reached.
Inputs: request. Returns: result
pull-fileADestructiveInspect
Download one packed backup archive from a host to this node, hashed on both sides; a mismatch is refused. Any other single file goes by fetch-file.
Inputs: request. Returns: result
push-fileADestructiveInspect
Upload one packed backup archive from this node to a host, hashed on both sides; a mismatch is refused. Any other single file goes by send-file.
Inputs: request. Returns: result
query-planARead-onlyInspect
Show one statement's estimated plan without running it: SQL Server SHOWPLAN_XML with cost, top operators and missing indexes; PostgreSQL and MySQL EXPLAIN without ANALYZE.
Inputs: request. Returns: result
read-fileARead-onlyInspect
Read one small file on a host, its bytes proven by size and sha256.
Inputs: request (required). Returns: result
relay-fileADestructiveInspect
Copy one file from one host to another through this node, its SHA-256 checked at both ends.
Inputs: request. Returns: result
remote-credential-addADestructiveInspect
Register an OS login (SSH or WinRM) for a host, and the cmd_access that uses it, so run-cmd and the host-* tools can reach that host.
Inputs: request (required). Returns: result
report-server-removeADestructiveInspect
Take one server off the report's canonical inventory (not off db_instances.json) - a plan unless apply.
Inputs: request (required). Returns: result
restoreADestructiveInspect
Run one restore step on one engine - step full (on PostgreSQL the base backup chain), diff (differential or incremental on top of the full) or log (logs, WAL or archived logs, to the latest or a point in time). Run them in that order, then verify-restore.
Inputs: request (required). Returns: result
restore-keyBDestructiveInspect
Import the backup-encryption certificate an encrypted SQL Server backup can only be restored with - before restore step full.
Inputs: request. Returns: result
restore-metadataADestructiveInspect
Apply named .sql metadata files (logins, roles, permissions, jobs) to a restored SQL Server instance, in the order given. For a whole exported bundle use sqlserver-replay-instance.
Inputs: request. Returns: result
rotate-passwordADestructiveInspect
Change database logins' passwords on the server and in the secret store as one step: change, re-authenticate on a new connection, then store.
Inputs: request. Returns: result
run-cmdADestructiveInspect
Run one shell command or script on a host over its OS login (SSH, or WinRM on Windows) and return its output.
Inputs: request. Returns: result
run-sqlADestructiveInspect
Run one SELECT on one server and return its rows - checked to be a single SELECT, always rolled back. To change data use run-sql-write; for a sqlcmd batch (GO, RESTORE ...) on SQL Server, run-sqlcmd. Runs with the rights of the login this node stores for the server (users.json: the instance's default_credential_name, or credential_name): what that login may do, this may do - DML and DDL included. The statement is checked to be one SELECT and the batch is rolled back, but the check reads text and does not bound what the login can do; a login with read rights only is what keeps it to reading. The SQL is the target engine's: SQL Server T-SQL https://learn.microsoft.com/sql/t-sql/language-reference, PostgreSQL https://www.postgresql.org/docs/current/sql-commands.html, Oracle https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/, MySQL https://dev.mysql.com/doc/refman/8.4/en/sql-statements.html.
Inputs: request. Returns: result
run-sqlcmdADestructiveInspect
Run one sqlcmd batch where the SQL Server runs (on its host or in its container) - for T-SQL that needs sqlcmd, such as GO-separated scripts. A single statement goes by run-sql or run-sql-write.
Inputs: request (required). Returns: result
run-sql-writeADestructiveInspect
Run one statement that changes data or schema on one server (INSERT, UPDATE, DELETE, DDL), kept only when the request says commit (or autocommit) true - otherwise rolled back. A SELECT goes by run-sql.
The SQL is the target engine's: SQL Server T-SQL https://learn.microsoft.com/sql/t-sql/language-reference, PostgreSQL https://www.postgresql.org/docs/current/sql-commands.html, Oracle https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/, MySQL https://dev.mysql.com/doc/refman/8.4/en/sql-statements.html.
Inputs: request. Returns: result
seal-ssh-keyBDestructiveInspect
Seal an SSH private key (or generate and seal one) at its path, its passphrase kept as a secret ref.
Inputs: request (required). Returns: result
self-statusARead-onlyInspect
Report what this dbabrain installation is - version, host, role, CPU, memory, disk and the app commands it schedules - read from the machine itself, without the store.
Inputs: request. Returns: result
send-fileADestructiveInspect
Copy one named file from this node to a host. For a packed backup archive whose SHA-256 must match at both ends use push-file.
Inputs: request. Returns: result
shrink-logADestructiveInspect
Shrink one SQL Server database's transaction log file - an emergency action, confirmed and with a reason.
Inputs: request. Returns: result
smb-credentialBDestructiveInspect
Store the login Windows uses for a host's share paths (cmdkey), for the smb-* tools.
Inputs: request. Returns: result
smb-deleteADestructiveInspect
Delete one file on a Windows share - one exact path, never a pattern.
Inputs: request. Returns: result
smb-getBDestructiveInspect
Download one file from a Windows share to a local path.
Inputs: request. Returns: result
smb-listBRead-onlyInspect
List every file under a folder of a Windows share, with size and modified time.
Inputs: request. Returns: result
sql-command-addADestructiveInspect
Register a SQL task's script - what it runs - by name. Then give it a server and a schedule with sql-target-add.
Inputs: request (required). Returns: result
sqlserver-apply-cuADestructiveInspect
Apply a staged cumulative update to one SQL Server instance; run sqlserver-cu-check with check precheck first and check build after.
Inputs: request. Returns: result
sqlserver-cu-checkARead-onlyInspect
Check one SQL Server instance around a cumulative update, read-only - check precheck: whether it is safe to patch now (host, installer, SQL gates, maintenance window); build: whether it reached the build the update should give.
Inputs: request (required). Returns: result
sqlserver-export-instanceBDestructiveInspect
Export an instance's server-level metadata (logins, roles, permissions, linked servers, Agent jobs) as SQL files and a manifest - read-only.
Inputs: request. Returns: result
sqlserver-replay-instanceADestructiveInspect
Apply an exported metadata bundle (from sqlserver-export-instance) to a target instance, in dependency order.
Inputs: request. Returns: result
sqlserver-verify-instanceBRead-onlyInspect
Compare a target instance with an exported metadata bundle and list what differs - read-only.
Inputs: request. Returns: result
sql-target-addADestructiveInspect
Give a registered SQL task (sql-command-add) a server to run on, when to run, and where its output and alerts go.
Inputs: request (required). Returns: result
standardize-field-namesADestructiveInspect
Rewrite this node's data/*.json to the standard field names (enabled -> active, db_name -> database_name ...) - a plan unless dry_run is false.
Inputs: request. Returns: result
start-jobADestructiveInspect
Start one SQL Server Agent job now - an emergency action, confirmed and with a reason.
Inputs: request. Returns: result
store-queryARead-onlyInspect
Run one read-only SELECT on dbabrain's own runtime store (job runs, metrics, the backup catalog, SLA), always rolled back. The tables are listed by store-schema.
Inputs: sql (required), max_rows. Returns: result
store-schemaARead-onlyInspect
List the tables of dbabrain's own runtime store (job runs, metrics, the backup catalog, SLA) and their columns, or one table's columns with types.
Inputs: table. Returns: result
table-infoBRead-onlyInspect
Describe one table: its columns (type, length, nullable, identity, computed, default), its indexes (keys, included columns, filter, unique, disabled), row count and reserved MB.
Inputs: request. Returns: result
trace-sessionARead-onlyInspect
List every open transaction on one SQL Server with the application user behind it (decoded from context_info), filtered by age, session or blocking.
Inputs: request. Returns: result
upgrade-configADestructiveInspect
Move this node's config files to this version's shapes after an upgrade - a plan unless dry_run is false.
Inputs: request. Returns: result
verify-restoreARead-onlyInspect
Check that restored databases are really usable - not left RESTORING, MOUNTED or in recovery - by asking the engine.
Inputs: request (required). Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 94 tools
Almost every description explicitly scopes itself and points to the sibling tool to use instead (run-sql vs run-sql-write vs run-sqlcmd, fetch-file vs pull-file vs relay-file vs push-file, delete-file vs delete-verified-files, instance-remove vs credential-remove vs entry-remove). A few clusters still blur under load — copy-files / send-file / push-file / relay-file, and the four delete-* variants — but the boundaries are stated, not inferred.
Uniformly kebab-case, with a small set of stable domain prefixes (smb-, sqlserver-, metric-, store-, host-, db-, instance-, credential-). The one deviation is verb/noun ordering: mostly verb-first (list-files, check-config) but some noun-first records (host-facts, table-info, db-status, object-source) and single-word tools (init, guide, restore). Predictable enough to guess at.
94 tools is far past any practical selection surface for an agent, well beyond the 25+ heavy threshold. The scope genuinely is broad (four engines, Docker labs, host/OS, SMB, backups, restores, patching, metrics, config, secrets), so most tools do earn their place — but 94 is a discovery and misselection burden regardless.
Coverage is unusually deep: inventory lifecycle, backup/restore/verify chains, CU patching, metadata export/replay/compare, file transfer with hashing, SMB, secrets, config upgrade and staging. Gaps are minor — no instance-update (register/remove only), and Agent jobs can be started/disabled but not created or edited.
Maintenance
Related MCP Connectors
Database backups and an AI agent safety net: restore points, health, audited changes as you.
Database evidence for AI agents: plans, workload, topology. SQL Server, Postgres, MySQL, Cassandra.
PostgreSQL, MySQL, and SQL Server in one session. 26 read-only MCP tools for AI agents.
Safe, read-only Postgres and MySQL access for AI agents. Audit log + column-level controls.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to interact with PostgreSQL databases through schema intelligence, query execution, and DBA tooling including index analysis and health monitoring. Features configurable access levels and audit logging for secure database operations.MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to interact with and manage multiple database types (PostgreSQL, MySQL, SQLite, SQL Server, MongoDB, Redis) through natural language, supporting query analysis, schema management, data analysis, backup/restore, and security analysis.6 npm2MIT
- FlicenseAqualityDmaintenanceExposes any Microsoft SQL Server database to AI agents with multi-database support, keyword lookup, free SELECT queries, and three transport modes (stdio/SSE/Streamable HTTP).4-
- FlicenseNot gradedqualityDmaintenanceEnables AI agents to inspect schemas, analyze performance, check security, and troubleshoot SQL Server 2019+ databases through a safe, controlled interface.-