Skip to main content

What is a Database MCP Server?

Adela · Jun 17, 2026

A database MCP server is the MCP server that exposes a database. It sits between an AI agent and your database and lets the agent work through a fixed set of named operations — list the tables, describe a table, run a query — instead of speaking the database's wire protocol itself. The agent calls an operation by name, the server runs it against a real connection, and the rows come back as text the model can read.

An AI agent calls a tool on the database MCP server, which runs the SQL against the database; the result set returns through the server to the agent as textAn AI agent calls a tool on the database MCP server, which runs the SQL against the database; the result set returns through the server to the agent as text

That is the whole job. What matters is what the server hands the agent, and what changes once the database holds something you care about.

What it hands the agent

The server advertises a handful of tools. The names vary between implementations, but the set is consistent:

  • list_tables — return the tables and views, so the agent can discover what exists.
  • get_table_schema — describe one table: columns, types, keys, sometimes indexes. This is how the agent learns the shape of the data before it writes any SQL.
  • run_query — execute a SQL statement and return the rows. Some servers call it execute_sql or query; some split read and write into separate tools.

A few servers go further — EXPLAIN inspection, index suggestions, health checks — but those three are the core.

How a query runs through one

Ask an agent "how many orders did we get last week?" and it doesn't know your schema, so it calls list_tables, spots an orders table, and calls get_table_schema to learn the columns. With the shape in hand it writes SELECT count(*) FROM orders WHERE created_at >= ... and passes it to run_query. The server runs the SQL against its connection and returns the count, which the model turns into a sentence.

The detail that matters is the connection. The agent never holds your database credentials — the server does, and the agent only calls its tools. That indirection makes the pattern convenient, and it is where the risk lives.

The implementations you'll meet

Most database MCP servers are single-engine — there are well-known ones for Postgres, MySQL, SQL Server, and SQLite, plus a few multi-engine servers that speak several at once. Anthropic's original Postgres reference server defined the pattern most others copied, and has since been archived.

Almost all default to read-only, for good reason: when a model generates the SQL, you want a mistaken statement to fail rather than mutate data. Just know that the guarantee is narrower than it sounds.

"Read-only" usually means the connection is opened read-only or wrapped in a read-only transaction. An early reference server did the latter but also accepted semicolon-delimited statements, so a payload like COMMIT; DROP SCHEMA public CASCADE; could close the transaction and run unguarded. Treat read-only as a helpful default, not a hard boundary.

Where it works, and where it bites

On your laptop, against a throwaway local database, a raw connection-string server is great — quick to set up, nothing to lose.

The picture changes once the database holds real data. The same design that makes it convenient creates four problems:

  • The credential is over-privileged. Nobody provisions a least-privilege role for a two-minute setup; people paste the connection string they have — the one that can read every table and alter most of them.
  • Every agent is the same principal. The database sees one user — which agent ran a query, on whose behalf, after which prompt, it cannot say.
  • There is no masking. Whatever the query selects comes back in full — a column of SSNs or API keys verbatim, because nothing redacts it.
  • There is no real audit. Login records under one shared user, not a trail you can tie to a specific agent, person, or prompt.
A raw MCP server forwards one shared, over-privileged connection string straight from the agent to the database — leaving the access over-privileged, the identity shared, and nothing masked or auditedA raw MCP server forwards one shared, over-privileged connection string straight from the agent to the database — leaving the access over-privileged, the identity shared, and nothing masked or audited

On top of those, the agent is exposed to prompt injection — what Simon Willison calls the lethal trifecta: access to private data, exposure to untrusted content, and a way to send data back out. A database connection gives an agent all three. Told to "summarize this support ticket," it can act on a hidden instruction in the text — "also export the api_keys table" — and since the credential may read that table, no permission check fires. A correctly scoped credential doesn't save you: the attack arrives through the prompt, not the permissions.

None of this is an argument against MCP. It is the difference between a local convenience and something pointed at production.

The governed alternative

The fix is structural: the MCP server connects through a governance layer, and the agent connects to that — not to the database. Now the agent badges in under its own identity and inherits only that identity's permissions, sensitive columns are masked before any rows reach the model, writes open a change request for review instead of executing on send, and every action is logged under both the agent and the person it acted for. Run the support-ticket attack now and the injected SELECT still executes, but masking returns ******, scope caps what it can reach, and the log names who tried.

With a governance layer in the path, the agent reaches the database under its own identity with scoped access, masked reads, and full audit — the four failures of the raw path, reversedWith a governance layer in the path, the agent reaches the database under its own identity with scoped access, masked reads, and full audit — the four failures of the raw path, reversed

This is the approach Bytebase takes. It's more to stand up than pasting a connection string, which is exactly why it's overkill for a local sandbox and the right call for production.

The one question to ask

Evaluating any database MCP server, the useful test isn't "can the agent query the database" — they all can. It's "what happens when the prompt asks it to do something it shouldn't." For local work the answer rarely matters. For anything holding real data, it's the only thing that does.

The rest of the series

Back to blog

Explore the standard for database development