Skip to content
MCP server

SQL MCP Server

Governed SQL gateway for untrusted AI agents on PostgreSQL, MySQL and OceanBase

Runs locally

SQL MCP Server is an open-source MCP server for databases. It runs locally on your machine and is started by your AI client.

Pricing
Open source
Platforms
Self-hosted, CLI, Linux
Runs
Locally
What it can do
Can change data (1 tool)
Version
0.1.21

Similar MCP servers

Install

Add with the CLI

Run in a terminal

claude mcp add sql-mcp-server --env DATABASE_DSN='<DATABASE_DSN>' -- docker run -i --rm -e DATABASE_DSN ghcr.io/nethinwei/sql-mcp-server:0.1.21

Add --scope user to use it in every project, or --scope project to share it in .mcp.json.

Or share it with your project

Add to .mcp.json

{
  "mcpServers": {
    "sql-mcp-server": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "-e",
        "DATABASE_DSN",
        "ghcr.io/nethinwei/sql-mcp-server:0.1.21"
      ],
      "env": {
        "DATABASE_DSN": "<DATABASE_DSN>"
      }
    }
  }
}

Claude Code setup guide

Add to claude_desktop_config.json

{
  "mcpServers": {
    "sql-mcp-server": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "-e",
        "DATABASE_DSN",
        "ghcr.io/nethinwei/sql-mcp-server:0.1.21"
      ],
      "env": {
        "DATABASE_DSN": "<DATABASE_DSN>"
      }
    }
  }
}

Settings → Developer → Edit Config, then quit and reopen Claude Desktop.

Claude Desktop setup guide

Add to ~/.cursor/mcp.json

{
  "mcpServers": {
    "sql-mcp-server": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "-e",
        "DATABASE_DSN",
        "ghcr.io/nethinwei/sql-mcp-server:0.1.21"
      ],
      "env": {
        "DATABASE_DSN": "<DATABASE_DSN>"
      }
    }
  }
}

Use .cursor/mcp.json in a project to share it with the project.

Cursor setup guide

Add to ~/.copilot/mcp-config.json

{
  "mcpServers": {
    "sql-mcp-server": {
      "type": "stdio",
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "-e",
        "DATABASE_DSN",
        "ghcr.io/nethinwei/sql-mcp-server:0.1.21"
      ],
      "env": {
        "DATABASE_DSN": "<DATABASE_DSN>"
      }
    }
  }
}

Or put the same entry in .mcp.json at your workspace root to share it.

VS Code setup guide

Add with the CLI

Run in a terminal

codex mcp add sql-mcp-server --env DATABASE_DSN='<DATABASE_DSN>' -- docker run -i --rm -e DATABASE_DSN ghcr.io/nethinwei/sql-mcp-server:0.1.21

Or add to config.toml

Add to ~/.codex/config.toml

[mcp_servers.sql-mcp-server]
command = "docker"
args = ["run", "-i", "--rm", "-e", "DATABASE_DSN", "ghcr.io/nethinwei/sql-mcp-server:0.1.21"]
env = { DATABASE_DSN = "<DATABASE_DSN>" }

Codex setup guide

Add to your client's MCP settings (most use this shape)

