# AI2SQL

> AI2SQL is a freemium MCP server for databases. Text-to-SQL MCP server running read-only queries on Postgres, MySQL and SQL Server. It runs as a hosted remote server, so there is nothing to install locally.

- **Kind:** MCP server
- **Pricing:** Freemium
- **Starting price:** $9 a month
- **Platforms:** Web, API, macOS, Windows
- **Website:** https://ai2sql.io/mcp
- **MCP Registry name:** io.ai2sql/ai2sql
- **Categories:** databases
- **Listing updated:** 2026-11-16

## About

This hosted server gives an AI assistant eight tools for working with SQL: five that write, fix, optimise, explain and convert queries, and three that inspect and query databases you connect at the vendor's site. Queries can be written for PostgreSQL, MySQL, SQL Server, Oracle, Snowflake, BigQuery, SQLite and MariaDB; live querying covers PostgreSQL, MySQL/MariaDB and SQL Server.

Access is guarded. Sign-in uses OAuth 2.1, so no API key is pasted into the client. Only a single SELECT or WITH statement runs, with writes, DDL and batches rejected on the server, and results are capped at 1,000 rows and 10 seconds. Team plans can mask names, emails, phone numbers and similar fields before the assistant sees them, and an activity log records every call, including blocked writes.

A sample store called demo_shop lets anyone try live queries without connecting a database.

## Features

- **SQL generation:** Turns plain English into SQL for the named dialect, using the real schema when a connection is picked.
- **Fix and optimise:** Repairs failing queries and suggests faster versions with index hints.
- **Dialect conversion:** Translates queries between eight SQL dialects.
- **Schema inspection:** Lists connections and describes tables and columns.
- **Read-only queries:** Runs one SELECT or WITH statement and returns up to 1,000 rows.
- **Data masking:** Replaces personal values in results with placeholders on the Team plan.
- **Audit log:** Logs SQL, database, result and latency for every call.

## Good for

- Ask Claude for last month's orders from a connected database
- Debug a failing query by pasting its error
- Convert a query from MySQL to Snowflake
- Explain an unfamiliar query line by line
- Let agents query customer data with personal fields masked

## Install

### Claude Code (Terminal)

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

### Claude Desktop (Settings → Connectors → Add custom connector)

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

### Cursor (~/.cursor/mcp.json)

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

### VS Code (.vscode/mcp.json)

```json
{
  "servers": {
    "ai2sql": {
      "type": "http",
      "url": "https://builder.ai2sql.io/api/chatgpt-mcp"
    }
  }
}
```

### Windsurf (~/.codeium/windsurf/mcp_config.json)

```json
{
  "mcpServers": {
    "ai2sql": {
      "serverUrl": "https://builder.ai2sql.io/api/chatgpt-mcp"
    }
  }
}
```

### Other clients (your client's MCP settings (most use this shape))

```json
{
  "mcpServers": {
    "ai2sql": {
      "type": "http",
      "url": "https://builder.ai2sql.io/api/chatgpt-mcp"
    }
  }
}
```

## Tools

- `generate_sql`: Plain English to SQL in a named dialect.
- `fix_sql`: Corrects a failing query given its error.
- `optimize_sql`: Rewrites a slow query with reasoning and index hints.
- `explain_sql`: Explains a query line by line.
- `convert_sql`: Translates SQL between dialects.
- `list_connections`: Lists connected databases.
- `describe_schema`: Describes tables and columns of a connection.
- `run_query`: Runs one read-only query, up to 1,000 rows.

## FAQ

### Is it safe to point at a production database?

Queries are read-only: only one SELECT or WITH statement runs, and writes, DDL and batches are rejected server-side.

### How do I sign in?

With your AI2SQL account via OAuth 2.1; there is no API key to paste.

### Which clients work?

Claude, ChatGPT, Cursor, VS Code with Copilot and any client supporting Streamable HTTP with OAuth.

### What does it cost?

The pricing page lists Start at $9, Pro at $19 and Team at $39 a month with a 7-day trial; running queries on your own databases needs Pro or Team.

### Is AI2SQL free?

AI2SQL has a free plan, with paid plans for more usage or features. Paid plans start at $9 a month.

### How do I add AI2SQL to Claude Code?

Run this command in your terminal: claude mcp add --transport http ai2sql https://builder.ai2sql.io/api/chatgpt-mcp

### What are the best alternatives to AI2SQL?

The closest alternatives to AI2SQL are Midplane, PlatypusDB, Lorebase, Sovaria and model2data studio.

## Alternatives

- [Midplane](https://ai-powered.com/mcp/midplane): Midplane is an open-source MCP server for databases.
- [PlatypusDB](https://ai-powered.com/mcp/platypusdb): PlatypusDB is an open-source MCP server for databases.
- [Lorebase](https://ai-powered.com/mcp/lorebase): Lorebase is an open-source MCP server for knowledge and memory.
- [Sovaria](https://ai-powered.com/mcp/sovaria): Sovaria is a freemium MCP server for databases.
- [model2data studio](https://ai-powered.com/mcp/model2data-studio): model2data studio is a freemium MCP server for databases.
- [semlayer](https://ai-powered.com/mcp/semlayer): semlayer is a free MCP server for databases.
- [bricksentry](https://ai-powered.com/mcp/bricksentry): bricksentry is an open-source MCP server for databases.
- [MCP Toolbox for Databases](https://ai-powered.com/mcp/mcp-toolbox-for-databases-2): MCP Toolbox for Databases is an open-source MCP server for databases.

---
Source: https://ai-powered.com/mcp/ai2sql
