MCP DB
MCP Database Server with natural language SQL queries
What is MCP DB?
MCP DB is a Model Context Protocol (MCP) server that allows AI assistants like Claude, Cursor, and VS Code to mcp database server with natural language sql queries
MCP Database Server with natural language SQL queries
This server falls under the Databases category on MCPgee, the world's largest MCP server directory with 33,000+ servers.
Features
- MCP Database Server with natural language SQL queries
Use Cases
Maintainer
Works with
Installation
Manual Installation
npx mcp-dbConfiguration
Configuration Details
claude_desktop_config.json
Performance
Response Metrics
Resource Usage
How to Set Up and Use MCP DB
mcp-db is a Python MCP server that enables AI assistants to query relational databases using natural language, translating conversational requests into SQL and returning structured results. It supports PostgreSQL, MySQL, and SQLite through async database drivers, and exposes tools to list tables, describe schemas, sample data, and execute natural language queries — making database exploration and reporting accessible without writing SQL manually.
Prerequisites
- Python 3.11 or higher installed, or Docker for the container-based setup
- A running PostgreSQL, MySQL, or SQLite database
- DATABASE_URL connection string or individual DB_HOST, DB_PORT, DB_USER, DB_PASSWORD, DB_NAME variables
- An MCP-compatible AI client such as Claude Desktop or VS Code with MCP extension
Clone the repository
Clone the mcp-db-server repository. Docker Compose is the recommended way to run the server with all dependencies bundled.
git clone https://github.com/Souhar-dya/mcp-db-server.git
cd mcp-db-serverConfigure the database connection
Set your database connection via the DATABASE_URL environment variable. The server supports PostgreSQL (postgresql+asyncpg://), MySQL (mysql+aiomysql://), and SQLite (sqlite+aiosqlite://).
# PostgreSQL example
export DATABASE_URL="postgresql+asyncpg://user:password@localhost:5432/mydb"
# MySQL example
export DATABASE_URL="mysql+aiomysql://user:password@localhost:3306/mydb"
# SQLite example
export DATABASE_URL="sqlite+aiosqlite:////path/to/database.db"Run with Docker Compose (recommended)
Use Docker Compose to start the server with all dependencies. The container exposes the MCP server on port 8000.
docker-compose up --buildOr run locally with Python
For local development without Docker, install dependencies and run the server directly with Python.
pip install -r requirements.txt
python -m app.serverConfigure VS Code or Claude Desktop to connect
Add the server to your MCP client configuration. The Docker approach uses the published image; adjust DATABASE_URL to point to your database.
{
"servers": {
"mcp-db-server": {
"type": "stdio",
"command": "docker",
"args": [
"run", "--rm", "-i",
"-e", "DATABASE_URL=postgresql+asyncpg://user:pass@host:5432/mydb",
"souhardyak/mcp-db-server:1.3.1"
]
}
}
}MCP DB Examples
Client configuration (VS Code / Claude Desktop)
Configuration using the Docker image, passing the DATABASE_URL for your PostgreSQL database.
{
"servers": {
"mcp-db-server": {
"type": "stdio",
"command": "docker",
"args": [
"run", "--rm", "-i",
"-e", "DATABASE_URL=postgresql+asyncpg://user:pass@localhost:5432/mydb",
"souhardyak/mcp-db-server:1.3.1"
]
}
}
}Prompts to try
Natural language database queries that the server translates into SQL and executes against your connected database.
- "Show all customers"
- "Count orders by status"
- "Top 5 customers by total order amount"
- "Show recent orders from the last week"
- "List all tables in the database"
- "Describe the schema of the users table"Troubleshooting MCP DB
Connection refused or cannot reach database host
When running in Docker, the database host 'localhost' inside the container refers to the container itself, not your machine. Use your machine's actual IP or host.docker.internal (on macOS/Windows) in the DATABASE_URL.
Server starts but natural language queries return errors
Verify the database driver in DATABASE_URL matches your database type: postgresql+asyncpg for PostgreSQL, mysql+aiomysql for MySQL, sqlite+aiosqlite for SQLite. Install the matching async driver if running locally.
Health check endpoint returns unhealthy
Access GET /health to see the current status. If the database connection is failing, check that the database is running and accessible at the configured host and port, and that the credentials in DATABASE_URL are correct.
Frequently Asked Questions about MCP DB
What is MCP DB?
MCP DB is a Model Context Protocol (MCP) server that mcp database server with natural language sql queries It connects AI assistants to external tools and data sources through a standardized interface.
How do I install MCP DB?
Follow the installation instructions on the MCP DB GitHub repository. Clone the repo, install dependencies, and add the server config to your AI client.
Which AI clients work with MCP DB?
MCP DB works with all major MCP-compatible AI clients including Claude Desktop, Claude Code, Cursor, VS Code (GitHub Copilot), Windsurf, and Cline.
Is MCP DB free to use?
Yes, MCP DB is open source and available under the NOASSERTION license. You can use it freely in both personal and commercial projects.
MCP DB Alternatives — Similar Databases Servers
Looking for alternatives to MCP DB? Here are other popular databases servers you can use with Claude, Cursor, and VS Code.
Excelize
★ 20.6kGo language library for reading and writing Microsoft Excel™ (XLAM / XLSM / XLSX / XLTM / XLTX) spreadsheets
MCP Toolbox for Databases
★ 15.3kOpen source MCP server specializing in easy, fast, and secure tools for Databases.
DBHub
★ 2.8kA universal database gateway MCP server that enables AI assistants to connect to and query multiple databases (PostgreSQL, MySQL, MariaDB, SQL Server, SQLite) with support for schema exploration, SQL execution, and secure connections via SSH tunnels.
Tabularis
★ 2.1kA lightweight, cross-platform database client for developers. Supports MySQL, PostgreSQL and SQLite. Hackable with plugins. Built for speed, security, and aesthetics.
Postgres AI Guide
★ 1.7kMCP server and Claude plugin for Postgres skills and documentation. Helps AI coding tools generate better PostgreSQL code.
Anyquery
★ 1.7k🏎️ 🏠 ☁️ - Query more than 40 apps with one binary using SQL. It can also connect to your PostgreSQL, MySQL, or SQLite compatible database. Local-first and private by design.
Browse More Databases MCP Servers
Explore all databases servers available in the MCPgee directory. Each server includes setup guides for Claude, Cursor, and VS Code.
Set Up MCP DB in Your Editor
Choose your AI client for step-by-step setup instructions.
Quick Config Preview
Add this to your claude_desktop_config.json or .cursor/mcp.json
Ready to use MCP DB?
Browse our complete directory of 33,000+ MCP servers, read setup guides for your editor, and start building with the Model Context Protocol.