MSSQL MCP Server
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., "@MSSQL MCP Server show me the tables in the Sales database with row counts"
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.
MSSQL MCP Server
MCP (Model Context Protocol) server for Microsoft SQL Server. Provides AI assistants with read-only access to SQL Server for query execution, performance analysis, health monitoring, and troubleshooting.
Features
Connection & Discovery
test_connection - Verify SQL Server connectivity and authentication
list_databases - List all databases with status and size
get_server_info - Server version, edition, and configuration
Query Execution
execute_query - Run read-only SELECT queries (INSERT/UPDATE/DELETE blocked)
get_expensive_queries - Find resource-intensive queries from plan cache
get_running_queries - View currently executing queries
Schema Exploration
get_tables - List tables with row counts, sizes, and metadata
get_columns - Column definitions for a table (types, keys, defaults)
get_stored_procedures - List and view stored procedure code
get_functions - List and view user-defined function code
get_views - List and view definitions
get_foreign_keys - Table relationships and constraints
get_indexes - Index definitions with included columns
get_triggers - Table triggers with event types
get_connected_users - Active sessions and connections
Performance Analysis
get_blocking - Identify blocking chains and deadlocks
get_wait_stats - Analyze wait statistics for bottlenecks
get_cpu_usage - CPU usage history from ring buffer
get_index_usage - Find unused or missing indexes
Health Monitoring
get_database_states - Database health and status
get_disk_space - Data and log file space usage
get_memory_usage - Buffer pool and memory clerk stats
get_log_space - Transaction log usage
get_backup_status - Last backup times and status
SQL Agent Jobs
list_jobs - All SQL Agent jobs with status
get_running_jobs - Currently executing jobs
get_failed_jobs - Recent job failures
get_job_history - Execution history for a job
Availability Groups
get_ag_status - Always On AG health and sync status
get_replica_states - Detailed replica information
get_cluster_status - WSFC cluster status
Related MCP server: Microsoft SQL Server MCP Server
Installation
npx @elad-nofy/mssql-mcpConfiguration
Environment Variables
# Required
MSSQL_HOST=your-server.domain.com
# Optional
MSSQL_PORT=1433 # Default: 1433
MSSQL_DATABASE=master # Default: master
# Authentication - Windows Auth (default)
# Leave MSSQL_USER and MSSQL_PASSWORD empty for Windows Authentication
# Authentication - SQL Auth
MSSQL_USER=your_username
MSSQL_PASSWORD=your_password
# Connection Options
MSSQL_ENCRYPT=false # Default: false
MSSQL_TRUST_SERVER_CERTIFICATE=true # Default: true
MSSQL_CONNECTION_TIMEOUT=30000 # Default: 30000ms
MSSQL_REQUEST_TIMEOUT=30000 # Default: 30000msClaude Code CLI
Windows:
{
"mcpServers": {
"mssql": {
"command": "cmd",
"args": ["/c", "npx", "@elad-nofy/mssql-mcp"],
"env": {
"MSSQL_HOST": "your-server.domain.com"
}
}
}
}macOS/Linux:
{
"mcpServers": {
"mssql": {
"command": "npx",
"args": ["@elad-nofy/mssql-mcp"],
"env": {
"MSSQL_HOST": "your-server.domain.com"
}
}
}
}Windows Authentication
For Windows Authentication, run the MCP server under an account with SQL Server access. The server will use the process credentials automatically.
Required Permissions
The SQL Server login needs these permissions:
VIEW SERVER STATE- For DMVs (wait stats, blocking, etc.)VIEW DATABASE STATE- For database-level DMVsSELECTonmsdb- For SQL Agent job information
Example:
USE master;
CREATE LOGIN [DOMAIN\ServiceAccount] FROM WINDOWS;
GRANT VIEW SERVER STATE TO [DOMAIN\ServiceAccount];
GRANT VIEW ANY DATABASE TO [DOMAIN\ServiceAccount];
USE msdb;
CREATE USER [DOMAIN\ServiceAccount] FOR LOGIN [DOMAIN\ServiceAccount];
GRANT SELECT ON SCHEMA::dbo TO [DOMAIN\ServiceAccount];Example Usage
Explore Database Schema
"What tables are in the Orders database?"
→ Uses get_tables to list all tables with row counts
"Show me the columns in the Customers table"
→ Uses get_columns to show column definitions
"What stored procedures exist for order processing?"
→ Uses get_stored_procedures with name filter
"How are the tables related?"
→ Uses get_foreign_keys to map relationshipsInvestigate Performance Issues
"Check for blocking on PROD-SQL-01"
→ Uses get_blocking to show blocking chains
"What are the top CPU-consuming queries?"
→ Uses get_expensive_queries sorted by CPU
"Show me the wait stats"
→ Uses get_wait_stats to identify bottlenecksHealth Check
"Are all databases healthy?"
→ Uses get_database_states to check status
"When was the last backup for each database?"
→ Uses get_backup_status to show backup times
"Check disk space on SQL Server"
→ Uses get_disk_space for file usageTroubleshoot Jobs
"What jobs failed in the last 24 hours?"
→ Uses get_failed_jobs to show failures
"Is the nightly backup job running?"
→ Uses get_running_jobs to check statusTroubleshooting
Connection Issues
"Login failed for user"
Verify SQL Server allows the authentication type (Windows/SQL)
Check the account has server-level permissions
For Windows Auth, ensure the process runs as the correct user
"Connection timeout"
Verify network connectivity to SQL Server
Check firewall allows port 1433 (or custom port)
Increase
MSSQL_CONNECTION_TIMEOUTif needed
"Cannot open database"
Verify the account has access to the database
Check database is online:
SELECT state_desc FROM sys.databases
Permission Errors
"The server principal is not able to access the database"
Create a user in the target database for the login
Grant appropriate permissions
"VIEW SERVER STATE permission denied"
Grant at server level:
GRANT VIEW SERVER STATE TO [login]
Development
# Install dependencies
npm install
# Build
npm run build
# Run in development (watch mode)
npm run devSecurity Notes
Read-only by design - Only SELECT queries are allowed
No secrets in code - All credentials via environment variables
Parameterized queries - Protection against SQL injection
Blocked dangerous operations - INSERT, UPDATE, DELETE, EXEC prevented
Graceful shutdown - Connection pool properly closed on exit
License
MIT
Available Tools
31 toolsexecute_queryB
Execute a read-only SQL query. Only SELECT statements are allowed for safety.
Inputs: query (required), server, maxRows, database.
get_ag_statusC
Get Always On Availability Group status and health
Inputs: server.
get_backup_statusC
Get last backup information for all databases
Inputs: server, maxAgeDays.
get_blockingC
Get current blocking chains showing blocked and blocking sessions
Inputs: server.
get_cluster_statusB
Get Windows Server Failover Cluster status for the SQL Server instance
Inputs: server.
get_columnsC
Get column definitions for a specific table
Inputs: table (required), database (required), schema, server.
get_connected_usersC
Get currently connected users and sessions
Inputs: server, database, activeOnly.
get_cpu_usageB
Get CPU usage history for SQL Server from ring buffer
Inputs: server, minutes.
get_database_statesB
Get the health status of all databases including any that are offline, recovering, or suspect
Inputs: server.
get_disk_spaceB
Get disk space usage for all database files including data and log files
Inputs: server, database.
get_expensive_queriesB
Get the most resource-intensive queries from the query store or plan cache
Inputs: top, metric, server.
get_failed_jobsC
Get jobs that failed in their last execution or recent history
Inputs: hours, server.
get_foreign_keysB
Get foreign key relationships between tables
Inputs: database (required), table, server.
get_functionsB
List user-defined functions with optional code view
Inputs: database (required), type, schema, server, +1 more.
get_indexesC
Get index information for tables
Inputs: database (required), table, schema, server.
get_index_usageB
Get index usage statistics to identify unused or missing indexes
Inputs: database (required), server, showUnused.
get_job_historyC
Get execution history for a specific job
Inputs: jobName (required), top, server.
get_log_spaceC
Get transaction log space usage for all databases
Inputs: server.
get_memory_usageB
Get SQL Server memory usage including buffer pool, plan cache, and other memory clerks
Inputs: server.
get_replica_statesC
Get detailed state information for all availability group replicas
Inputs: agName, server.
get_running_jobsB
Get currently executing SQL Server Agent jobs
Inputs: server.
get_running_queriesB
Get currently executing queries with their status and resource usage
Inputs: server, includeSystem.
get_server_infoA
Get SQL Server instance information including version, edition, and configuration
Inputs: server.
get_stored_proceduresC
List stored procedures with optional code view
Inputs: database (required), name, schema, server, +1 more.
get_tablesB
List all tables in a database with row counts, sizes, and metadata
Inputs: database (required), schema, server, includeRowCounts.
get_triggersC
List triggers in a database
Inputs: database (required), table, server, includeDefinition.
get_viewsC
List views with optional definition
Inputs: database (required), schema, server, includeDefinition.
get_wait_statsB
Get aggregated wait statistics to identify performance bottlenecks
Inputs: top, server, excludeIdle.
list_databasesB
List all databases on the SQL Server instance with their status and size
Inputs: server, includeSystem.
list_jobsB
List all SQL Server Agent jobs with their status and schedule
Inputs: server, enabledOnly.
test_connectionB
Test the connection to SQL Server and verify authentication
Inputs: server.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 31 tools
Most tools target a clearly distinct resource+action (jobs vs queries vs indexes vs disk vs memory), but a few boundaries blur: list_databases already reports status/size while get_database_states reports health, and get_failed_jobs overlaps with get_job_history since failed jobs are derived from history. get_running_queries vs get_expensive_queries also needs the descriptions to separate current-execution from historical-cost.
Nearly everything follows a clean get_/list_ snake_case pattern with descriptive qualifiers (get_wait_stats, get_backup_status). The only minor deviation is list_ vs get_ for collection tools (list_databases and list_jobs use list_, while get_tables, get_views, get_indexes are also collections), plus two singletons (test_connection, execute_query).
31 tools is heavy for a single server and exceeds the comfortable range, but they group into coherent families (schema, Agent jobs, Always On/cluster, performance, storage/backup) rather than being ad hoc. Trimming overlapping diagnostics would tighten the surface considerably.
The read-only diagnostics domain is covered broadly: connectivity, instance/server info, schema, jobs, availability groups, live performance, blocking, waits, and storage/backup all have entries. Minor gaps remain (no partitions/statistics or parameter discovery for procedures, no error-log or deadlock-graph tool), but core DBA triage workflows are reachable.
Maintenance
Related MCP Connectors
Safe, read-only Postgres and MySQL access for AI agents. Audit log + column-level controls.
PostgreSQL, MySQL, and SQL Server in one session. 26 read-only MCP tools for AI agents.
Ask your AI assistant about your logs, traces, security events, robot runs and video. Read-only.
Ask your AI about your Airbnb and VRBO listings, bookings, guest messages and reviews. Read-only.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceProvides read-only access to Microsoft SQL Server databases using Windows Authentication, enabling AI assistants to safely explore schemas and query data with built-in security controls.1MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to connect and query Microsoft SQL Server databases using natural language, executing read-only SQL queries for safe data inspection and analysis.MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to securely interact with Microsoft SQL Server databases to query data, inspect schemas, and retrieve metadata with read-only operations by default and optional write capabilities.1MIT
- FlicenseCqualityDmaintenanceEnables AI assistants to analyze and query SQL Server databases, including schema discovery, health checks, and data retrieval.10-