Database MCP

MCP Clients

Add dbmcp to Claude, Codex, VS Code, Cursor, and other MCP clients

Every MCP client keeps its server list in a different file under a different key. This page has a ready-to-paste entry for each one.

All examples launch dbmcp with npx -y @haymon-ai/dbmcp, which needs Node.js 18 or newer and no separate install (see npm). To run Docker or an installed binary instead, see Docker or installed binary.

The examples connect to MySQL with DBMCP_DB_BACKEND, DBMCP_DB_HOST, DBMCP_DB_USER, DBMCP_DB_PASSWORD, and DBMCP_DB_NAME. Replace the values with your own; every setting is listed in Configuration. An empty DBMCP_* value counts as unset, so a blank value falls back to the default.

One-click install

VS Code asks for the backend, host, user, password, and database name when you install. The password prompt hides its input.

Install in VS Code Install in VS Code Insiders

Cursor and LM Studio install placeholder values. Edit them in the client's mcp.json afterwards.

Add to Cursor Add to LM Studio

The Cursor and LM Studio buttons add this server:

{
  "command": "npx",
  "args": ["-y", "@haymon-ai/dbmcp"],
  "env": {
    "DBMCP_DB_BACKEND": "mysql",
    "DBMCP_DB_HOST": "127.0.0.1",
    "DBMCP_DB_USER": "root",
    "DBMCP_DB_PASSWORD": "change-me",
    "DBMCP_DB_NAME": "mydb"
  }
}

The VS Code buttons add the VS Code entry below, with an input for each DBMCP_DB_* value.

Claude Desktop

Open Settings → Developer → Edit Config, or edit the file directly:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json
claude_desktop_config.json
{
  "mcpServers": {
    "dbmcp": {
      "command": "npx",
      "args": ["-y", "@haymon-ai/dbmcp"],
      "env": {
        "DBMCP_DB_BACKEND": "mysql",
        "DBMCP_DB_HOST": "127.0.0.1",
        "DBMCP_DB_USER": "root",
        "DBMCP_DB_PASSWORD": "secret",
        "DBMCP_DB_NAME": "mydb"
      }
    }
  }
}

Quit Claude Desktop completely and start it again to load the change.

Claude Code

Add the server with claude mcp add. Options go before the server name, and the launch command follows --:

claude mcp add --env DBMCP_DB_BACKEND=mysql --env DBMCP_DB_HOST=127.0.0.1 \
  --env DBMCP_DB_USER=root --env DBMCP_DB_PASSWORD=secret --env DBMCP_DB_NAME=mydb \
  --transport stdio --scope user dbmcp -- npx -y @haymon-ai/dbmcp

Keep another option, such as --transport stdio, between the last --env and the name: otherwise --env reads the name as another KEY=value pair. --scope is local (default, this project only), project (writes .mcp.json), or user (all projects).

To share the server with your team, commit a .mcp.json and let each developer supply the password from their own environment with ${VAR} expansion:

.mcp.json
{
  "mcpServers": {
    "dbmcp": {
      "command": "npx",
      "args": ["-y", "@haymon-ai/dbmcp"],
      "env": {
        "DBMCP_DB_BACKEND": "mysql",
        "DBMCP_DB_USER": "root",
        "DBMCP_DB_PASSWORD": "${DBMCP_DB_PASSWORD}",
        "DBMCP_DB_NAME": "mydb"
      }
    }
  }
}

For a server you started with DBMCP_TRANSPORT=http:

claude mcp add --transport http dbmcp http://127.0.0.1:9001/mcp --header "Authorization: Bearer $DBMCP_TOKEN"

Codex

Add the server to ~/.codex/config.toml, or to .codex/config.toml in a trusted project:

~/.codex/config.toml
[mcp_servers.dbmcp]
command = "npx"
args = ["-y", "@haymon-ai/dbmcp"]
env = { DBMCP_DB_BACKEND = "mysql", DBMCP_DB_HOST = "127.0.0.1", DBMCP_DB_USER = "root", DBMCP_DB_NAME = "mydb" }
env_vars = ["DBMCP_DB_PASSWORD"]

env_vars forwards DBMCP_DB_PASSWORD from the environment Codex runs in, so the password stays out of the file. Or add the server from the command line:

codex mcp add dbmcp --env DBMCP_DB_BACKEND=mysql --env DBMCP_DB_USER=root \
  --env DBMCP_DB_PASSWORD=secret --env DBMCP_DB_NAME=mydb -- npx -y @haymon-ai/dbmcp

For a server you started with DBMCP_TRANSPORT=http, Codex reads the bearer token from the named environment variable:

