sqlserver
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@sqlserver List all tables in the database"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
MCP SQL Server Server
A Model Context Protocol (MCP) server that provides tools to interact with SQL Server databases. This server allows Cursor and other MCP clients to query, analyze, and manage SQL Server data intelligently.
Features
Execute SQL Queries: Run SELECT queries safely to retrieve data
List Tables: Discover all tables in the database
Get Table Schema: Inspect table structure, columns, and data types
Get Table Statistics: View row counts and column information
Insert Data: Add new records to tables
Update Data: Modify existing records
Related MCP server: Python MSSQL MCP Server
Prerequisites
Node.js v22.14.0 or higher
Docker version 28.3.3 or higher
SQL Server running in Docker (or access to an existing SQL Server instance)
Step-by-Step Setup Guide
Step 1: Install Dependencies
npm installThis will install all required packages including:
@modelcontextprotocol/sdk- MCP SDK for building the servermssql- SQL Server driver for Node.jstypescript- TypeScript compilertsx- TypeScript execution environment
Step 2: Start SQL Server with Docker
The project includes a docker-compose.yml file that will automatically:
Start SQL Server 2022
Create the
SampleDBdatabaseCreate sample tables (Customers, Products, Orders, OrderItems)
Insert sample data
Start the SQL Server container:
docker-compose up -dVerify the container is running:
docker psYou should see a container named mcp-sqlserver running.
Wait for initialization: The database initialization script runs automatically. You can check the logs:
docker logs mcp-sqlserverNote: The default password is YourStrong@Passw0rd. If you need to change it, update both docker-compose.yml and .env files.
Step 3: Configure Environment Variables
Copy the example environment file:
copy .env.example .envEdit .env and ensure the connection details match your Docker setup:
SQL_SERVER_HOST=localhost
SQL_SERVER_PORT=1433
SQL_SERVER_DATABASE=SampleDB
SQL_SERVER_USER=sa
SQL_SERVER_PASSWORD=YourStrong@Passw0rd
SQL_SERVER_ENCRYPT=falseStep 4: Build the MCP Server
Compile the TypeScript code:
npm run buildThis creates the dist/ directory with the compiled JavaScript.
Step 5: Test the MCP Server
You can test the server manually to ensure it works:
npm startThe server will start and listen on stdio (standard input/output). Press Ctrl+C to stop.
Step 6: Configure Cursor IDE
To use this MCP server in Cursor, you need to add it to Cursor's MCP configuration.
Option A: Using Cursor Settings UI
Open Cursor IDE
Go to Settings (Ctrl+,)
Search for "MCP" or "Model Context Protocol"
Click on "MCP Servers" or "Add MCP Server"
Add a new server with these settings:
Name:
sqlserverCommand:
nodeArgs:
["dist/index.js"]Working Directory:
C:\OrgProjects\SkillUps\ModelContextProtocol(or your actual project path)Environment Variables:
SQL_SERVER_HOST=localhostSQL_SERVER_PORT=1433SQL_SERVER_DATABASE=SampleDBSQL_SERVER_USER=saSQL_SERVER_PASSWORD=YourStrong@Passw0rdSQL_SERVER_ENCRYPT=false
Option B: Using Configuration File (Windows)
Navigate to Cursor's configuration directory:
%APPDATA%\Cursor\User\globalStorage\saoudrizwan.claude-dev\settings\Edit or create
cline_mcp_settings.jsonand add:
{
"mcpServers": {
"sqlserver": {
"command": "node",
"args": ["C:\\\\OrgProjects\\\\SkillUps\\\\ModelContextProtocol\\\\dist\\\\index.js"],
"env": {
"SQL_SERVER_HOST": "localhost",
"SQL_SERVER_PORT": "1433",
"SQL_SERVER_DATABASE": "SampleDB",
"SQL_SERVER_USER": "sa",
"SQL_SERVER_PASSWORD": "YourStrong@Passw0rd",
"SQL_SERVER_ENCRYPT": "false"
}
}
}
}Important: Replace C:\\OrgProjects\\SkillUps\\ModelContextProtocol with your actual project path.
Restart Cursor IDE for changes to take effect.
Step 7: Verify MCP Server in Cursor
Restart Cursor after adding the configuration
Open a chat in Cursor
Try asking questions like:
"List all tables in the database"
"Show me the schema of the Customers table"
"Get statistics for the Products table"
"Run a query to show all customers"
"Show me customers from New York"
The AI should now be able to use the MCP tools to interact with your SQL Server database!
Available MCP Tools
1. execute_query
Execute a SELECT query to retrieve data.
Example:
{
"query": "SELECT TOP 10 * FROM Customers"
}2. list_tables
List all tables in the database.
Example:
{}3. get_table_schema
Get the schema of a specific table.
Example:
{
"tableName": "Customers"
}4. get_table_stats
Get statistics about a table (row count, columns).
Example:
{
"tableName": "Products"
}5. execute_insert
Insert a new record into a table.
Example:
{
"tableName": "Customers",
"data": {
"FirstName": "John",
"LastName": "Doe",
"Email": "john.doe@example.com",
"City": "Seattle"
}
}6. execute_update
Update existing records in a table.
Example:
{
"tableName": "Customers",
"data": {
"City": "Portland"
},
"where": {
"CustomerID": 1
}
}Sample Database Schema
The initialization script creates a sample e-commerce database with:
Customers: Customer information
Products: Product catalog
Orders: Customer orders
OrderItems: Order line items
Development
Run in Development Mode
npm run devThis uses tsx watch to automatically recompile on file changes.
Project Structure
.
├── src/
│ └── index.ts # Main MCP server implementation
├── dist/ # Compiled JavaScript (generated)
├── init-db/ # SQL initialization scripts
│ └── 01-init-sample-db.sql
├── docker-compose.yml # Docker setup for SQL Server
├── package.json # Node.js dependencies
├── tsconfig.json # TypeScript configuration
└── README.md # This fileTroubleshooting
SQL Server Connection Issues
Check if SQL Server is running:
docker psCheck SQL Server logs:
docker logs mcp-sqlserverVerify connection details in
.envmatch your Docker setupTest connection manually:
docker exec -it mcp-sqlserver /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P YourStrong@Passw0rd -Q "SELECT @@VERSION"
MCP Server Not Appearing in Cursor
Verify the path in the configuration is correct and absolute
Check that the build succeeded:
npm run buildEnsure the server starts without errors:
npm startRestart Cursor after configuration changes
Check Cursor's developer console for MCP-related errors
Permission Issues
Ensure SQL Server credentials are correct
Verify the database exists and is accessible
Check that the SA password matches in both
docker-compose.ymland.env
Security Notes
Never commit
.envfiles to version controlThe
execute_querytool only allows SELECT queries for securityUse strong passwords in production
Consider using environment-specific configurations
Next Steps
Explore the sample data using natural language queries in Cursor
Try asking complex questions that require joins
Add more tables or modify the schema as needed
Extend the MCP server with additional tools for your use case
License
MIT
Available Tools
6 toolsexecute_insertA
Insert data into a table. Returns the inserted row ID if available.
Inputs: data (required), tableName (required).
execute_queryA
Execute a SQL query and return results. Use for SELECT queries to retrieve data.
Inputs: query (required).
execute_updateB
Update data in a table. Returns the number of affected rows.
Inputs: data (required), where (required), tableName (required).
get_table_schemaA
Get the schema/structure of a table including column names, types, and constraints
Inputs: tableName (required).
get_table_statsB
Get statistics about a table including row count and column information
Inputs: tableName (required).
list_tablesA
List all tables in the database
Inputs: no named parameters.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 6 tools
Each tool targets a distinct action: SELECT retrieval, listing tables, schema inspection, statistics, inserts, and updates. There is no overlap between query, DML, and metadata operations, making selection straightforward.
Naming mixes execute_query/execute_insert/execute_update with list_tables and get_table_schema/get_table_stats. The pattern is not uniform (execute_ vs list_ vs get_table_), though it remains readable and predictable within subgroups.
Six tools is a well-scoped set for a SQL server, covering query, data modification, and metadata needs without excessive surface area.
The toolset covers SELECT, INSERT, UPDATE, and metadata, but lacks a DELETE operation, DDL support (CREATE/ALTER/DROP), and transaction control. These are significant gaps that will hinder common database workflows.
Maintenance
Related MCP Connectors
Query, explore, and manage your databases through natural conversation.
Text-to-SQL MCP server: read-only queries on PostgreSQL, MySQL and SQL Server with your real schema
Hosted SQL Server MCP server for Claude, ChatGPT and Cursor, with each action switched per account.
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
Related MCP Servers
- AlicenseBqualityDmaintenanceA Model Context Protocol server that enables AI assistants (Cursor, Windsurf, Claude Code) to interact with Microsoft SQL Server databases by providing connectivity through environment-configurable connections.8601 npm8MIT
- FlicenseNot gradedqualityDmaintenanceEnables Language Models to interact with Microsoft SQL Server databases by inspecting table schemas, executing SQL queries, and reading table data through a standardized Model Context Protocol interface.27-
- FlicenseAqualityDmaintenanceEnables AI assistants to query SQL Server databases and retrieve schema information securely through the Model Context Protocol.2-
- FlicenseCqualityDmaintenanceEnables AI assistants to analyze and query SQL Server databases, including schema discovery, health checks, and data retrieval.10-