Skip to main content
Glama
bymcs

MS SQL Server MCP Server

by bymcs

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

-
security - not tested
F
license - not found
-
quality - not tested

Resources

Looking for Admin?

Admins can modify the Dockerfile, update the server description, and track usage metrics. If you are the server author, to access the admin panel.

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/bymcs/mssql-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server