Connect Claude to SQL Server over MCP, read-only

Add your SQL Server database to AI2SQL, add the AI2SQL connector to Claude or Cursor, and sign in. They can then read your schema and run SELECT queries, while writes are blocked and your password never leaves AI2SQL.

Short answer: connect Claude to SQL Server through an MCP server that only runs read-only SQL, using a login that is only in db_datareader. With AI2SQL you add the database once, add the connector https://builder.ai2sql.io/api/claude-mcp to Claude (or the editor URL to Cursor), and sign in. The same steps work for Azure SQL and Amazon RDS for SQL Server.

Step 1: a read-only SQL Server login

Enforce read-only in SQL Server itself, so a write fails even if every other layer missed it:

-- SQL Server / RDS
CREATE LOGIN claude_ro WITH PASSWORD = 'a-long-random-Passw0rd!';
USE AppDb;
CREATE USER claude_ro FOR LOGIN claude_ro;
ALTER ROLE db_datareader ADD MEMBER claude_ro;

-- Azure SQL Database (contained user, run in the database)
CREATE USER claude_ro WITH PASSWORD = 'a-long-random-Passw0rd!';
ALTER ROLE db_datareader ADD MEMBER claude_ro;

To hide sensitive tables, skip db_datareader and grant SELECT on specific schemas instead, for example GRANT SELECT ON SCHEMA::sales TO claude_ro;.

Step 2: add the database to AI2SQL

Sign in at builder.ai2sql.io, open Connections, pick SQL Server and enter the host, port (usually 1433), database and the claude_ro login. If the server only listens on localhost or inside a private network, use the desktop connector instead.

Step 3: add the connector

claude.ai or Claude Desktop

  1. Open Customize → Connectors.
  2. Add AI2SQL from the directory, or choose Add custom connector and paste the URL below.
  3. Press Connect, sign in to AI2SQL and press Allow.
https://builder.ai2sql.io/api/claude-mcp

Claude Code

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

Then run /mcp, pick ai2sql and choose Authenticate.

Cursor

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

Add it to ~/.cursor/mcp.json, then click Needs login next to ai2sql in Settings → MCP. More in Cursor MCP SQL server.

Step 4: ask a question

Try "Use AI2SQL to describe my SQL Server database and show the top 10 customers by revenue this quarter." Claude reads the real schema with describe_schema, writes T-SQL and runs it with run_query, up to 1,000 rows.

What keeps it safe

AI2SQL or Microsoft's SQL MCP Server?

Microsoft's SQL MCP Server (part of Data API builder) is self-hosted and exposes the tables and views you configure as typed operations. It suits teams that want to run and govern their own server. AI2SQL is hosted: no server to run, natural-language questions over the whole readable schema, OAuth sign-in from Claude and Cursor, and an audit log. If you only need Claude to answer questions from SQL Server data, the hosted connector is the shorter path.

Frequently asked

Is there an MCP server for SQL Server that works with Claude? +

Yes. The AI2SQL connector is a hosted MCP server that works with claude.ai, Claude Desktop, Claude Code and Cursor. Add your SQL Server database in AI2SQL, then add the connector URL https://builder.ai2sql.io/api/claude-mcp to Claude and sign in. Microsoft also publishes a self-hosted SQL MCP Server in Data API builder if you prefer to run your own.

Can Claude change data in my SQL Server database? +

Not through AI2SQL. run_query accepts one SELECT or WITH statement and rejects INSERT, UPDATE, DELETE, MERGE and DDL before they reach SQL Server. Connect with a login that is only in db_datareader so the database refuses writes as well.

Does it work with Azure SQL Database and Amazon RDS for SQL Server? +

Yes, as long as AI2SQL can reach the server over the network. On Azure SQL Database, create a contained database user with a password instead of a server login. A SQL Server on localhost or a private network needs the AI2SQL desktop connector.

Do I put my SQL Server password in Claude's config? +

No. You enter it once in AI2SQL, where it is encrypted. Claude and Cursor sign in to AI2SQL with OAuth and only hold a token you can revoke.

What does it cost? +

Signing in, listing connections, reading schemas, the demo_shop sample 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.

Let Claude answer from your SQL Server data

Connect SQL Server, add one connector, sign in. Read-only and logged from the first query.

Connect SQL Server free →

Related guides