{
  "mcpServers": {
    "sql-mcp-server": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "-e",
        "DATABASE_DSN",
        "ghcr.io/nethinwei/sql-mcp-server:0.1.21"
      ],
      "env": {
        "DATABASE_DSN": "<DATABASE_DSN>"
      }
    }
  }
}
  • Gemini CLI and Antigravity

    Gemini CLI

    Add to ~/.gemini/settings.json

    {
      "mcpServers": {
        "sql-mcp-server": {
          "command": "docker",
          "args": [
            "run",
            "-i",
            "--rm",
            "-e",
            "DATABASE_DSN",
            "ghcr.io/nethinwei/sql-mcp-server:0.1.21"
          ],
          "env": {
            "DATABASE_DSN": "<DATABASE_DSN>"
          }
        }
      }
    }

    Or run: gemini mcp add -s user -e DATABASE_DSN='<DATABASE_DSN>' sql-mcp-server docker -- run -i --rm -e DATABASE_DSN ghcr.io/nethinwei/sql-mcp-server:0.1.21

    Antigravity

    Add to ~/.gemini/config/mcp_config.json

    {
      "mcpServers": {
        "sql-mcp-server": {
          "command": "docker",
          "args": [
            "run",
            "-i",
            "--rm",
            "-e",
            "DATABASE_DSN",
            "ghcr.io/nethinwei/sql-mcp-server:0.1.21"
          ],
          "env": {
            "DATABASE_DSN": "<DATABASE_DSN>"
          }
        }
      }
    }

    Use .agents/mcp_config.json to add it to one workspace only.

    Gemini CLI and Antigravity setup guide

  • Devin Desktop (formerly Windsurf)

    Add to ~/.config/devin/mcp_config.json

    {
      "mcpServers": {
        "sql-mcp-server": {
          "command": "docker",
          "args": [
            "run",
            "-i",
            "--rm",
            "-e",
            "DATABASE_DSN",
            "ghcr.io/nethinwei/sql-mcp-server:0.1.21"
          ],
          "env": {
            "DATABASE_DSN": "<DATABASE_DSN>"
          }
        }
      }
    }

    On Windows the file is %APPDATA%\devin\mcp_config.json. Use .devin/mcp_config.json to share it with a project.

    Devin Desktop setup guide

  • Cline

    Add to cline_mcp_settings.json

    {
      "mcpServers": {
        "sql-mcp-server": {
          "command": "docker",
          "args": [
            "run",
            "-i",
            "--rm",
            "-e",
            "DATABASE_DSN",
            "ghcr.io/nethinwei/sql-mcp-server:0.1.21"
          ],
          "env": {
            "DATABASE_DSN": "<DATABASE_DSN>"
          }
        }
      }
    }

    Open it from the MCP Servers icon → Configure → Configure MCP Servers.

    Cline setup guide

  • Zed

    Add to Zed settings.json

    {
      "context_servers": {
        "sql-mcp-server": {
          "command": "docker",
          "args": [
            "run",
            "-i",
            "--rm",
            "-e",
            "DATABASE_DSN",
            "ghcr.io/nethinwei/sql-mcp-server:0.1.21"
          ],
          "env": {
            "DATABASE_DSN": "<DATABASE_DSN>"
          }
        }
      }
    }

    Open it with zed: open settings file. Merge context_servers into the settings you already have.

    Zed setup guide

  • JetBrains AI Assistant and Junie

    AI Assistant

    Add to Settings → Tools → AI Assistant → Model Context Protocol (MCP) → Add

    {
      "mcpServers": {
        "sql-mcp-server": {
          "command": "docker",
          "args": [
            "run",
            "-i",
            "--rm",
            "-e",
            "DATABASE_DSN",
            "ghcr.io/nethinwei/sql-mcp-server:0.1.21"
          ],
          "env": {
            "DATABASE_DSN": "<DATABASE_DSN>"
          }
        }
      }
    }

    The AI Assistant docs only show command and args. If the env block is ignored, use Junie for this server.

    Junie

    Add to ~/.junie/mcp/mcp.json

    {
      "mcpServers": {
        "sql-mcp-server": {
          "command": "docker",
          "args": [
            "run",
            "-i",
            "--rm",
            "-e",
            "DATABASE_DSN",
            "ghcr.io/nethinwei/sql-mcp-server:0.1.21"
          ],
          "env": {
            "DATABASE_DSN": "<DATABASE_DSN>"
          }
        }
      }
    }

    Use .junie/mcp/mcp.json to share it with a project.

    JetBrains AI Assistant and Junie setup guide

  • Kiro

    Add to ~/.kiro/settings/mcp.json

    {
      "mcpServers": {
        "sql-mcp-server": {
          "command": "docker",
          "args": [
            "run",
            "-i",
            "--rm",
            "-e",
            "DATABASE_DSN",
            "ghcr.io/nethinwei/sql-mcp-server:0.1.21"
          ],
          "env": {
            "DATABASE_DSN": "<DATABASE_DSN>"
          }
        }
      }
    }

    Use .kiro/settings/mcp.json to add it to one workspace only.

    Kiro setup guide

Using several servers? Build one config file with the MCP config generator.

Configuration

  • DATABASE_DSNDatabase DSN referenced by ${DATABASE_DSN} in config.yaml

About SQL MCP Server

Rather than hand an agent a database connection, this Go gateway makes it work through explicit entities, a relational-algebra intermediate form and parameterised code generation. The governed path accepts no arbitrary SQL and offers no DDL. Documentation is mainly in Chinese.

Controls include RBAC, field ACLs, row policies and masking, EXPLAIN pre-screening, result caps, timeouts and session or tenant budgets, and the design fails closed when a safety capability cannot be proven. Configuration hot-reloads, audits are asynchronous and OpenTelemetry hooks are available. A separate trusted-operator escape tool, execute_sql, is off by default, visible only to users granted sql:execute for a data source, and bound by hard limits and fail-on-audit-write rules.

A five-minute Docker Compose quickstart demonstrates tenant isolation, masking and denials. It ships as a container image and stdio server, with a web admin console, and is MIT licensed at version 0.1.21.

Tools this server provides (1)

Taken from the project documentation; the running server may differ.

From the tool list in its README, going by the names, 1 of 1 tool changes data.

From the server's own tool labels and tool names; not verified by us.

execute_sqlName suggests: changes
Trusted-operator SQL escape tool, disabled by default

What it does

No arbitrary SQL
Agents compose only controlled tools and allow-listed IR.
Field and row governance
RBAC, field ACLs, row policies and masks are enforced together.
Cost limits
EXPLAIN screening, result caps, timeouts and budgets.
Fail closed
Denies when a safety capability cannot be proven.
Audit trail
Asynchronous audit with OpenTelemetry hooks.
Trusted escape hatch
execute_sql is off by default and separately audited.

Good for

  • Give an AI agent read access to tenant data without raw SQL
  • Mask sensitive columns in agent queries
  • Cap query cost per session or tenant
  • Audit every agent data access

Pricing

Open source

MIT licensed

SQL MCP Server FAQ

Which databases?

PostgreSQL, MySQL and OceanBase.

Can agents run raw SQL?

Not on the governed path; execute_sql is a separate, default-off tool for trusted operators.

How do I try SQL MCP Server?

Run the Docker Compose quickstart with Docker only.

What licence?

MIT.

Is SQL MCP Server free?

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

How do I add SQL MCP Server to Claude Code?

Run this command in your terminal: claude mcp add sql-mcp-server --env DATABASE_DSN='<DATABASE_DSN>' -- docker run -i --rm -e DATABASE_DSN ghcr.io/nethinwei/sql-mcp-server:0.1.21

What are the best alternatives to SQL MCP Server?

The closest alternatives to SQL MCP Server are REA, AiSOC, x64dbg-mcp-server, redamon and Treasure Map.

Where this comes from

  • Description: written from the project's README.
  • Install steps: from the official MCP Registry entry.

How AIPoweredBot checks servers