dbmcp — database MCP server for Claude Code
Connect an AI agent to MySQL, MariaDB, PostgreSQL, or SQLite to inspect database structure and run queries from your development setup.
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.1What dbmcp 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.
What it helps with
- 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 for the agent
- List the tables and views in the connected database.
- Run a read query to show the latest records.
- Use
explainQueryto inspect this query plan.
How to install dbmcp
Platform CLI
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.1Replace <…> with your own values
Platform CLI
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.1Replace <…> with your own values
Config file
{
"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
Config file
{
"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
Platform CLI
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.1Replace <…> with your own values
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 dbmcp
How do I install dbmcp in Claude Code?
Run `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`. This setup uses Docker.
What does dbmcp do?
It connects an AI agent to MySQL, MariaDB, PostgreSQL, or SQLite through MCP. The agent can inspect database structure and run queries.
Can dbmcp prevent database writes?
Yes. In read-only mode, the server hides tools for writing, creating databases, and dropping databases or tables.