~/.codex/config.toml
[mcp_servers.dbmcp]
url = "http://127.0.0.1:9001/mcp"
bearer_token_env_var = "DBMCP_TOKEN"

VS Code

Add the server to .vscode/mcp.json in your workspace, or to your user profile with MCP: Open User Configuration. VS Code uses servers, not mcpServers, and prompts for each ${input:...} value on first start:

.vscode/mcp.json
{
  "inputs": [
    {
      "type": "promptString",
      "id": "db-password",
      "description": "Database password",
      "password": true
    }
  ],
  "servers": {
    "dbmcp": {
      "type": "stdio",
      "command": "npx",
      "args": ["-y", "@haymon-ai/dbmcp"],
      "env": {
        "DBMCP_DB_BACKEND": "mysql",
        "DBMCP_DB_HOST": "127.0.0.1",
        "DBMCP_DB_USER": "root",
        "DBMCP_DB_PASSWORD": "${input:db-password}",
        "DBMCP_DB_NAME": "mydb"
      }
    }
  }
}

For a server you started with DBMCP_TRANSPORT=http:

.vscode/mcp.json
{
  "inputs": [
    {
      "type": "promptString",
      "id": "dbmcp-token",
      "description": "dbmcp bearer token",
      "password": true
    }
  ],
  "servers": {
    "dbmcp": {
      "type": "http",
      "url": "http://127.0.0.1:9001/mcp",
      "headers": { "Authorization": "Bearer ${input:dbmcp-token}" }
    }
  }
}

Cursor

Add the server to ~/.cursor/mcp.json (all projects) or .cursor/mcp.json (this project). ${env:NAME} reads a value from Cursor's environment:

~/.cursor/mcp.json
{
  "mcpServers": {
    "dbmcp": {
      "command": "npx",
      "args": ["-y", "@haymon-ai/dbmcp"],
      "env": {
        "DBMCP_DB_BACKEND": "mysql",
        "DBMCP_DB_HOST": "127.0.0.1",
        "DBMCP_DB_USER": "root",
        "DBMCP_DB_PASSWORD": "${env:DBMCP_DB_PASSWORD}",
        "DBMCP_DB_NAME": "mydb"
      }
    }
  }
}

For a server you started with DBMCP_TRANSPORT=http:

~/.cursor/mcp.json
{
  "mcpServers": {
    "dbmcp": {
      "url": "http://127.0.0.1:9001/mcp",
      "headers": { "Authorization": "Bearer ${env:DBMCP_TOKEN}" }
    }
  }
}

Windsurf (Devin Desktop)

Windsurf is now Devin Desktop. Add the server to ~/.config/devin/mcp_config.json (Windows: %APPDATA%\devin\mcp_config.json) or .devin/mcp_config.json in a project. Older Windsurf builds read ~/.codeium/windsurf/mcp_config.json with the same shape.

~/.config/devin/mcp_config.json
{
  "mcpServers": {
    "dbmcp": {
      "command": "npx",
      "args": ["-y", "@haymon-ai/dbmcp"],
      "env": {
        "DBMCP_DB_BACKEND": "mysql",
        "DBMCP_DB_HOST": "127.0.0.1",
        "DBMCP_DB_USER": "root",
        "DBMCP_DB_PASSWORD": "${env:DBMCP_DB_PASSWORD}",
        "DBMCP_DB_NAME": "mydb"
      }
    }
  }
}

For a server you started with DBMCP_TRANSPORT=http:

~/.config/devin/mcp_config.json
{
  "mcpServers": {
    "dbmcp": {
      "url": "http://127.0.0.1:9001/mcp",
      "headers": { "Authorization": "Bearer ${env:DBMCP_TOKEN}" }
    }
  }
}

Zed

Open your settings with zed: open settings file and add the server under context_servers:

settings.json
{
  "context_servers": {
    "dbmcp": {
      "command": "npx",
      "args": ["-y", "@haymon-ai/dbmcp"],
      "env": {
        "DBMCP_DB_BACKEND": "mysql",
        "DBMCP_DB_HOST": "127.0.0.1",
        "DBMCP_DB_USER": "root",
        "DBMCP_DB_PASSWORD": "secret",
        "DBMCP_DB_NAME": "mydb"
      }
    }
  }
}

For a server you started with DBMCP_TRANSPORT=http, set url and headers instead of command. Without an Authorization header, Zed starts an OAuth flow.

settings.json
{
  "context_servers": {
    "dbmcp": {
      "url": "http://127.0.0.1:9001/mcp",
      "headers": { "Authorization": "Bearer <token>" }
    }
  }
}

Gemini CLI

