mcpField
M
Mssql Mcp Server

Mssql Mcp Server

Local
github.com/stillloveeDatabases0Updated 46w ago

About Mssql Mcp Server

Mssql Mcp Server lets AI agents and other MCP clients work with Microsoft SQL Server. It supports query and stored procedure execution over stdio or Streamable HTTP, with configurable authentication and session handling.

Key features

  1. 01Execute SQL queries
  2. 02Run stored procedures
  3. 03Retrieve database connection information
  4. 04Windows and SQL Server authentication
  5. 05Stdio and Streamable HTTP transports
  6. 06Multiple HTTP sessions

Use cases

  1. 01Querying SQL Server from an MCP client
  2. 02Calling stored procedures through an agent
  3. 03Connecting web applications over HTTP
  4. 04Separating database connections by API key

MCP support

It exposes SQL Server operations as MCP tools, including query execution, stored procedures, and connection information. Clients can connect through stdio or Streamable HTTP.

Configuration

Local server config is the same for every client. Copy it into your client’s MCP config file.

mcp.json · Universal config
{
"mcpServers": {
"mssql-mcp-server-stilllovee": {
"command": "npx",
"args": [
"-y",
"github:stilllovee/mssql-mcp-server"
],
"env": {
"DB_SERVER": "<DB_SERVER>",
"DB_DATABASE": "<DB_DATABASE>",
"DB_USER": "<DB_USER>",
"DB_PASSWORD": "<DB_PASSWORD>",
"DB_TRUST_SERVER_CERTIFICATE": "<DB_TRUST_SERVER_CERTIFICATE>",
"DB_ENCRYPT": "<DB_ENCRYPT>"
}
}
}
}
Run commandnpx -y github:stilllovee/mssql-mcp-server
Environment variables to set
DB_SERVER
DB_DATABASE
DB_USER
DB_PASSWORDSecret
DB_TRUST_SERVER_CERTIFICATE
DB_ENCRYPT

Local servers need a runtime on your machine (e.g. Node.js 18+). Config file locations differ by client; see your client’s docs.

Packages
npmgithub:stilllovee/mssql-mcp-server

Tools

No tool list yet

Local servers expose tools only once running on your machine, and the maintainer has not provided a tool list.

Details

From the project README

MSSQL MCP Server

Model Context Protocol (MCP) server for Microsoft SQL Server database operations.

Features

  • Execute SQL queries against SQL Server
  • Execute stored procedures
  • Get database connection information
  • Support for both Windows Authentication and SQL Server Authentication
  • Flexible configuration via environment variables
  • Streamable HTTP transport for web-based applications and remote connections
  • Support for multiple simultaneous sessions

Usage

The server supports two transport modes:

1. Stdio Transport (Default)

For use with Claude Desktop and other stdio-based MCP clients.

Add to your Claude Desktop configuration:

{
    "mcpServers": {
        "mssql": {
            "command": "npx",
            "args": [
                "github:stilllovee/mssql-mcp-server"
            ],
            "env": {
                "DB_SERVER": "servername",
                "DB_DATABASE": "dbname",
                "DB_USER": "username", //optional
                "DB_PASSWORD": "password",  //optional
                "DB_TRUST_SERVER_CERTIFICATE": "true",  //optional
                "DB_ENCRYPT": "true"  //optional
            }
        }
    }
}

Or install in your own PC

npm install
{
    "mcpServers": {
        "mssql": {
            "command": "node",
            "args": ["/path/to/folder"],
            "env": {
                "DB_SERVER": "servername",
                "DB_DATABASE": "dbname",
                "DB_USER": "username", //optional
                "DB_PASSWORD": "password",  //optional
                "DB_TRUST_SERVER_CERTIFICATE": "true",  //optional
                "DB_ENCRYPT": "true"  //optional
            }
        }
    }
}

Or using a connection string:

