DB Explorer — Claude Code MCP server: SQL and setup
A read-only MCP server for exploring schemas, running safe SQL, and reviewing database plans across PostgreSQL, MySQL, and SQLite.
claude mcp add db-explorer-mcp-server -e DATABASE_URL=<DATABASE_URL> -- uvx db-explorer-mcp-serverWhat DB Explorer does
DB Explorer lets an MCP client inspect a relational database and ask for read-only query results. Its tools cover schema exploration, query execution, execution-plan analysis, schema checks, index suggestions, and migration review through explore_schema, execute_query, explain_query, validate_schema, suggest_index, migration_context, and validate_migration.
The server parses model-generated SQL before it reaches the database. It accepts one read-only SELECT, rejects write operations, and caps returned rows. Migration checks inspect up/down changes without applying them. Local connections use stdio; remote deployments can use streamable HTTP with bearer-token authentication.
Python 3.11+ and uv are required. Set DATABASE_URL for PostgreSQL, MySQL, or SQLite. The server does not make its own LLM API calls, so no API key is needed for its reasoning. Without Python 3.11+ and uv, it will not start.
What it helps with
- inspect a relational database schema
- run a guarded SELECT query
- read a SQL execution plan
- identify possible index additions
- review a migration without applying it
Example prompts for the agent
- Show me the database schema and explain the relationships between its tables.
- Run a read-only SELECT to find orders from the requested period.
- Inspect this query plan and suggest an index when the plan supports one.
How to install DB Explorer
Platform CLI
claude mcp add db-explorer-mcp-server -e DATABASE_URL=<DATABASE_URL> -- uvx db-explorer-mcp-serverReplace <…> with your own values. uvx runs the command named after the package; if the README names another one, use uvx --from db-explorer-mcp-server <command>
Platform CLI
codex mcp add db-explorer --env DATABASE_URL=<DATABASE_URL> -- uvx db-explorer-mcp-serverReplace <…> with your own values. uvx runs the command named after the package; if the README names another one, use uvx --from db-explorer-mcp-server <command>
Config file
{
"mcpServers": {
"db-explorer": {
"command": "uvx",
"args": [
"db-explorer-mcp-server"
],
"env": {
"DATABASE_URL": "<DATABASE_URL>"
}
}
}
}Replace <…> with your own values. uvx runs the command named after the package; if the README names another one, use uvx --from db-explorer-mcp-server <command>
Config file
{
"servers": {
"db-explorer": {
"type": "stdio",
"command": "uvx",
"args": [
"db-explorer-mcp-server"
],
"env": {
"DATABASE_URL": "<DATABASE_URL>"
}
}
}
}Replace <…> with your own values. uvx runs the command named after the package; if the README names another one, use uvx --from db-explorer-mcp-server <command>
Platform CLI
gemini mcp add -e DATABASE_URL=<DATABASE_URL> db-explorer uvx db-explorer-mcp-serverReplace <…> with your own values. uvx runs the command named after the package; if the README names another one, use uvx --from db-explorer-mcp-server <command>
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 DB Explorer
How do I install DB Explorer in Claude Code?
Run claude mcp add db-explorer-mcp-server -e DATABASE_URL=<DATABASE_URL> -- uvx db-explorer-mcp-server. Then connect the server in Claude Code.
What does DB Explorer do?
It gives an agent read-only access to schema details, SELECT results, execution plans, index suggestions, and migration checks. Write operations are rejected.
Which databases does DB Explorer support?
It supports PostgreSQL, MySQL, and SQLite. The connection is provided through DATABASE_URL.