Featured

Deploy OpenClaw in 60 seconds — 20% off logoDeploy OpenClaw in 60 seconds — 20% off

Launch OpenClaw on Hostinger in about 60 seconds and keep your agent live 24/7. Our referral link gives you 20% off, no coupon code needed.

Launch on Hostinger
Run your Hermes agent on Hostinger, fully managed logoRun your Hermes agent on Hostinger, fully managed

Launch Hermes on Hostinger in one click, fully managed, no VPS knowledge needed. Use code ZACAARON10 for 10% off.

Launch on Hostinger
Crawl and scrape any site into clean data, 10% off logoCrawl and scrape any site into clean data, 10% off

Firecrawl crawls and scrapes any site into clean markdown for your agent. Get 1,000 free credits, and new users get 10% off their first purchase.

Try Firecrawl free
6,000+ web scrapers for your AI agent, start free logo6,000+ web scrapers for your AI agent, start free

Apify gives your agent live web data: 6,000+ prebuilt scrapers and actors, MCP-ready. Sign up free with $5 in usage credits.

Try Apify free
One API to scrape, enrich, and extract the internet. logoOne API to scrape, enrich, and extract the internet.

Context.dev gives your agents a single API to scrape, enrich, and extract live web data — no proxies, no parsers, no maintenance.

Start building free
SetupClaw: done-for-you OpenClaw for founders & exec teams logoSetupClaw: done-for-you OpenClaw for founders & exec teams

White-glove OpenClaw for founders and exec teams (4–50+ employees): we install, harden, integrate your tools, and maintain it — secured from day one.

Get it set up for you
SEO data APIs for your agent, $1 free credit logoSEO data APIs for your agent, $1 free credit

DataForSEO gives your agent live access to SERP results, keyword data, backlinks, and on-page SEO data through one API. New accounts get a $1 credit, good for up to 20,000 keyword or backlink lookups.

Try DataForSEO free
Reach 48,000+ AI builders

A flat monthly placement in front of developers actively installing AI tools. No lock-in, cancel anytime.

Advertise here

Works with

Claude CodeClaude DesktopCursorVS CodeClineCodex CLIOpenClaw+ any MCP client

Install to Claude Code

This server doesn't publish a one-line install command. Follow the setup in the source repository.

Summary

Enables Cursor AI to interact with SQL Server databases, including querying, schema exploration, report generation, and chart creation.

README.md

SQL Server MCP Server for Cursor

A local Model Context Protocol (MCP) server that enables Cursor AI to interact with SQL Server databases. This MCP server provides comprehensive database capabilities including querying, reporting, and chart generation directly within Cursor.

What is This?

This is a local MCP server that you install and configure in Cursor to give the AI assistant the ability to:

  • Connect to your SQL Server databases
  • Execute SQL queries
  • Explore database schemas and tables
  • Generate reports and visualizations
  • Export data in various formats

All database operations happen through Cursor's AI interface - you can ask the AI to query your databases, generate reports, or create charts.

Quick Start Guide

Step 1: Install and Build

  1. Install dependencies:
   npm install
  1. Generate Prisma client:
   npm run prisma:generate
  1. Build the project:
   npm run build

Step 2: Configure in Cursor

  1. Open Cursor Settings:
  • Press Ctrl+, (or Cmd+, on Mac) to open settings
  • Click on the {} icon to open JSON settings
  1. Add the MCP server configuration:

Find or create the mcpServers section and add: ``json { "mcpServers": { "sql-server": { "command": "node", "args": ["D:\\Work\\Code\\Projects\\local_MCPs\\SQLMCP\\dist\\index.js"] } } } ``

Important: Replace the path with your actual project path. On Windows, use double backslashes \\ or forward slashes /.

  1. Restart Cursor to load the MCP server

Step 3: Configure Database Connections

You have two options for connecting to databases:

Option A: Automatic Connection (Recommended)

Create a .env file in the project root directory:

# Format: DATABASE_URL_<connectionId>
# Use any name you want for <connectionId> - this will be how you reference the database

