AI2SQL

Generate, fix, optimize, explain and convert SQL, browse the live schema and run read-only queries on PostgreSQL, MySQL and SQL Server.

Documentation

Query your database from Claude, Cursor and ChatGPT

AI2SQL is a hosted MCP server that connects Claude, ChatGPT, Cursor and VS Code to your PostgreSQL, MySQL or SQL Server database. Sign in with your AI2SQL account and your assistant writes SQL against the real schema and runs it read-only, inside the chat you already use.

Live querying for PostgreSQL, MySQL and SQL Server. No API key to paste.

AI2SQL MCP server at a glance

What it is

AI2SQL is a hosted MCP server that lets AI assistants write SQL against your real schema and run read-only queries on your database.

Server URL

https://builder.ai2sql.io/api/chatgpt-mcp

Works with

Claude (claude.ai, Claude Desktop, Claude Code), Cursor, VS Code with GitHub Copilot, ChatGPT in developer mode, and any MCP client that supports Streamable HTTP with OAuth 2.1.

Sign-in

OAuth 2.1 with PKCE and dynamic client registration. You sign in with your AI2SQL account; no API key is pasted into the client.

Live databases

PostgreSQL, MySQL and MariaDB, Microsoft SQL Server. Connections are created once in the AI2SQL dashboard.

SQL dialects

Writes, fixes, explains, optimizes and converts SQL for PostgreSQL, MySQL, SQL Server, Oracle, Snowflake, BigQuery, SQLite and MariaDB.

Safety

Read-only. Only a single SELECT or WITH statement runs; writes, DDL and multi-statement batches are rejected server-side. 1,000 rows and 10 seconds per query.

Price

Free: 5 SQL requests a day, schema browsing included. Start $9, Pro $19, Team $39 per month with a 7-day trial; paid plans add run_query on connected databases.

Last updated

2 September 2026

SETUP

Pick your assistant

Server URL https://builder.ai2sql.io/api/chatgpt-mcp

  1. 1 Open the Add custom connector dialog in Claude. Open in Claude ↗ Claude Desktop: Settings → Connectors → Add custom connector. Custom connectors need Claude Pro, Max, Team or Enterprise.
  2. 2 Name it AI2SQL, paste the server URL above, leave Client ID and Secret empty, and press Continue.
  3. 3 Press Connect. A builder.ai2sql.io tab asks you to sign in (or create an account), then Allow. Back in Claude, 8 tools are live.

Try: "Which databases do I have connected?" then "Show me the schema of <name> and list last month's orders."

Any other MCP client

Streamable HTTP with OAuth 2.1 and dynamic client registration. Add this to your client's MCP config; it will prompt you to sign in.

{
  "mcpServers": {
    "ai2sql": {
      "url": "https://builder.ai2sql.io/api/chatgpt-mcp"
    }
  }
}

8 TOOLS

What your assistant can do

You never pick a tool. Say what you need and the assistant chooses; these are the calls it can make.

Write SQL

Every plan.

  • generate_sql — Plain English → SQL in the dialect you name, against your real schema when a connection is picked.
  • fix_sql — Paste a failing query and its error; get the corrected statement and why it broke.
  • optimize_sql — Slow query in, faster query out, with the reasoning and index hints.
  • explain_sql — Line-by-line explanation of what a query does.
  • convert_sql — Translate between PostgreSQL, MySQL, SQL Server, Oracle, Snowflake, BigQuery, SQLite, MariaDB.

Work with your data

Connections you set up at ai2sql.io.

  • list_connections — The databases you connected at ai2sql.io: id, name, type.
  • describe_schema — Tables and columns of one connection, so SQL uses real names.
  • run_query — Runs one SELECT / WITH read-only and returns up to 1,000 rows. Paid plans.

HOW IT STAYS SAFE

Read-only, signed in, bounded

OAuth, not keys

Your assistant signs in with your AI2SQL account (OAuth 2.1 with PKCE). Access tokens last an hour and refresh for 30 days. Disconnect in your client any time.

Writes never reach the database

Our server classifies every statement first. Only a single SELECT or WITH passes; writes, DDL, batches and dangerous functions are refused with a clear error.

Bounded by default

1,000 rows per query, 10-second timeout, one short-lived connection per call. Your credentials stay encrypted on our side; the assistant only ever sees results.

DATABASES

