# SQL MCP Server [Health: Active]

**Category:** 🗄️ Databases  
**Repository:** https://github.com/nethinwei/sql-mcp-server  
**GitHub Stars:** 1  
**Views:** 0  
**Installs:** 0  
**Upvotes:** 0  
**Directory Page:** https://allmcps.com/mcp/sql-mcp-server

## Description
Controlled SQL access gateway with policy, cost limits, tenant isolation, and safe tools.

## Claude Desktop Quick Installation
No generated config for this server: it installs through its own setup steps.

The project's own setup steps (from https://github.com/nethinwei/sql-mcp-server), copied verbatim. Follow them in order; they are not an mcpServers config.

1. Start the server:

```sh
docker compose -f examples/quickstart/compose.yaml up -d --wait
```

2. Install:

```sh
git clone https://github.com/nethinwei/sql-mcp-server.git
```

3. Install:

```sh
cd sql-mcp-server
```

4. Install:

```sh
make build
```

## Documentation

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

_Full upstream README: https://allmcps.com/mcp/sql-mcp-server/readme_