{
    "mcpServers": {
        "mssql": {
            "command": "node",
            "args": ["/path/to/folder"],
            "env": {
                "DB_CONNECTION_STRING": "Server=localhost;Database=ecommerce;Trusted_Connection=yes;TrustServerCertificate=yes"
            }
        }
    }
}
2. Streamable HTTP Transport

For web applications, remote connections, and environments where HTTP is preferred.

Start the HTTP Server

Setup .env file with your database configuration:

DB_SERVER=localhost
DB_DATABASE=ecommerce
DB_USE_WINDOWS_AUTH=true
# Or use a full connection string
# DB_CONNECTION_STRING=Server=localhost;Database=ecommerce;Trusted_Connection=yes;TrustServerCertificate=yes

Run the server:

# Using default port 8123
node index-http.js

# Or specify a custom port
node index-http.js --port=3000

The server will be available at http://localhost:8123/mcp (or your custom port).

HTTP Transport Features
  • Session Management: Supports multiple simultaneous client connections with unique session IDs
  • Server-Sent Events (SSE): Real-time notifications via GET endpoint
  • Stateful Connections: Maintains session state across requests
  • Standard HTTP: Works with any HTTP client or proxy
  • API Key-Based Connection Mapping: Map different API keys to different database connections (see below)
API Key-Based Multi-Database Support

The HTTP transport supports API key-based connection mapping using Azure Table Storage, allowing different clients to connect to different databases using unique API keys.

Enable API Key Mapping:

# Set environment variables
USE_API_KEY_MAPPING=true
AZURE_STORAGE_CONNECTION_STRING=your_azure_connection_string

# Start the server
node index-http.js

Configure in Claude Desktop:

"mssql": {
    "type": "http",
    "url": "http://localhost:8123/mcp",
    "headers": {
        "x-api-key": "your-api-key"
    }
},

Making Requests with API Keys:

curl -X POST http://localhost:8123/mcp \
  -H "Content-Type: application/json" \
  -H "x-api-key: your-api-key" \
  -d '{"jsonrpc":"2.0","id":1,"method":"initialize",...}'

Managing API Keys:

# List all API keys
node scripts/manage-api-keys.js list

# Add a new API key
node scripts/manage-api-keys.js add my-api-key

# Delete an API key
node scripts/manage-api-keys.js delete my-api-key

For detailed information about Azure Table Storage setup, API key management, and security best practices, see Azure Table Storage Documentation.

HTTP Endpoints
  • POST /mcp - Send MCP requests and receive responses
  • GET /mcp - Establish SSE connection for receiving notifications (requires mcp-session-id header)
Available Environment Variables
VariableDescriptionDefault
DB_CONNECTION_STRINGFull connection string (overrides all other settings)-
DB_SERVERSQL Server hostname or IPlocalhost
DB_DATABASEDatabase nameecommerce
DB_USERUsername for SQL Server Authentication-
DB_PASSWORDPassword for SQL Server Authentication-
DB_USE_WINDOWS_AUTHUse Windows Authenticationtrue (if user/password not set)
DB_DRIVERODBC driver nameODBC Driver 17 for SQL Server
DB_ENCRYPTEnable connection encryptionfalse
DB_TRUST_SERVER_CERTIFICATETrust server certificatetrue
USE_API_KEY_MAPPINGEnable API key-based connection mappingfalse
AZURE_STORAGE_CONNECTION_STRINGAzure Table Storage connection string (required for API key mapping)-
AZURE_TABLE_NAMEAzure Table name for API key mappingsApiKeyMappings
Available Tools
  1. sql_execute_query - Execute SQL queries

    • Parameters: query (string), params (object, optional)
  2. sql_execute_procedure - Execute stored procedures

    • Parameters: procedure_name (string), params (object, optional)
  3. sql_get_database_info - Get database connection information

    • No parameters required
  4. And more ...

Requirements

  • Node.js 14 or higher
  • SQL Server with ODBC driver installed
  • For Windows Authentication: Running on Windows with appropriate permissions

Comments

Markdown supported

New to MCP?

From what the protocol is to installing your first server, these answers cover most first questions.

An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.