SQL MCP Server logo

SQL MCP Server

Governed SQL access for AI agents with policy enforcement, tenant isolation, cost controls, and PostgreSQL, MySQL, and OceanBase support.

Install SQL MCP Server

Run the project’s own setup commands, in order.

Setup steps from the project

SQL MCP Server installs with its own steps rather than a config we can generate, so these are copied as-is. Follow them in order and run the commands in a terminal. Source: github.com

  1. 1. Start the server
    docker compose -f examples/quickstart/compose.yaml up -d --wait
    
  2. 2. Install
    git clone https://github.com/nethinwei/sql-mcp-server.git
    
  3. 3. Install
    cd sql-mcp-server
    
  4. 4. Install
    make build
    

Overview

SQL MCP Server provides governed access to PostgreSQL, MySQL, and OceanBase through controlled entities, relational-algebra IR, and parameterized code generation. Its policy layer applies RBAC, field ACLs, row policies, masking, result limits, timeouts, and tenant or session budgets while rejecting unsafe operations by default. A separately configured execute_sql escape hatch is available only to explicitly authorized users and is disabled by default. Reach for it when agents need database access with auditable, bounded queries rather than unrestricted SQL or DDL.

Use cases

  • Govern agent access to production relational data
  • Enforce row and field policies across tenants
  • Limit query cost with budgets, timeouts, and result caps
  • Audit controlled database operations
  • Provide trusted operators with a restricted SQL escape hatch

Key features

  • PostgreSQL, MySQL, and OceanBase support
  • Entity and relational-algebra query interface
  • RBAC, field ACLs, row policies, and masking
  • EXPLAIN checks, limits, timeouts, and budgets
  • Tenant isolation and fail-closed enforcement
  • Permission-gated execute_sql escape hatch

Security & health

What it can reach and how reliably it runs — from our own checks, not the maintainer’s claims.

ActiveLast checked

Recent health check succeeded.

12/12 checks healthy over the last 45d

Adoption & maintenance

Factual signals from GitHub, npm, and our automated checks — not a rating.

GitHub stars1Stargazers on the source repository.
Last commit1mo agoMost recent push to the default branch.

How SQL MCP Server works

What SQL MCP Server does

SQL MCP Server acts as a policy-enforcing gateway between AI agents and relational databases. It supports PostgreSQL, MySQL, and OceanBase, exposing governed data access through explicit entities and a relational-algebra intermediate representation. Parameterized code generation turns approved operations into database queries without allowing the governed interface to accept arbitrary SQL.

The access model is designed for untrusted agents. Role-based access control, field-level ACLs, row policies, and masking are enforced together. The governed interface does not provide DDL, so agents cannot use it to alter database structure. When the server cannot establish that a security condition is satisfied, it rejects the operation.

How it works

Agents compose the server's controlled tools and approved IR instead of submitting free-form SQL. Before execution, the gateway can apply EXPLAIN-based screening, result-size limits, timeouts, and session or tenant budgets. These controls constrain both what an agent may access and how much work a request may consume.

Trusted operators can use a separate execute_sql path as an SQL escape hatch. It is disabled by default, visible only to users granted sql:execute@<data-source>, and uses a separately declared connection. Hard limits and audit controls apply to this path, and writes are rejected when the required failure conditions are encountered.

Configuration can be hot-reloaded. Asynchronous auditing and an OpenTelemetry hook support operational visibility, while tenant isolation, masking, and rejection cases can be exercised through the quickstart and MCP Inspector example.

Setup and configuration

A Docker and Docker Compose quickstart is available in examples/quickstart/compose.yaml. It starts the example deployment and exposes a health check at http://127.0.0.1:8080/healthz.

For a source build, the project requires Go 1.26.10 or newer and a verified database version. The basic build flow is:

sh
git clone https://github.com/nethinwei/sql-mcp-server.git
cd sql-mcp-server
make build

The full YAML configuration example is in examples/config.example.yaml, with configuration reference material covering the public settings. Deployment, lifecycle management, CLI usage, containers, upgrades, and hot reload are covered by the operations documentation. A web administration console is also available for configuration editing, publishing, rollback, administrator permissions, and Docker Compose deployment.

Client connection templates are provided for Cursor, Claude Desktop, and VS Code using stdio. Database support should be checked against the project's provider compatibility and supported-version references before deployment.

Tools and capabilities

  • Governed access through explicit entities and relational-algebra IR.
  • Parameterized query generation for PostgreSQL, MySQL, and OceanBase.
  • RBAC, field ACLs, row policies, and field masking.
  • EXPLAIN prechecks, result caps, timeouts, and session or tenant budgets.
  • Tenant isolation with default-deny behavior when safeguards cannot be verified.
  • Optional, permission-gated execute_sql access for trusted operators.
  • Configuration hot reload, asynchronous audit events, and an OpenTelemetry hook.

Limitations and notes

The governed surface is intentionally not an arbitrary SQL interface and does not expose DDL. The execute_sql route is a separate exception path: it is off by default, requires an explicit data-source-scoped permission, and uses its own declared connection. Provider behavior depends on the verified database versions and compatibility boundaries.

The project is licensed under MIT. The repository also includes security, threat-model, testing, and evidence references that define operational controls and their validation boundaries.

Written by AllMCPs with AI assistance from the project’s README and listing data. How we build listings

Reviews

No reviews yet — be the first to share how it worked for you.

Frequently Asked Questions about SQL MCP Server

SQL MCP Server is an MCP server that connects AI agents to PostgreSQL, MySQL, and OceanBase through governed entity and relational-algebra tools. It generates parameterized queries, enforces RBAC, field and row policies, masking, limits, and budgets, and offers a separately permissioned execute_sql path for trusted operators.

Install it with Docker Compose or build it from source. The quickstart uses Docker and `examples/quickstart/compose.yaml`; source builds require Go 1.26.10 or newer, followed by `make build` from the cloned repository.

SQL MCP Server supports PostgreSQL, MySQL, and OceanBase. Verify the database version against the project's supported-version and provider-compatibility references before deployment.

Yes, SQL MCP Server includes a stdio connection template for Cursor. Templates are also provided for Claude Desktop and VS Code in the repository's client examples.

No, the governed interface does not accept arbitrary SQL or provide DDL. A separate `execute_sql` escape hatch exists for explicitly authorized trusted users, is disabled by default, uses a separately declared connection, and remains subject to hard limits and auditing.

Related MCP servers

Add a badge to your READMEShow it’s listed — live SVG, Markdown or HTML.

AllMCPs Directory Badge

Full Badge Customizer

Showcase your server listing on GitHub or your project documentation. Embed this dynamic SVG badge to highlight official listing status and live engagement.

Badge Style:
Live Dynamic SVG PreviewSQL MCP Server AllMCPs Directory Badge
Markdown (GitHub README)
[![AllMCPs](https://allmcps.com/api/badge/sql-mcp-server?style=directory)](https://allmcps.com/mcp/sql-mcp-server)
HTML Embed
<a href="https://allmcps.com/mcp/sql-mcp-server"><img src="https://allmcps.com/api/badge/sql-mcp-server?style=directory" alt="SQL MCP Server on AllMCPs" /></a>