Live schema and queries

  • ✓ PostgreSQL
  • ✓ MySQL and MariaDB
  • ✓ SQL Server

SQL is written for Oracle, Snowflake, BigQuery, SQLite and MongoDB too, but live querying for those is not available yet.

PLANS

Same account, same plan

  • Free — sign in, list connections, browse schemas, 5 SQL requests a day shared with the web app.
  • Start, Pro, Team — unlimited SQL writing plus run_query on your connected databases. See plans →

Scripts and custom agents

No browser to sign in with? The API-key server at builder.ai2sql.io/api/mcp exposes list_connections, describe_schema and run_query with an X-API-Key header, metered per key.

Get an API key →

COMPARED

AI2SQL MCP vs a self-hosted database MCP server

AI2SQL MCPSelf-hosted DB MCP server
SetupAdd one URL, sign in with OAuthInstall locally, put database credentials in a config file
DatabasesPostgreSQL, MySQL, SQL Server from one serverUsually one engine per server
Write protectionServer-side statement guard, cannot be turned off by the assistantDepends on the server and on the database user you configure
SQL helpgenerate, fix, optimize, explain, convert built inQuery execution only
Works in claude.ai and ChatGPTYes, hosted with OAuthLocal servers only work in desktop and IDE clients

Longer comparison: AI2SQL Gateway vs the Postgres MCP server.

Questions people ask their assistant

Last updated 2 September 2026.

How do I connect Claude to my PostgreSQL, MySQL or SQL Server database?

Add the AI2SQL MCP server as a custom connector in Claude (Customize → Connectors → Add), paste https://builder.ai2sql.io/api/chatgpt-mcp, and sign in with your AI2SQL account. Claude can then list your connected databases, read their schema and run read-only queries. Works in claude.ai, Claude Desktop and Claude Code.

Can ChatGPT query my SQL database?

Yes, with developer mode on ChatGPT Plus, Pro, Team, Enterprise or Edu. Create a plugin pointing at the AI2SQL MCP server URL with OAuth authentication, connect, and ChatGPT can describe your schema and run read-only SQL on PostgreSQL, MySQL or SQL Server connections you set up in the AI2SQL dashboard.

Is there an MCP server for text-to-SQL?

AI2SQL is one: its MCP server exposes generate_sql, fix_sql, optimize_sql, explain_sql and convert_sql alongside list_connections, describe_schema and run_query. The assistant picks the tool from what you ask; you never call a tool by name.

Can the AI change or delete my data?

No. Every tool is read-only. run_query accepts a single SELECT or WITH statement; INSERT, UPDATE, DELETE, DDL and multi-statement batches are rejected on the AI2SQL server before anything reaches your database.

Do I need an API key?

Not for Claude, Cursor, VS Code or ChatGPT. Those sign in with your AI2SQL account over OAuth 2.1. Nothing is pasted anywhere except the server URL. API keys remain available for scripts and custom agents through the separate server at builder.ai2sql.io/api/mcp.

Does it work with Cursor and VS Code?

Yes. Cursor and VS Code (GitHub Copilot agent mode) both support remote MCP servers with OAuth. The install buttons on this page add the server in one click; the client then asks you to sign in to AI2SQL.

Which databases can it actually query?

Live schema browsing and run_query work for PostgreSQL, MySQL, MariaDB and Microsoft SQL Server connections. Snowflake, MongoDB, Oracle and others still get SQL written for them, but live querying for those is not available yet.

How is this different from pasting my schema into ChatGPT?

Pasting a schema gives the model a snapshot it cannot verify or run. Through MCP the assistant reads the current schema itself, executes the query read-only and answers with real rows, and the schema never has to be copied into a chat.

What does the free plan get?

Sign in, list your connections, browse schemas and make 5 SQL requests a day, shared with the AI2SQL web app. Running queries against a connected database is part of the paid plans (Start $9, Pro $19, Team $39 per month).

Where do I connect a database?

In the AI2SQL dashboard at builder.ai2sql.io. Your AI assistant only sees connections you have already set up there. Databases on your own machine go through the AI2SQL Connector desktop app.

Which plans of Claude or ChatGPT support custom MCP servers?

Custom connectors need Claude Pro, Max, Team or Enterprise. ChatGPT needs developer mode, available on Plus, Pro, Team, Enterprise and Edu. Claude Code, Cursor and VS Code have no plan requirement for MCP servers.