# database-mcp

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.

- MCP server · `type=mcp` · Claude Code, Codex, Cursor, GitHub Copilot, Windsurf (Devin Desktop), Cline, Zed, Gemini CLI · ★ 5 repo stars
- Author: cocaxcode
- License: MIT · policy=link-only · description only; the file stays with the author
- Source: https://github.com/cocaxcode/database-mcp
- Updated: 2026-08-26
- Security check: automated, 2026-11-17 (text) — no signs of malicious code found.
- HTML: https://affpapa.org/en/nevibecode/mcp/database-mcp

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

## Requirements
- Needs: Node.js (commands run via npx)

## Install

### Claude Code (native platform)

**Platform CLI**
```bash
claude mcp add database-mcp -- npx -y @cocaxcode/database-mcp
```

### Codex

**Platform CLI**
```bash
codex mcp add database-mcp -- npx -y @cocaxcode/database-mcp
```

### Cursor

**Config file**
File `.cursor/mcp.json`:
```json
{
    "mcpServers": {
        "database-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "@cocaxcode/database-mcp"
            ]
        }
    }
}
```

### GitHub Copilot

**Config file**
File `.vscode/mcp.json`:
```json
{
    "servers": {
        "database-mcp": {
            "type": "stdio",
            "command": "npx",
            "args": [
                "-y",
                "@cocaxcode/database-mcp"
            ]
        }
    }
}
```

### Gemini CLI

**Platform CLI**
```bash
gemini mcp add database-mcp npx -y @cocaxcode/database-mcp
```

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

## Similar
- [sql-database-assistant](https://affpapa.org/en/nevibecode/skills/sql-database-assistant.md) — skill · 727 installs
- [database-optimizer](https://affpapa.org/en/nevibecode/skills/httpsgithubcomjeffallan-database-optimizer.md) — skill · 6500 installs
- [relational-database-mcp-cloudbase](https://affpapa.org/en/nevibecode/skills/relational-database-mcp-cloudbase.md) — skill · 962 installs
- [database-schema-designer](https://affpapa.org/en/nevibecode/skills/borghei-database-schema-designer.md) — skill · 183 installs
- [database-schema-design](https://affpapa.org/en/nevibecode/skills/database-schema-design.md) — skill · 599 installs
- [database-migration-management](https://affpapa.org/en/nevibecode/skills/database-migration-management.md) — skill · 505 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
