# AgentSQL

AgentSQL places a control layer between an AI agent and PostgreSQL or MySQL, checking access, masking results, and recording database activity.

- MCP server · `type=mcp` · Claude Code, Codex, Cursor, GitHub Copilot, Windsurf (Devin Desktop), Cline, Zed, Gemini CLI · ★ 15
- Author: cuipengdba
- License: Apache-2.0 · policy=link-only · description only; the file stays with the author
- Source: https://github.com/cuipengdba/agentsql
- Updated: 2026-10-24
- HTML: https://affpapa.org/en/nevibecode/mcp/agentsql

## What it does

AgentSQL acts as an MCP gateway between an AI client and a database. Before a PostgreSQL or MySQL request reaches the database, the gateway authenticates the caller, parses SQL, evaluates permissions and rules, and controls execution. Returned data can be masked, while the action is written to an audit trail.

The server supports local `stdio` and Streamable HTTP `/mcp` transport. Its controls include API Key authentication, agent capability levels, and permissions for database objects or columns.

Write operations require approval. The Claude Code setup command points to `https://demo.agentsql.cn/mcp`, so access to that MCP endpoint must be configured before use.

## Requirements
- Remote server: `https://demo.agentsql.cn/mcp`

## Install

### Claude Code (native platform)

**Platform CLI: remote server**
```bash
claude mcp add --transport http agentsql https://demo.agentsql.cn/mcp
```

### Codex

**Platform CLI: remote server**
```bash
codex mcp add agentsql --url https://demo.agentsql.cn/mcp
```

### Cursor

**Config file**
File `.cursor/mcp.json`:
```json
{
    "mcpServers": {
        "agentsql": {
            "url": "https://demo.agentsql.cn/mcp"
        }
    }
}
```

### GitHub Copilot

**Config file**
File `.vscode/mcp.json`:
```json
{
    "servers": {
        "agentsql": {
            "type": "http",
            "url": "https://demo.agentsql.cn/mcp"
        }
    }
}
```

### Gemini CLI

**Platform CLI: remote server**
```bash
gemini mcp add -t http agentsql https://demo.agentsql.cn/mcp
```

## When to use it
- inspect an agent’s SQL before it reaches the database
- restrict access to approved tables and columns
- mask sensitive values in query results
- require approval before write operations
- record agent database activity for audit

## Example prompts
- List the PostgreSQL tables this agent can access and explain the allowed scope.
- Run a MySQL query using approved columns only, then mask sensitive values in the result.
- Check this write query against the policy and ask for approval before executing it.

## Similar
- [extension-object-storage](https://affpapa.org/en/nevibecode/skills/extension-object-storage.md) — skill · 28100 installs
- [extension-oql](https://affpapa.org/en/nevibecode/skills/extension-oql.md) — skill · 27700 installs
- [revenue-data-governance-strategy](https://affpapa.org/en/nevibecode/skills/revenue-data-governance-strategy.md) — skill · 21000 installs
- [customer-health-score](https://affpapa.org/en/nevibecode/skills/customer-health-score.md) — skill · 20600 installs
- [cargo-storage](https://affpapa.org/en/nevibecode/skills/cargo-storage.md) — skill · 10000 installs
- [cargo-analytics](https://affpapa.org/en/nevibecode/skills/cargo-analytics.md) — skill · 10000 installs

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
