# DB Explorer

> DB Explorer is an open-source MCP server for databases. Read-only SQL access to PostgreSQL, MySQL and SQLite with schema, EXPLAIN and index advice. It runs locally on your machine and is started by your AI client.

- **Kind:** MCP server
- **Pricing:** Open source
- **Platforms:** CLI, Self-hosted
- **Repository:** https://github.com/ayush-148/db-explorer-mcp
- **MCP Registry name:** io.github.AYUSH-148/db-explorer-mcp-server
- **Categories:** [databases](https://ai-powered.com/categories/databases), [developer tools](https://ai-powered.com/categories/developer-tools)
- **Listing updated:** 2026-11-23

## About

DB Explorer is built around one idea: the SQL your assistant writes is untrusted, so it is parsed rather than pattern-matched. The safety layer uses a SQL parser to accept only a single read-only SELECT, with no comments, a denylist and a row cap, so writes are blocked structurally and a rejected query never reaches the database. The server itself makes no LLM calls and needs no API key.

It exposes seven tools covering schema exploration, query execution, execution plans, schema health, index suggestions and migration review; migration files are parsed and never executed. It runs locally over stdio or remotely over streamable HTTP with bearer tokens. Set `DATABASE_URL` to a SQLAlchemy URL; with it unset, a bundled demo database opens.

The README reports 336 tests plus 26 run against real PostgreSQL and MySQL in CI, and an evaluation in which Claude completed 14 of 14 database tasks with no failed tool calls. It installs from PyPI with `uvx db-explorer-mcp-server` and needs Python 3.11 or later.

## Features

- **SELECT-only safety:** Parses SQL and rejects anything but one read-only SELECT, with a row cap.
- **Schema exploration:** Inspects tables, columns and relationships across three database engines.
- **Execution plans:** Runs EXPLAIN on a query to show how the database will run it.
- **Index suggestions:** Recommends indexes based on the schema and queries.
- **Migration review:** Reads up and down migrations without executing them.
- **Local or remote:** Runs over stdio, or over streamable HTTP with bearer tokens.

## Good for

- Let an assistant explore a production replica without write risk
- Audit a schema for design problems
- Get index advice for a slow query
- Review a migration before applying it

## Install

### Claude Code: Add with the CLI (Terminal)

```sh
claude mcp add db-explorer-mcp-server --env DATABASE_URL='<DATABASE_URL>' -- uvx db-explorer-mcp-server
```

Add --scope user to use it in every project, or --scope project to share it in .mcp.json.

### Claude Code: Or share it with your project (.mcp.json)

```json
{
  "mcpServers": {
    "db-explorer-mcp-server": {
      "command": "uvx",
      "args": [
        "db-explorer-mcp-server"
      ],
      "env": {
        "DATABASE_URL": "<DATABASE_URL>"
      }
    }
  }
}
```

### Claude Desktop (claude_desktop_config.json)

```json
{
  "mcpServers": {
    "db-explorer-mcp-server": {
      "command": "uvx",
      "args": [
        "db-explorer-mcp-server"
      ],
      "env": {
        "DATABASE_URL": "<DATABASE_URL>"
      }
    }
  }
}
```

Settings → Developer → Edit Config, then quit and reopen Claude Desktop.

### Cursor (~/.cursor/mcp.json)

```json
{
  "mcpServers": {
    "db-explorer-mcp-server": {
      "command": "uvx",
      "args": [
        "db-explorer-mcp-server"
      ],
      "env": {
        "DATABASE_URL": "<DATABASE_URL>"
      }
    }
  }
}
```

Use .cursor/mcp.json in a project to share it with the project.

### VS Code (~/.copilot/mcp-config.json)

```json
{
  "mcpServers": {
    "db-explorer-mcp-server": {
      "type": "stdio",
      "command": "uvx",
      "args": [
        "db-explorer-mcp-server"
      ],
      "env": {
        "DATABASE_URL": "<DATABASE_URL>"
      }
    }
  }
}
```

Or put the same entry in .mcp.json at your workspace root to share it.

### Codex: Add with the CLI (Terminal)

```sh
codex mcp add db-explorer-mcp-server --env DATABASE_URL='<DATABASE_URL>' -- uvx db-explorer-mcp-server
```

### Codex: Or add to config.toml (~/.codex/config.toml)

```toml
[mcp_servers.db-explorer-mcp-server]
command = "uvx"
args = ["db-explorer-mcp-server"]
env = { DATABASE_URL = "<DATABASE_URL>" }
```

### Gemini CLI and Antigravity: Gemini CLI (~/.gemini/settings.json)

```json
{
  "mcpServers": {
    "db-explorer-mcp-server": {
      "command": "uvx",
      "args": [
        "db-explorer-mcp-server"
      ],
      "env": {
        "DATABASE_URL": "<DATABASE_URL>"
      }
    }
  }
}
```

Or run: gemini mcp add -s user -e DATABASE_URL='<DATABASE_URL>' db-explorer-mcp-server uvx -- db-explorer-mcp-server

### Gemini CLI and Antigravity: Antigravity (~/.gemini/config/mcp_config.json)

```json
{
  "mcpServers": {
    "db-explorer-mcp-server": {
      "command": "uvx",
      "args": [
        "db-explorer-mcp-server"
      ],
      "env": {
        "DATABASE_URL": "<DATABASE_URL>"
      }
    }
  }
}
```

Use .agents/mcp_config.json to add it to one workspace only.

### Devin Desktop (~/.config/devin/mcp_config.json)

```json
{
  "mcpServers": {
    "db-explorer-mcp-server": {
      "command": "uvx",
      "args": [
        "db-explorer-mcp-server"
      ],
      "env": {
        "DATABASE_URL": "<DATABASE_URL>"
      }
    }
  }
}
```

On Windows the file is %APPDATA%\\devin\\mcp_config.json. Use .devin/mcp_config.json to share it with a project.

### Cline (cline_mcp_settings.json)

```json
{
  "mcpServers": {
    "db-explorer-mcp-server": {
      "command": "uvx",
      "args": [
        "db-explorer-mcp-server"
      ],
      "env": {
        "DATABASE_URL": "<DATABASE_URL>"
      }
    }
  }
}
```

Open it from the MCP Servers icon → Configure → Configure MCP Servers.

### Zed (Zed settings.json)

```json
{
  "context_servers": {
    "db-explorer-mcp-server": {
      "command": "uvx",
      "args": [
        "db-explorer-mcp-server"
      ],
      "env": {
        "DATABASE_URL": "<DATABASE_URL>"
      }
    }
  }
}
```

Open it with zed: open settings file. Merge context_servers into the settings you already have.

### JetBrains AI Assistant and Junie: AI Assistant (Settings → Tools → AI Assistant → Model Context Protocol (MCP) → Add)

```json
{
  "mcpServers": {
    "db-explorer-mcp-server": {
      "command": "uvx",
      "args": [
        "db-explorer-mcp-server"
      ],
      "env": {
        "DATABASE_URL": "<DATABASE_URL>"
      }
    }
  }
}
```

The AI Assistant docs only show command and args. If the env block is ignored, use Junie for this server.

### JetBrains AI Assistant and Junie: Junie (~/.junie/mcp/mcp.json)

```json
{
  "mcpServers": {
    "db-explorer-mcp-server": {
      "command": "uvx",
      "args": [
        "db-explorer-mcp-server"
      ],
      "env": {
        "DATABASE_URL": "<DATABASE_URL>"
      }
    }
  }
}
```

Use .junie/mcp/mcp.json to share it with a project.

### Kiro (~/.kiro/settings/mcp.json)

```json
{
  "mcpServers": {
    "db-explorer-mcp-server": {
      "command": "uvx",
      "args": [
        "db-explorer-mcp-server"
      ],
      "env": {
        "DATABASE_URL": "<DATABASE_URL>"
      }
    }
  }
}
```

Use .kiro/settings/mcp.json to add it to one workspace only.

### Other clients (your client's MCP settings (most use this shape))

```json
{
  "mcpServers": {
    "db-explorer-mcp-server": {
      "command": "uvx",
      "args": [
        "db-explorer-mcp-server"
      ],
      "env": {
        "DATABASE_URL": "<DATABASE_URL>"
      }
    }
  }
}
```

## Tools

From the tool list in its README, going by the names, 1 of 7 tools changes data; 3 names don't say. From the server's own tool labels and tool names; not verified by us.

- `explore_schema`: Inspect database structure
- `execute_query` (name suggests: changes): Run a validated read-only SELECT
- `explain_query` (name suggests: reads): Show the execution plan for a query
- `validate_schema` (name suggests: reads): Check a schema for problems
- `suggest_index`: Recommend indexes
- `migration_context`: Provide context for reviewing a migration
- `validate_migration` (name suggests: reads): Review a migration without executing it

## FAQ

### Can DB Explorer modify my data?

No. Only a single read-only SELECT is accepted, enforced at parser level.

### Which databases work?

PostgreSQL, MySQL and SQLite, through SQLAlchemy.

### Does DB Explorer need an API key?

No. The server makes no LLM calls; reasoning happens in your MCP client.

### How do I install DB Explorer?

Run uvx db-explorer-mcp-server, or add it with claude mcp add and set DATABASE_URL.

### Is DB Explorer free?

Yes. DB Explorer is open source, so you can use and self-host it for free.

### How do I add DB Explorer to Claude Code?

Run this command in your terminal: claude mcp add db-explorer-mcp-server --env DATABASE_URL='<DATABASE_URL>' -- uvx db-explorer-mcp-server

### What are the best alternatives to DB Explorer?

The closest alternatives to DB Explorer are REA, Context7, Chrome DevTools MCP, Codebase Memory and GitHub.

## Where this comes from

- Description: written from the project's README.
- Install steps: from the official MCP Registry entry.

## Alternatives

- [REA](https://ai-powered.com/mcp/rea): REA is an open-source MCP server for developer tools.
- [Context7](https://ai-powered.com/mcp/context7): Context7 is a freemium MCP server for developer tools.
- [Chrome DevTools MCP](https://ai-powered.com/mcp/chrome-devtools-mcp-2): Chrome DevTools MCP is an open-source MCP server for browser automation.
- [Codebase Memory](https://ai-powered.com/mcp/codebase-memory): Codebase Memory is an open-source MCP server for knowledge and memory.
- [GitHub](https://ai-powered.com/mcp/github): GitHub is an open-source MCP server for developer tools.
- [Serena MCP: the IDE for your agent](https://ai-powered.com/mcp/serena-mcp-the-ide-for-your-agent): Serena MCP: the IDE for your agent is an open-source MCP server for developer tools.
- [awesome-mcp-servers](https://ai-powered.com/mcp/awesome-mcp-servers-2): awesome-mcp-servers is an open-source MCP server for developer tools.
- [XERJ](https://ai-powered.com/mcp/xerj): XERJ is an open-source MCP server for knowledge and memory.

---
Source: https://ai-powered.com/mcp/db-explorer
