Skip to main content
MCP server CX Codex

MCP Database Server — Claude Code MCP server: query SQL in plain words

An MCP server that connects PostgreSQL and MySQL to your agent and turns plain-language questions into SQL. Handy when you want to inspect data without writing queries by hand.

Install into Claude Code · Platform CLI All methods and platforms ↓
claude mcp add --env DATABASE_URL=<DATABASE_URL> --transport stdio mcp-database-server -- docker run -i --rm -e DATABASE_URL docker.io/souhardyak/mcp-db-server:1.3.1
Open on GitHub

What MCP Database Server does

The server runs a FastAPI app and hands your agent table listings, a table's schema, sample rows, and query execution. A question like "top 5 customers by total order amount" goes through HuggingFace transformers, which produces the SQL and a structured result.

Operations are read-only, queries get validated, and result size is capped. Since version 1.4.0 the database HTTP routes require an X-API-Key header; only /health stays public. Without MCP_API_KEY set, those routes are disabled, so plan for the key up front. The same release binds to 127.0.0.1 by default, checks table names against the real schema, and supports sslmode=require for asyncpg.

Docker Compose is the shortest path: clone the repo, generate a key with openssl rand -hex 32, bring the containers up. Running locally needs Python 3.11+ and the packages from requirements.txt. A demo e-commerce database ships with the project, which is a reasonable way to test the wiring before pointing it at a real database.

What it helps with

  • inspect table contents without opening psql
  • pull a table schema into the agent chat
  • phrase a SQL query in words and see the rows
  • grab a few sample rows to sanity-check data
  • wire PostgreSQL or MySQL into an agent without writing code

Example prompts for the agent

  • List the tables in the database and how many columns each has
  • Describe the schema of the customers table
  • Count orders grouped by status

How to install MCP Database Server

Platform CLI

claude mcp add --env DATABASE_URL=<DATABASE_URL> --transport stdio mcp-database-server -- docker run -i --rm -e DATABASE_URL docker.io/souhardyak/mcp-db-server:1.3.1

Replace <…> with your own values

Step by step, with commands for each platform: How to add an MCP server to Claude Code, Codex, Cursor, VS Code, Gemini CLI and more

Questions about MCP Database Server

How do I install MCP Database Server in Claude Code?

Run `claude mcp add --env DATABASE_URL=<DATABASE_URL> --transport stdio mcp-database-server -- docker run -i --rm -e DATABASE_URL docker.io/souhardyak/mcp-db-server:1.3.1`, replacing the placeholder with your own connection string.

What does MCP Database Server do?

It gives an agent access to PostgreSQL and MySQL: table listings, schemas, sample data, and query execution. Plain-language questions become SQL.

Which databases are supported?

PostgreSQL and MySQL. The DATABASE_URL uses the asyncpg driver for PostgreSQL and pymysql for MySQL.

Similar MCP servers

All MCP servers for Data and databases →

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor