AgentSQL — Claude Code MCP server: setup
AgentSQL places a control layer between an AI agent and PostgreSQL or MySQL, checking access, masking results, and recording database activity.
claude mcp add --transport http agentsql https://demo.agentsql.cn/mcpWhat AgentSQL 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.
What it helps with
- 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 for the agent
- 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.
How to install AgentSQL
Platform CLI: remote server
claude mcp add --transport http agentsql https://demo.agentsql.cn/mcpPlatform CLI: remote server
codex mcp add agentsql --url https://demo.agentsql.cn/mcpConfig file
{
"mcpServers": {
"agentsql": {
"url": "https://demo.agentsql.cn/mcp"
}
}
}Config file
{
"servers": {
"agentsql": {
"type": "http",
"url": "https://demo.agentsql.cn/mcp"
}
}
}Platform CLI: remote server
gemini mcp add -t http agentsql https://demo.agentsql.cn/mcpStep by step, with commands for each platform: How to add an MCP server to Claude Code, Codex, Cursor, VS Code, Gemini CLI and more
Questions about AgentSQL
How do I install AgentSQL in Claude Code?
Run claude mcp add --transport http agentsql https://demo.agentsql.cn/mcp.
What does AgentSQL do?
It places an MCP gateway in front of database requests, applying authentication, permission and rule checks, controlled execution, result masking, and audit logging.
Which databases does AgentSQL support?
The description names PostgreSQL and MySQL.