Add the server to ~/.gemini/settings.json (all projects) or .gemini/settings.json (this project):

~/.gemini/settings.json
{
  "mcpServers": {
    "dbmcp": {
      "command": "npx",
      "args": ["-y", "@haymon-ai/dbmcp"],
      "env": {
        "DBMCP_DB_BACKEND": "mysql",
        "DBMCP_DB_HOST": "127.0.0.1",
        "DBMCP_DB_USER": "root",
        "DBMCP_DB_PASSWORD": "$DBMCP_DB_PASSWORD",
        "DBMCP_DB_NAME": "mydb"
      }
    }
  }
}

Gemini CLI removes inherited environment variables whose names contain PASSWORD, TOKEN, SECRET, KEY, AUTH, or CREDENTIAL before it starts a server. Set DBMCP_DB_PASSWORD in the server's env, as above: an exported DBMCP_DB_PASSWORD alone never reaches dbmcp.

Or add the server from the command line (-s user for all projects):

gemini mcp add -s user -e DBMCP_DB_BACKEND=mysql -e DBMCP_DB_USER=root \
  -e DBMCP_DB_PASSWORD=secret -e DBMCP_DB_NAME=mydb dbmcp npx -y @haymon-ai/dbmcp

For a server you started with DBMCP_TRANSPORT=http, use httpUrl (url means SSE in Gemini CLI):

~/.gemini/settings.json
{
  "mcpServers": {
    "dbmcp": {
      "httpUrl": "http://127.0.0.1:9001/mcp",
      "headers": { "Authorization": "Bearer <token>" }
    }
  }
}

Goose

Run goose configure and choose Add Extension → Command-line Extension, with npx -y @haymon-ai/dbmcp as the command. Or edit ~/.config/goose/config.yaml (Windows: %APPDATA%\Block\goose\config\config.yaml):

~/.config/goose/config.yaml
extensions:
  dbmcp:
    type: stdio
    name: dbmcp
    enabled: true
    cmd: npx
    args: ["-y", "@haymon-ai/dbmcp"]
    envs:
      DBMCP_DB_BACKEND: mysql
      DBMCP_DB_HOST: 127.0.0.1
      DBMCP_DB_USER: root
      DBMCP_DB_PASSWORD: secret
      DBMCP_DB_NAME: mydb
    timeout: 300

JetBrains AI Assistant

Open Settings → Tools → AI Assistant → Model Context Protocol (MCP), click Add, and paste:

MCP server
{
  "mcpServers": {
    "dbmcp": {
      "command": "npx",
      "args": ["-y", "@haymon-ai/dbmcp"],
      "env": {
        "DBMCP_DB_BACKEND": "mysql",
        "DBMCP_DB_HOST": "127.0.0.1",
        "DBMCP_DB_USER": "root",
        "DBMCP_DB_PASSWORD": "secret",
        "DBMCP_DB_NAME": "mydb"
      }
    }
  }
}

Click Apply to start the server; OK alone does not.

LM Studio

Use the one-click button, or open the Program tab, choose Install → Edit mcp.json, and add:

mcp.json
{
  "mcpServers": {
    "dbmcp": {
      "command": "npx",
      "args": ["-y", "@haymon-ai/dbmcp"],
      "env": {
        "DBMCP_DB_BACKEND": "mysql",
        "DBMCP_DB_HOST": "127.0.0.1",
        "DBMCP_DB_USER": "root",
        "DBMCP_DB_PASSWORD": "secret",
        "DBMCP_DB_NAME": "mydb"
      }
    }
  }
}

Docker or installed binary

Every example above works with another launcher: change only command and args, and keep env.

With the binary from the install script on your PATH:

{
  "command": "dbmcp",
  "args": []
}

With Docker, pass each variable through with -e NAME (no value: Docker copies it from the env block). Use host.docker.internal to reach a database on your machine:

{
  "command": "docker",
  "args": [
    "run", "-i", "--rm",
    "-e", "DBMCP_DB_BACKEND",
    "-e", "DBMCP_DB_HOST",
    "-e", "DBMCP_DB_USER",
    "-e", "DBMCP_DB_PASSWORD",
    "-e", "DBMCP_DB_NAME",
    "ghcr.io/haymon-ai/dbmcp"
  ],
  "env": {
    "DBMCP_DB_BACKEND": "mysql",
    "DBMCP_DB_HOST": "host.docker.internal",
    "DBMCP_DB_USER": "root",
    "DBMCP_DB_PASSWORD": "secret",
    "DBMCP_DB_NAME": "mydb"
  }
}

Docker also needs -i: without it the container gets no stdin and the client cannot talk to the server.

On this page