MS SQL Server MCP Server

MS SQL Server MCP Server

Enables interaction with Microsoft SQL Server and Azure SQL databases through natural language, supporting queries, schema exploration, stored procedures, and complete database operations with connection pooling and security features.

Category
Visit Server

README

MS SQL Server MCP Server v2.1.1

šŸš€ Model Context Protocol (MCP) server for Microsoft SQL Server - compatible with Claude Desktop, Cursor, Windsurf and VS Code.

šŸš€ Quick Start

1. Install

npm install -g mssql-mcp

2. Configure IDE

Claude Desktop (claude_desktop_config.json):

{
  "mcpServers": {
    "mssql": {
      "command": "npx",
      "args": ["-y", "mssql-mcp@latest"],
      "env": {
        "DB_SERVER": "your-server.com",
        "DB_DATABASE": "your-database",
        "DB_USER": "your-username",
        "DB_PASSWORD": "your-password",
        "DB_ENCRYPT": "true",
        "DB_TRUST_SERVER_CERTIFICATE": "true"
      }
    }
  }
}

Cursor/Windsurf/VS Code (.vscode/mcp.json):

{
  "servers": {
    "mssql": {
      "command": "npx",
      "args": ["-y", "mssql-mcp@latest"],
      "env": {
        "DB_SERVER": "your-server.com",
        "DB_DATABASE": "your-database",
        "DB_USER": "your-username",
        "DB_PASSWORD": "your-password",
        "DB_ENCRYPT": "true",
        "DB_TRUST_SERVER_CERTIFICATE": "true"
      }
    }
  }
}

Replace with your actual database credentials.

šŸ› ļø Available Tools

Tool Description
connect_database Connect to database using environment variables
disconnect_database Close current database connection
connection_status Check connection state with pool info
execute_query Execute any SQL query with parameters
get_schema List database objects (tables, views, procedures)
describe_table Get detailed table structure
get_table_data Retrieve data with pagination
execute_procedure Execute stored procedures
list_databases List all databases

šŸ”§ Environment Variables

Variable Required Default Description
DB_SERVER āœ… - SQL Server hostname
DB_DATABASE āŒ - Database name
DB_USER āŒ - Username
DB_PASSWORD āŒ - Password
DB_PORT āŒ 1433 SQL Server port
DB_ENCRYPT āŒ true Enable TLS encryption (required for Azure SQL)
DB_TRUST_SERVER_CERTIFICATE āŒ false Trust self-signed certificates
DB_CONNECTION_TIMEOUT āŒ 30000 Connection timeout (ms)
DB_REQUEST_TIMEOUT āŒ 30000 Request timeout (ms)

Azure SQL Configuration

For Azure SQL Database, use these settings:

{
  "DB_ENCRYPT": "true",
  "DB_TRUST_SERVER_CERTIFICATE": "false"
}

Local SQL Server (Self-signed cert)

For local development with self-signed certificates:

{
  "DB_ENCRYPT": "true",
  "DB_TRUST_SERVER_CERTIFICATE": "true"
}

šŸ† Features

  • āœ… MCP SDK 1.25.1: Latest Model Context Protocol SDK
  • āœ… Azure SQL Compatible: TLS encryption enabled by default
  • āœ… Complete SQL Support: All database operations
  • āœ… Parameterized Queries: SQL injection protection
  • āœ… Connection Pooling: Efficient resource management
  • āœ… Performance Monitoring: Execution time tracking

šŸ“‹ Usage Examples

Connect to Database

Use the connect_database tool to establish a connection.

Execute a Query

SELECT TOP 10 * FROM Customers WHERE Country = @country
-- With parameters: { "country": "USA" }

Get Table Schema

Use describe_table with tableName: "Customers" to see column details.

šŸ” Troubleshooting

āŒ Connection failed

  • Verify all required environment variables are set
  • Check server accessibility and credentials
  • Ensure network connectivity to SQL Server

āŒ SSL/Certificate errors

  • For Azure SQL: Set DB_ENCRYPT=true (default)
  • For self-signed certs: Set DB_TRUST_SERVER_CERTIFICATE=true
  • For local dev without encryption: Set DB_ENCRYPT=false

šŸ“‹ Version History

v2.1.1 - Latest

  • āœ… Added DB_ENCRYPT environment variable (Issue #1)
  • āœ… Azure SQL Database compatibility improved
  • āœ… Encryption enabled by default (DB_ENCRYPT=true)
  • āœ… Fixed DB_TRUST_SERVER_CERTIFICATE default to false

v2.1.0

  • āœ… Updated to MCP SDK 1.25.1
  • āœ… Migrated to registerTool() / registerResource() API
  • āœ… Added tool titles for better UI display

v2.0.3

  • āœ… Documentation improvements

šŸ“„ License

MIT License

šŸ†˜ Support


šŸŽ‰ v2.1.1: Azure SQL compatibility with DB_ENCRYPT support

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
E2B

E2B

Using MCP to run code via e2b.

Official
Featured