mcp-sqlserver
MCP server for Microsoft SQL Server
Install / Use
claude mcp add bilims -- npx -y github:bilims/mcp-sqlserverIf the server publishes to npm under a different name, use that package instead — check the repo README.
MCP Server
Model Context Protocol server
Quality Score
Category
Data & AnalyticsSupported Platforms
Our assessment of mcp-sqlserver
mcp-sqlserver scores 68/100 on our quality scale, 551st of 587 Data & Analytics skills we index.
Its MCP Server is 9.2 KB long, well organised into 61 sections with 22 code examples: a thorough specification that gives an agent plenty to work with.
It has 43 GitHub stars, so there is little community track record yet; judge it on its content.
Maintenance, license and trust
- The repository was last updated about 6 months ago. That is recent enough to be usable, but agent tooling moves fast, so check the instructions against your agent's current version.
- It is released under the MIT license, a permissive license that allows use, modification and commercial use with attribution.
- Its trust signals score 86/100, with 2 cautions from licensing, adoption, age or documentation. These come from repository metadata, not a code audit — read the skill file before letting an agent act on it.
mcp-sqlserver compared with similar skills
All 4 of these similar skills score higher than mcp-sqlserver; compare them before choosing.
| Skill | Score | Stars | Updated | Format |
|---|---|---|---|---|
| mcp-sqlserver (this skill)by bilims | 68 | 43 | 6mo ago | MCP Server |
| claude-memby thedotmack | 100 | 96.6k | today | CLAUDE.md |
| Agent-Reachby Panniantong | 100 | 91.8k | 20d ago | CLAUDE.md |
| headroomby headroomlabs-ai | 100 | 74.5k | today | CLAUDE.md |
| CowAgentby zhayujie | 100 | 47.2k | today | CLAUDE.md |
Frequently asked questions
- How do I install mcp-sqlserver?
- Run
claude mcp add bilims -- npx -y github:bilims/mcp-sqlserver. The install tabs above show the steps for each supported agent. - Which AI agents does mcp-sqlserver work with?
- It is written for Claude Code, Claude Desktop, Gemini CLI and OpenAI Codex, as a MCP Server file. Other agents that read the same format can often use it too.
- Is mcp-sqlserver safe to use?
- It is MIT-licensed and scores 86/100 on trust signals. Skills are instructions an agent will follow, so read the file before installing it and do not approve commands you do not understand.
- Is mcp-sqlserver still maintained?
- The repository was last updated about 6 months ago. That is recent enough to be usable, but agent tooling moves fast, so check the instructions against your agent's current version.
Skill content
View source on GitHubMCP SQL Server
A read-only Model Context Protocol (MCP) server for Microsoft SQL Server that enables AI agents to safely explore and query SQL Server databases.
Quick Start
Step 1: Install the Package
# Global installation (recommended)
npm install -g @bilims/mcp-sqlserver
# Verify installation
mcp-sqlserver --version
Step 2: Configure Your SQL Server Connection
Choose your SQL Server type and follow the configuration:
Azure SQL Database
export SQLSERVER_HOST="your-server.database.windows.net"
export SQLSERVER_USER="your-username"
export SQLSERVER_PASSWORD="your-password"
export SQLSERVER_DATABASE="your-database"
export SQLSERVER_ENCRYPT="true"
export SQLSERVER_TRUST_CERT="false"
On-Premises SQL Server
export SQLSERVER_HOST="your-sql-server.company.com"
export SQLSERVER_USER="your-username"
export SQLSERVER_PASSWORD="your-password"
export SQLSERVER_DATABASE="your-database"
export SQLSERVER_ENCRYPT="true"
export SQLSERVER_TRUST_CERT="true" # For self-signed certificates
Local SQL Server Express
export SQLSERVER_HOST="localhost\\SQLEXPRESS"
export SQLSERVER_USER="sa"
export SQLSERVER_PASSWORD="your-password"
export SQLSERVER_DATABASE="master"
export SQLSERVER_ENCRYPT="false"
export SQLSERVER_TRUST_CERT="true"
Step 3: Test the Connection
# Test your configuration
mcp-sqlserver --help
# Quick connection test (press Ctrl+C to exit)
mcp-sqlserver
Step 4: Add to Claude Desktop
-
Find your Claude Desktop config file:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json
- macOS:
-
Add the MCP server configuration:
{
"mcpServers": {
"sqlserver": {
"command": "mcp-sqlserver",
"env": {
"SQLSERVER_HOST": "your-server.database.windows.net",
"SQLSERVER_USER": "your-username",
"SQLSERVER_PASSWORD": "your-password",
"SQLSERVER_DATABASE": "your-database",
"SQLSERVER_ENCRYPT": "true",
"SQLSERVER_TRUST_CERT": "false"
}
}
}
}
- Restart Claude Desktop
Step 5: Start Exploring!
Try these commands in Claude Desktop:
"Test the SQL Server connection""List all databases on the server""Show me the tables in [database name]""Describe the structure of the Users table""Show me foreign key relationships"
Features
- 🔒 Read-only operations: Only SELECT queries allowed, with comprehensive security validation
- 🗄️ Schema discovery: Explore databases, tables, views, relationships, and metadata
- 📊 Data exploration: Execute safe queries with built-in limits and timeouts
- 🔐 Enterprise-ready: Encrypted connections with certificate trust for production environments
- 🛡️ Security-first: Query validation, SQL injection protection, and access controls
Available Tools
Schema Discovery
list_databases- List all databases on the SQL Server instancelist_tables- List tables in a database or schemalist_views- List views in a database or schemadescribe_table- Get detailed table schema including columns, data types, and constraints
Relationship Analysis
get_foreign_keys- Get foreign key relationships for tablesget_table_stats- Get table statistics including row counts and size information
Data Exploration
execute_query- Execute read-only SELECT queries with safety validationget_server_info- Get SQL Server version, edition, and configuration details
Common Commands for Claude Desktop
Once your MCP server is configured, try these natural language commands:
Getting Started Commands
"Test the SQL Server connection"
"Show me server information"
"List all databases on this server"
"What tables are in the [database name] database?"
Database Exploration
"Describe the structure of the Users table"
"Show me foreign key relationships in this database"
"What are the largest tables by row count?"
"Give me a sample of data from the Orders table"
Advanced Analysis
"Help me understand the relationship between Orders and Customers"
"Show me all lookup tables in this database"
"What columns contain date/time information?"
"Find tables that might contain user authentication data"
Custom Queries
"Run this query: SELECT TOP 10 * FROM Products WHERE Price > 100"
"Show me all customers created in the last 30 days"
"What are the different product categories in the database?"
Installation
npm install
npm run build
Configuration
The server is configured using environment variables:
Required
SQLSERVER_USER- SQL Server usernameSQLSERVER_PASSWORD- SQL Server password
Optional
SQLSERVER_HOST- Server hostname (default: localhost)SQLSERVER_DATABASE- Default database nameSQLSERVER_PORT- Port number (default: 1433)SQLSERVER_ENCRYPT- Enable encryption (default: true)SQLSERVER_TRUST_CERT- Trust server certificate (default: true)SQLSERVER_CONNECTION_TIMEOUT- Connection timeout in ms (default: 30000)SQLSERVER_REQUEST_TIMEOUT- Request timeout in ms (default: 60000)SQLSERVER_MAX_ROWS- Maximum rows per query (default: 1000)
Usage
Environment Variables
export SQLSERVER_HOST="your-server.database.windows.net"
export SQLSERVER_USER="your-username"
export SQLSERVER_PASSWORD="your-password"
export SQLSERVER_DATABASE="your-database"
export SQLSERVER_ENCRYPT="true"
export SQLSERVER_TRUST_CERT="true"
Running the Server
npm start
Installation Options
Option 1: Global Installation (Recommended)
npm install -g @bilims/mcp-sqlserver
Option 2: Local Installation
npm install @bilims/mcp-sqlserver
npx mcp-sqlserver
Option 3: Run with npx (No Installation)
npx @bilims/mcp-sqlserver
Integration Examples
Claude Desktop
Add to your Claude Desktop configuration (claude_desktop_config.json):
{
"mcpServers": {
"sqlserver": {
"command": "mcp-sqlserver",
"env": {
"SQLSERVER_HOST": "your-server.database.windows.net",
"SQLSERVER_USER": "your-username",
"SQLSERVER_PASSWORD": "your-password",
"SQLSERVER_DATABASE": "your-database"
}
}
}
}
Claude Code CLI
# Set environment variables
export SQLSERVER_HOST="your-server"
export SQLSERVER_USER="your-username"
export SQLSERVER_PASSWORD="your-password"
# Use with Claude Code
claude mcp add sqlserver mcp-sqlserver
VSCode with MCP Extension
Install the MCP extension for VSCode and add the server configuration.
Security Features
Query Validation
- Only SELECT, WITH, SHOW, DESCRIBE, and EXPLAIN statements allowed
- Comprehensive blacklist of dangerous keywords (INSERT, UPDATE, DELETE, DROP, etc.)
- SQL injection pattern detection
- Automatic query sanitization
Connection Security
- TLS/SSL encryption enabled by default
- Server certificate trust options for enterprise environments
- Connection pooling with timeout controls
- Configurable request timeouts
Result Limits
- Maximum row limits per query (configurable)
- Automatic TOP clause injection for SELECT queries
- Query execution time tracking
- Memory usage protection
Example Queries
Once connected, you can use the tools through your MCP client:
// List all databases
await callTool("list_databases", {});
// List tables in a specific schema
await callTool("list_tables", { schema: "dbo" });
// Get table schema details
await callTool("describe_table", {
table_name: "Users",
schema: "dbo"
});
// Execute a read-only query
await callTool("execute_query", {
query: "SELECT TOP 10 * FROM Users WHERE active = 1",
limit: 10
});
// Get foreign key relationships
await callTool("get_foreign_keys", {
table_name: "Orders"
});
Development
# Install dependencies
npm install
# Build the project
npm run build
# Run in development mode
npm run dev
# Run linting
npm run lint
# Run tests
npm test
Troubleshooting
Connection Issues
- Verify server hostname and port
- Check if encryption/certificate settings match your SQL Server configuration
- Ensure user has appropriate read permissions
- Test connection using SQL Server Management Studio first
Permission Issues
The user account needs at minimum:
CONNECTpermission to the databaseSELECTpermission on tables/views you want to query- Access to system views for metadata queries
Common SQL Server Configurations
Azure SQL Database
export SQLSERVER_HOST="your-server.database.windows.net"
export SQLSERVER_ENCRYPT="true"
export SQLSERVER_TRUST_CERT="false"
On-premises SQL Server with self-signed certificates
export SQLSERVER_HOST="sql-server.company.com"
export SQLSERVER_ENCRYPT="true"
export SQLSERVER_TRUST_CERT="true"
License
MIT
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
Support
For issues and questions:
- Check the troubleshooting section above
- Review SQL Server connection documentation
- Ensure MCP client compatibility
Built with the Model Context Protocol SDK for seamless AI integration.
Related Skills
claude-mem
96.6kPersistent Context Across Sessions for Every Agent – Captures everything your agent does during sessions, compresses it with AI, and injects relevant context back into future sessions. Works with Claude Code, OpenClaw, Codex, Gemini, Hermes, Copilot, OpenCode + More
Agent-Reach
91.8kGive your AI agent eyes to see the entire internet. Read & search Twitter, Reddit, YouTube, GitHub, Bilibili, XiaoHongShu — one CLI, zero API fees.
headroom
74.5kCompress tool outputs, logs, files, and RAG chunks before they reach the LLM. 20% fewer tokens for coding agents, 60-95% fewer tokens for JSON, same answers. Library, proxy, MCP server.
CowAgent
47.2kOpen-source personal AI assistant & Agent Harness. Plans tasks, runs tools and skills, self-evolves with memory and knowledge. Multi-agent, multi-model, multi-channel. Lightweight, extensible, one-line install.
Languages
Trust signals
From repository metadata: license, adoption, age and documentation. Not a code audit — see the Safety scan above for what the skill file itself contains.
