database-mcp — Claude Code MCP server: what it does, how to install
database-mcp is a Claude Code MCP server that connects PostgreSQL, MySQL, and SQLite databases. It handles folder-scoped connection groups, pre-mutation snapshots, rollbacks, and query history.
MIT ★ 5 updated 2026-08-26
claude mcp add database-mcp -- npx -y @cocaxcode/database-mcpWhat database-mcp does
The server links database engines directly to the coding assistant without external cloud platforms. Credentials stay on the local machine. The assistant inspects schema structures through db://schema resources, identifies foreign keys, and generates SQL queries with proper table joins.
Every write operation creates a snapshot for rollback via reverse SQL. Destructive operations like bulk deletes require explicit confirmation before execution. The toolset also covers full database dumps, schema inspection, and execution history with timestamps.
Connections stay organized in groups tied to project directories, requiring Node.js 20 or higher to run via npx. The first connection in a group acts as the default, resetting active switches back after a session restart.
What it helps with
- inspect schemas and run SQL on PostgreSQL, MySQL, or SQLite
- generate queries with joins based on foreign keys
- roll back unintended row changes using reverse SQL
- isolate database connections per project directory
- dump database structure and data directly from chat
Example prompts for the agent
- Add a PostgreSQL connection for myapp on port 5432 with user admin in the backend group
- Fetch the latest 10 orders including the customer name
- Remove inactive users from the accounts table
How to install database-mcp
Platform CLI
claude mcp add database-mcp -- npx -y @cocaxcode/database-mcpPlatform CLI
codex mcp add database-mcp -- npx -y @cocaxcode/database-mcpConfig file
{
"mcpServers": {
"database-mcp": {
"command": "npx",
"args": [
"-y",
"@cocaxcode/database-mcp"
]
}
}
}Config file
{
"servers": {
"database-mcp": {
"type": "stdio",
"command": "npx",
"args": [
"-y",
"@cocaxcode/database-mcp"
]
}
}
}Platform CLI
gemini mcp add database-mcp npx -y @cocaxcode/database-mcpStep 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 database-mcp
How to install database-mcp in Claude Code?
Run claude mcp add database-mcp -- npx -y @cocaxcode/database-mcp in your terminal.
What does database-mcp do?
It provides tools for running SQL queries, reading table schemas, generating database dumps, and rolling back mutations.
What is required to run database-mcp?
The server requires Node.js 20 or newer alongside an accessible PostgreSQL, MySQL, or SQLite instance.