Skip to content
MCP server

AgentSQL

Guard agents' PostgreSQL and MySQL access with SQL audit, masking and write approval

Install
Pricing
Open source
Platforms
self-hosted, Linux, API
Runs
Remotely
Version
0.4.0
Listing updated
1 day ago

About AgentSQL

AgentSQL is an open-source MCP server for databases. It runs as a hosted remote server, so there is nothing to install locally.

Every query from an external agent passes a six-stage chain: the API key is verified and agent, data source and policy are loaded (failing closed), SQL is parsed into an AST for the PostgreSQL or MySQL dialect, static checks run before any database contact, then read-only EXPLAIN and metadata checks. Decisions combine deny, approve, warn and allow into allow, alert, block or human review. Only allowed or warned statements execute, with limits on connections, timeouts and rows, and results are masked by column before return. Each decision is written to an application audit log, and audit failure also fails closed.

The project is also a standalone natural-language data-question agent with its own Go web page, so SQLBot is not required, though a version-pinned adapter can route SQLBot's database calls through the gateway. Both entry points share identity, authorization, execution control, masking and audit. A live demo runs on synthetic data only.

It is self-hosted, ships as a Go binary under Apache-2.0, supports stdio and HTTP MCP and exposes Prometheus metrics. The release notes caution that it has not been verified on users' real business systems. Documentation is mainly in Chinese.

Install

Run in a terminal

claude mcp add --transport http agentsql https://demo.agentsql.cn/mcp

Add to Settings → Connectors → Add custom connector

https://demo.agentsql.cn/mcp
Install in CursorOpens Cursor, which asks you to confirm. Or add it by hand:

Add to ~/.cursor/mcp.json

{
  "mcpServers": {
    "agentsql": {
      "url": "https://demo.agentsql.cn/mcp"
    }
  }
}
Install in VS CodeOpens VS Code, which asks you to confirm. Or add it by hand:

Add to .vscode/mcp.json

{
  "servers": {
    "agentsql": {
      "type": "http",
      "url": "https://demo.agentsql.cn/mcp"
    }
  }
}

Add to ~/.codeium/windsurf/mcp_config.json

{
  "mcpServers": {
    "agentsql": {
      "serverUrl": "https://demo.agentsql.cn/mcp"
    }
  }
}

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

{
  "mcpServers": {
    "agentsql": {
      "type": "http",
      "url": "https://demo.agentsql.cn/mcp"
    }
  }
}

What it does

Six-stage SQL gate
Authenticates, parses, checks, decides, executes and audits each query.
Dangerous-statement rules
Blocks writes without WHERE and unauthorized tables.
Result masking
Masks sensitive columns such as phone and email.
Write approval
Can route risky statements to human review.
Persistent audit
Records decisions with matched rules and timeline.
Own query agent
Ask questions in natural language without SQLBot.

Good for

  • Let an external AI agent query a production-like database safely
  • Mask phone numbers and emails in results sent to a model
  • Require approval before an agent runs an UPDATE
  • Keep an audit trail of every agent query

Pricing

Open source

Apache-2.0, self-hosted; public demo uses synthetic data

Prices change. Check agentsql.cn before you buy.

AgentSQL FAQ

Which databases are supported?

PostgreSQL and MySQL dialects are parsed, with support levels listed in the project's compatibility matrix.

Is it self-hosted?

Yes, as a Go binary or Docker image under Apache-2.0.

Does it require SQLBot?

No. SQLBot is an optional client through a fixed-version adapter.

Is it production verified?

The release notes say it has not been verified on users' real business systems.

Is AgentSQL free?

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

How do I add AgentSQL to Claude Code?

Run this command in your terminal: claude mcp add --transport http agentsql https://demo.agentsql.cn/mcp

What are the best alternatives to AgentSQL?

The closest alternatives to AgentSQL are REA, Agent Roast, Midplane, Leash and Tinplate Edge AI Safety, Security & EU Compliance.

Alternatives to AgentSQL

  1. REA

    MCP server

    CLI and MCP server that lets coding agents reverse engineer apps and binaries

    Runs locally
    • Open source
    • 464K GitHub stars
    • Developer tools
  2. Agent Roast

    MCP server

    Offline review that flags agent changes which weaken tests, assertions or CI

    Runs locally
    • Open source
    • 4 Hacker News points
    • Developer tools
  3. Midplane

    MCP server

    Postgres gateway for AI agents with table grants, column masking and approval for writes

    Runs locally
    • Open source
    • 5 GitHub stars
    • Databases
  4. Leash

    MCP server

    Review what your AI touched, approve risky actions and undo supported changes

    • 1 tool
    • Remote
    • Free
    • 1 GitHub star
    • Security
  5. SecureCloud

    MCP server

    SentinelOne and IT security catalog, prices, quotes and checkout links for Israel

    • 7 tools
    • Remote
    • Free
    • Security