Cursor MCP SQL Server: Query Your Database from Cursor

A Cursor MCP SQL server lets Cursor’s AI query your SQL database directly through the Model Context Protocol — so while you’re coding, the agent can check your real schema, run a SELECT, and answer data questions without you switching to a database client.

Cursor supports MCP through its mcp.json configuration. Point it at a governed SQL gateway and Cursor gains a live, read-only view of your database.

Why connect Cursor to your database

When Cursor can see your actual schema and data, it stops hallucinating table and column names. It writes migrations against tables that really exist, generates queries that match your data, and answers questions like “how many rows in orders have a null customer_id?” from the real database instead of guessing.

The AI2SQL MCP SQL server is read-only by default — the SQL guard blocks any write or DDL, so pointing Cursor at a real database is safe. More on that in is it safe to connect AI to a database.

Setup — add it to mcp.json

  1. Connect your database at AI2SQL and copy your API key and connection ID.
  2. Open Cursor’s MCP settings (or edit ~/.cursor/mcp.json) and add:
{
  "mcpServers": {
    "ai2sql": {
      "url": "https://builder.ai2sql.io/api/mcp",
      "headers": {
        "x-ai2sql-key": "sk_live_your_key",
        "x-ai2sql-connection": "conn_your_database"
      }
    }
  }
}
  1. Reload Cursor. The ai2sql tools show up and Cursor can query your database.

Supported databases

The Cursor MCP SQL server works across Postgres, MySQL, Microsoft SQL Server, SQLite, Snowflake, and more — Cursor writes correct dialect-aware SQL for whichever you connect. Postgres users can also follow connect Cursor to Postgres.

Other clients

Same gateway, different editor:

Wire Cursor to your data

Get your Cursor MCP SQL server config in a couple of minutes — read-only by default, free to start.

TRY IT — FREE, NO SIGNUP
Try one: