# dbmcp

Connect an AI agent to MySQL, MariaDB, PostgreSQL, or SQLite to inspect database structure and run queries from your development setup.

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

## What it does

dbmcp exposes tools for browsing databases, tables, views, and other schema objects, along with tools for reading queries. It supports MySQL, MariaDB, PostgreSQL, and SQLite, and includes `explainQuery` for examining query plans. Read-only mode hides tools that write or delete data.

Run the server over stdio or HTTP. An SSH tunnel can connect to MySQL, MariaDB, or PostgreSQL through a bastion host. The Claude Code install command below starts a Docker image, so Docker is required for that setup. When HTTP listens on an external interface, set `HTTP_AUTH_TOKEN`.

## Requirements
- Needs: Docker
- Environment variables: `HTTP_HOST`, `HTTP_PORT`, `HTTP_ALLOWED_ORIGINS`, `HTTP_ALLOWED_HOSTS`, `HTTP_AUTH_TOKEN` — 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 --env HTTP_HOST=<HTTP_HOST> --env HTTP_PORT=<HTTP_PORT> --env HTTP_ALLOWED_ORIGINS=<HTTP_ALLOWED_ORIGINS> --env HTTP_ALLOWED_HOSTS=<HTTP_ALLOWED_HOSTS> --env HTTP_AUTH_TOKEN=<HTTP_AUTH_TOKEN> --transport stdio dbmcp -- docker run -i --rm -e HTTP_HOST -e HTTP_PORT -e HTTP_ALLOWED_ORIGINS -e HTTP_ALLOWED_HOSTS -e HTTP_AUTH_TOKEN ghcr.io/haymon-ai/dbmcp:0.15.1
```
Replace <…> with your own values

### Codex

**Platform CLI**
```bash
codex mcp add dbmcp --env HTTP_HOST=<HTTP_HOST> --env HTTP_PORT=<HTTP_PORT> --env HTTP_ALLOWED_ORIGINS=<HTTP_ALLOWED_ORIGINS> --env HTTP_ALLOWED_HOSTS=<HTTP_ALLOWED_HOSTS> --env HTTP_AUTH_TOKEN=<HTTP_AUTH_TOKEN> -- docker run -i --rm -e HTTP_HOST -e HTTP_PORT -e HTTP_ALLOWED_ORIGINS -e HTTP_ALLOWED_HOSTS -e HTTP_AUTH_TOKEN ghcr.io/haymon-ai/dbmcp:0.15.1
```
Replace <…> with your own values

### Cursor

**Config file**
File `.cursor/mcp.json`:
```json
{
    "mcpServers": {
        "dbmcp": {
            "command": "docker",
            "args": [
                "run",
                "-i",
                "--rm",
                "-e",
                "HTTP_HOST",
                "-e",
                "HTTP_PORT",
                "-e",
                "HTTP_ALLOWED_ORIGINS",
                "-e",
                "HTTP_ALLOWED_HOSTS",
                "-e",
                "HTTP_AUTH_TOKEN",
                "ghcr.io/haymon-ai/dbmcp:0.15.1"
            ],
            "env": {
                "HTTP_HOST": "<HTTP_HOST>",
                "HTTP_PORT": "<HTTP_PORT>",
                "HTTP_ALLOWED_ORIGINS": "<HTTP_ALLOWED_ORIGINS>",
                "HTTP_ALLOWED_HOSTS": "<HTTP_ALLOWED_HOSTS>",
                "HTTP_AUTH_TOKEN": "<HTTP_AUTH_TOKEN>"
            }
        }
    }
}
```
Replace <…> with your own values

### GitHub Copilot

**Config file**
File `.vscode/mcp.json`:
```json
{
    "servers": {
        "dbmcp": {
            "type": "stdio",
            "command": "docker",
            "args": [
                "run",
                "-i",
                "--rm",
                "-e",
                "HTTP_HOST",
                "-e",
                "HTTP_PORT",
                "-e",
                "HTTP_ALLOWED_ORIGINS",
                "-e",
                "HTTP_ALLOWED_HOSTS",
                "-e",
                "HTTP_AUTH_TOKEN",
                "ghcr.io/haymon-ai/dbmcp:0.15.1"
            ],
            "env": {
                "HTTP_HOST": "<HTTP_HOST>",
                "HTTP_PORT": "<HTTP_PORT>",
                "HTTP_ALLOWED_ORIGINS": "<HTTP_ALLOWED_ORIGINS>",
                "HTTP_ALLOWED_HOSTS": "<HTTP_ALLOWED_HOSTS>",
                "HTTP_AUTH_TOKEN": "<HTTP_AUTH_TOKEN>"
            }
        }
    }
}
```
Replace <…> with your own values

### Gemini CLI

**Platform CLI**
```bash
gemini mcp add -e HTTP_HOST=<HTTP_HOST> -e HTTP_PORT=<HTTP_PORT> -e HTTP_ALLOWED_ORIGINS=<HTTP_ALLOWED_ORIGINS> -e HTTP_ALLOWED_HOSTS=<HTTP_ALLOWED_HOSTS> -e HTTP_AUTH_TOKEN=<HTTP_AUTH_TOKEN> dbmcp docker run -i --rm -e HTTP_HOST -e HTTP_PORT -e HTTP_ALLOWED_ORIGINS -e HTTP_ALLOWED_HOSTS -e HTTP_AUTH_TOKEN ghcr.io/haymon-ai/dbmcp:0.15.1
```
Replace <…> with your own values

## When to use it
- inspect tables and other database objects
- read results from a SQL query
- examine a query execution plan
- restrict an agent from using write tools

## Example prompts
- List the tables and views in the connected database.
- Run a read query to show the latest records.
- Use `explainQuery` to inspect this query plan.

## Similar
- [World Monitor](https://affpapa.org/en/nevibecode/mcp/world-monitor.md) — MCP server · ★ 89408
- [Scrapling MCP Server](https://affpapa.org/en/nevibecode/mcp/scrapling-mcp-server.md) — MCP server · ★ 89433
- [MCP Toolbox for Databases](https://affpapa.org/en/nevibecode/mcp/googleapis-mcp-toolbox-for-databases.md) — MCP server · ★ 16717
- [PostHog MCP Server](https://affpapa.org/en/nevibecode/mcp/posthog-mcp-server.md) — MCP server · ★ 40409
- [dbx](https://affpapa.org/en/nevibecode/mcp/dbx.md) — MCP server · ★ 27669
- [Metabase](https://affpapa.org/en/nevibecode/mcp/metabase.md) — MCP server · ★ 49845

---
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
