# DB Explorer

A read-only MCP server for exploring schemas, running safe SQL, and reviewing database plans across PostgreSQL, MySQL, and SQLite.

- MCP server · `type=mcp` · Claude Code, Codex, Cursor, GitHub Copilot, Windsurf (Devin Desktop), Cline, Zed, Gemini CLI · ★ 7
- Author: AYUSH-148
- License: MIT · policy=link-only · description only; the file stays with the author
- Source: https://github.com/AYUSH-148/DB-Explorer-MCP
- Updated: 2026-10-20
- HTML: https://affpapa.org/en/nevibecode/mcp/db-explorer

## What it 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.

## Requirements
- Needs: Python and uv (commands run via uvx)
- Environment variables: `DATABASE_URL` — keys and tokens: ask the human for the values, never commit them or put them in shared files.

## Install

### Claude Code (native platform)

**Platform CLI**
```bash
claude mcp add db-explorer-mcp-server -e DATABASE_URL=<DATABASE_URL> -- uvx db-explorer-mcp-server
```
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>

### Codex

**Platform CLI**
```bash
codex mcp add db-explorer --env DATABASE_URL=<DATABASE_URL> -- uvx db-explorer-mcp-server
```
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>

### Cursor

**Config file**
File `.cursor/mcp.json`:
```json
{
    "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>

### GitHub Copilot

**Config file**
File `.vscode/mcp.json`:
```json
{
    "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>

### Gemini CLI

**Platform CLI**
```bash
gemini mcp add -e DATABASE_URL=<DATABASE_URL> db-explorer uvx db-explorer-mcp-server
```
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>

## When to use it
- 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
- 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.

## Similar
- [Faucet](https://affpapa.org/en/nevibecode/mcp/faucet.md) — MCP server · ★ 166
- [sql-database-assistant](https://affpapa.org/en/nevibecode/skills/sql-database-assistant.md) — skill · 727 installs
- [DBHub](https://affpapa.org/en/nevibecode/mcp/dbhub.md) — MCP server · ★ 3730
- [whodb](https://affpapa.org/en/nevibecode/plugins/whodb.md) — plugin · ★ 5042
- [safedb-mcp](https://affpapa.org/en/nevibecode/mcp/safedb-mcp.md) — MCP server · ★ 9
- [sql-code-review](https://affpapa.org/en/nevibecode/skills/sql-code-review.md) — skill · 14060 installs

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
