Claude MCP SQL Server: Let Claude Query Your Database

· · AI2SQL

Short answer: in claude.ai or Claude Desktop, open Customize → Connectors, add AI2SQL from the directory (or add a custom connector with https://builder.ai2sql.io/api/claude-mcp), and sign in with your AI2SQL account. In Claude Code, run claude mcp add --transport http ai2sql https://builder.ai2sql.io/api/claude-mcp and authenticate from /mcp. Claude can then read your real schema and run read-only SQL on PostgreSQL, MySQL or SQL Server.

There is no API key or database password to paste. Claude signs in with OAuth, and your database credentials stay encrypted on the AI2SQL server.

What you get

Ask Claude “what were our top 10 products by revenue last quarter?” and, instead of guessing, it reads your schema through the AI2SQL MCP server, writes the SQL and answers from real rows. It works for schema exploration, ad-hoc analysis, debugging data issues and drafting reports.

No database yet? Ask “Use AI2SQL to show the top 5 customers by revenue in demo_shop.” demo_shop is a shared sample store with fake data that works on every plan.

Set up in claude.ai or Claude Desktop

  1. Open Customize → Connectors.
  2. Find AI2SQL in the directory, or choose Add custom connector and paste https://builder.ai2sql.io/api/claude-mcp.
  3. Press Connect. A builder.ai2sql.io tab opens: sign in and press Allow.
  4. In a chat, enable AI2SQL from the tools menu and ask a question.

Custom connectors need Claude Pro, Max, Team or Enterprise.

Set up in Claude Code

claude mcp add --transport http ai2sql https://builder.ai2sql.io/api/claude-mcp

Start Claude Code, run /mcp, select ai2sql and choose Authenticate. Sign in to AI2SQL in the browser and press Allow; Claude Code receives the token on a local callback. Then ask:

Use AI2SQL to describe my database and find orders with no customer.

Tools Claude gets

ToolWhat it does
get_startedShows what AI2SQL can do and runs a first demo query
list_connectionsLists your connected databases (and demo_shop)
describe_schemaTables, columns and types for one connection
run_queryOne read-only SELECT / WITH, up to 1,000 rows
generate_sqlWrites SQL from a plain-English request using your schema
fix_sql, explain_sql, optimize_sql, convert_sqlRepair, explain, tune or translate a query
connect_databaseLinks to the page where you add a database

Safety

  • Read-only. The SQL guard rejects DROP, DELETE, UPDATE and other writes before they reach your database. See is it safe to connect AI to a database.
  • Masking. Personal data such as emails and card numbers can be masked per column before Claude sees it (Team plan on your own databases).
  • Logged. Every call appears in Agent activity with the SQL, the database and the result.

Plans

Signing in, listing connections, reading schemas, demo_shop and a few SQL writing requests a day are free. Running queries on your own database needs Pro or Team, which start with a 7-day trial.

Which databases work

PostgreSQL, MySQL and SQL Server support live schema reads and queries. Postgres users can also follow connect Claude to Postgres.

Other clients

The same gateway works from Cursor, ChatGPT, VS Code, Gemini CLI, Devin Desktop (Windsurf), n8n and your own agent.

Frequently asked questions

How do I connect Claude to my SQL database?

In claude.ai or Claude Desktop, open Customize → Connectors and add AI2SQL from the directory, or add a custom connector with the URL https://builder.ai2sql.io/api/claude-mcp. Sign in with your AI2SQL account and Claude can read your schema and run read-only SQL.

How do I add AI2SQL to Claude Code?

Run claude mcp add --transport http ai2sql https://builder.ai2sql.io/api/claude-mcp, then open /mcp in Claude Code, pick ai2sql and choose Authenticate. A browser tab opens to sign in to AI2SQL.

Can I try it without connecting my own database?

Yes. In Claude, AI2SQL includes demo_shop, a shared sample store with fake customers, orders and products. Schema reads and queries on demo_shop work on every plan, including free.

Can Claude change data through AI2SQL?

No. run_query accepts one SELECT or WITH statement. INSERT, UPDATE, DELETE and DDL are blocked before they reach your database.

Which Claude plan do I need?

Custom connectors in claude.ai and Claude Desktop need Claude Pro, Max, Team or Enterprise. Claude Code has no plan requirement for MCP servers.

TRY IT — FREE, NO SIGNUP
Try one: