# dbmole

> dbmole is an open-source MCP server for databases. PostgreSQL and MySQL for agents that add their own connections at runtime, via SSH. 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/ed-smartass/dbmole-mcp/tree/HEAD/packages/dbmole-mcp
- **MCP Registry name:** io.github.ed-smartass/dbmole-mcp
- **Categories:** databases
- **Listing updated:** 2026-11-16

## About

dbmole lets an agent manage database connections itself. Tell it to connect to a staging replica through a bastion host in readonly mode and it calls `add_connection`; the entry is saved to a per-project `.dbmole.json` or a global store. Both are re-read on every tool call, so a change made by the agent, by you in an editor or by another session applies immediately with no client config edits or restarts.

One server covers PostgreSQL and MySQL with any number of named connections. SSH tunnels support password, key or agent auth with host keys checked against known_hosts or a pinned fingerprint, and TLS verifies certificate and hostname, including through the tunnel. Readonly is enforced by the database session itself, calls have timeouts, and results are capped at 40 KB so a wide SELECT cannot flood the context.

It needs Node.js 22 or newer and runs over stdio via npx, a Claude Desktop .mcpb bundle or Docker. A sister project covers Elasticsearch.

## Features

- **Runtime connections:** Agents add, edit and remove connections via tools.
- **Hot reload:** Config files are re-read on every call.
- **SSH tunnels:** Password, key or agent auth with host key checks.
- **Verified TLS:** Full certificate and hostname verification.
- **Enforced readonly:** Readonly applies at the database session.
- **Result cap:** Results are capped at 40 KB.

## Good for

- Query a staging replica through a bastion
- Inspect schemas across several databases
- Keep readonly access for safe exploration
- Share project-scoped connections

## Install

### Claude Code (Terminal)

```sh
claude mcp add dbmole-mcp -- npx -y dbmole-mcp
```

### Claude Desktop (claude_desktop_config.json)

```json
{
  "mcpServers": {
    "dbmole-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "dbmole-mcp"
      ]
    }
  }
}
```

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

```json
{
  "mcpServers": {
    "dbmole-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "dbmole-mcp"
      ]
    }
  }
}
```

### VS Code (.vscode/mcp.json)

```json
{
  "servers": {
    "dbmole-mcp": {
      "type": "stdio",
      "command": "npx",
      "args": [
        "-y",
        "dbmole-mcp"
      ]
    }
  }
}
```

### Windsurf (~/.codeium/windsurf/mcp_config.json)

```json
{
  "mcpServers": {
    "dbmole-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "dbmole-mcp"
      ]
    }
  }
}
```

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

```json
{
  "mcpServers": {
    "dbmole-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "dbmole-mcp"
      ]
    }
  }
}
```

## Tools

- `add_connection`: Adds a named database connection at runtime

## FAQ

### Which databases are supported?

PostgreSQL and MySQL.

### Where are connections stored?

In a per-project .dbmole.json or a global store.

### How is readonly enforced?

By the database session.

### What Node.js version is needed?

22 or newer.

### Is dbmole free?

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

### How do I add dbmole to Claude Code?

Run this command in your terminal: claude mcp add dbmole-mcp -- npx -y dbmole-mcp

### What are the best alternatives to dbmole?

The closest alternatives to dbmole are Midplane, PlatypusDB, Lorebase, Sovaria and model2data studio.

## Alternatives

- [Midplane](https://ai-powered.com/mcp/midplane): Midplane is an open-source MCP server for databases.
- [PlatypusDB](https://ai-powered.com/mcp/platypusdb): PlatypusDB is an open-source MCP server for databases.
- [Lorebase](https://ai-powered.com/mcp/lorebase): Lorebase is an open-source MCP server for knowledge and memory.
- [Sovaria](https://ai-powered.com/mcp/sovaria): Sovaria is a freemium MCP server for databases.
- [model2data studio](https://ai-powered.com/mcp/model2data-studio): model2data studio is a freemium MCP server for databases.
- [semlayer](https://ai-powered.com/mcp/semlayer): semlayer is a free MCP server for databases.
- [bricksentry](https://ai-powered.com/mcp/bricksentry): bricksentry is an open-source MCP server for databases.
- [MCP Toolbox for Databases](https://ai-powered.com/mcp/mcp-toolbox-for-databases-2): MCP Toolbox for Databases is an open-source MCP server for databases.

---
Source: https://ai-powered.com/mcp/dbmole