DATABASE_URL_production=sqlserver://server:1433;database=ProductionDB;user=admin;password=YourPassword;encrypt=true
DATABASE_URL_staging=sqlserver://server:1433;database=StagingDB;user=admin;password=YourPassword;encrypt=true
DATABASE_URL_local=sqlserver://localhost:1433;database=LocalDB;user=sa;password=YourPassword;encrypt=true

Connection String Format: `` sqlserver://[server]:[port];database=[database];user=[username];password=[password];encrypt=true ``

After creating .env:

  • Restart Cursor (or the MCP server)
  • Databases will automatically connect
  • Use the connectionId (e.g., production, staging, local) when asking the AI to query databases

Option B: Manual Connection

You can connect to databases on-demand by asking the AI to use the connect_database tool with your connection string.

Step 4: Using the MCP Server

Once configured, you can use the MCP server by simply asking Cursor's AI to interact with your databases. Here are some examples:

Example 1: List Tables

"List all tables in the production database"

The AI will use the list_tables tool with connectionId: "production"

Example 2: Query Data

"Show me the top 10 customers from the production database"

The AI will execute a SQL query like: ``sql SELECT TOP 10 * FROM Customers ORDER BY ... ``

Example 3: Get Table Structure

"What columns are in the Orders table in production?"

The AI will use get_table_structure to show you the table schema

Example 4: Generate a Report

"Generate a report of all orders from 2024 in the production database"

Example 5: Create a Chart

"Create a bar chart showing monthly sales from the Sales table in production, using Month as labels and Revenue as data"

Example 6: Export Data

"Export the Customers table from production as CSV"

Available Tools

The MCP server provides these tools (you can ask the AI to use them):

  1. list_connections - See all connected databases
  2. list_tables - List all tables in a database
  3. get_table_structure - Get detailed table schema
  4. list_schemas - List all database schemas
  5. execute_query - Run SQL queries (SELECT, INSERT, UPDATE, DELETE, EXEC)
  6. generate_report - Generate data reports from tables
  7. generate_chart_report - Create charts (bar, line, pie, scatter, doughnut, area)
  8. export_report - Export data as JSON or CSV
  9. connect_database - Manually connect to a database
  10. disconnect_database - Disconnect from a database

Features

  • Multiple Database Connections: Connect to multiple SQL Server databases simultaneously
  • Automatic Connection: Auto-connect databases from .env file on startup
  • SQL Query Execution: Run any SQL query (SELECT, INSERT, UPDATE, DELETE, EXEC)
  • Schema Exploration: Browse tables, columns, and database structure
  • Report Generation: Create data reports with filtering and limits
  • Chart Visualization: Generate various chart types (bar, line, pie, etc.)
  • Data Export: Export data in JSON or CSV formats
  • Security: SQL injection protection and input validation

Troubleshooting

MCP Server Not Loading

  • Verify the path in Cursor settings is correct
  • Make sure you've run npm run build
  • Check Cursor's MCP server logs (usually in the output panel)

Connection Errors

  • Verify your connection string format is correct
  • Check that your SQL Server is accessible
  • Ensure credentials are correct
  • Try connecting manually first using connect_database tool

Database Not Found

  • If using .env file, make sure variable names start with DATABASE_URL_
  • Restart Cursor after adding databases to .env
  • Check that the connectionId matches (e.g., DATABASE_URL_prod → use prod as connectionId)

Query Errors

  • Verify your SQL syntax is correct
  • Check that you have proper database permissions
  • Ensure table and column names are spelled correctly

Development

Project Structure

SQLMCP/
├── src/
│   ├── server/          # MCP server implementation
│   ├── database/        # Database connection management
│   ├── reporting/       # Report generation
│   └── charts/          # Chart generation
├── dist/                # Compiled JavaScript
├── prisma/              # Prisma schema
└── package.json

Building

npm run build

Development Mode

npm run dev

Security Notes

  • Connection strings in .env files should be kept secure
  • Never commit .env files to version control
  • All SQL inputs are validated to prevent injection attacks
  • Only SELECT, INSERT, UPDATE, DELETE, and EXEC statements are allowed
  • Table and column names are sanitized

License

MIT

"# SQL-MCP"

See related servers & alternatives →

Related MCP servers

Browse all →

Related guides

Hand-picked reading to help you choose and use Databases servers.