home / mcp / mssql mcp server

MSSQL MCP Server

Provides access to SQL Server data via MCP with query execution, schema browsing, and safe, encrypted connections.

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "combiz-mssql-mcp-server": {
      "command": "python",
      "args": [
        "-m",
        "mssql_mcp_server.server"
      ],
      "env": {
        "MSSQL_PORT": "1433",
        "MSSQL_USER": "your-username",
        "MSSQL_DRIVER": "ODBC Driver 17 for SQL Server",
        "MSSQL_SERVER": "your-server.database.windows.net",
        "MSSQL_ENCRYPT": "yes",
        "MSSQL_DATABASE": "your-database",
        "MSSQL_PASSWORD": "your-password",
        "MSSQL_CONNECTION_TIMEOUT": "30",
        "MSSQL_TRUSTED_CONNECTION": "yes",
        "MSSQL_TRUST_SERVER_CERTIFICATE": "yes"
      }
    }
  }
}

This MSSQL MCP Server lets MCP-compatible clients interact with a Microsoft SQL Server database through a standardized interface. You can execute SQL queries, explore schemas, and manage multi-line statements with secure, configurable connections.

How to use

You use this server by running it locally or integrating it with an MCP client. Start the server in your environment and point your MCP client to the local Python process. You can then execute SQL queries, inspect table schemas, and fetch sample data from your SQL Server.

To run the server as a stand-alone process, set your connection details in environment variables and launch the Python module. The server exposes a standard interface that MCP clients can consume to execute queries and retrieve results.

{
  "mcpServers": {
    "mssql": {
      "command": "python",
      "args": ["-m", "mssql_mcp_server.server"],
      "env": {
        "MSSQL_SERVER": "your-server.database.windows.net",
        "MSSQL_DATABASE": "your-database",
        "MSSQL_USER": "your-username",
        "MSSQL_PASSWORD": "your-password"
      }
    }
  }
}

How to install

Prerequisites: Python 3.8 or newer and an ODBC driver for SQL Server. Choose the driver appropriate for your OS (ODBC Driver 17 or 18 for SQL Server). Ensure you have a working network path to your SQL Server.

Step-by-step commands to set up the server locally:

# Install the MCP server package
pip install mssql-mcp-server-enhanced

# (Optional) Install from source
# git clone https://github.com/combiz/mssql-mcp-server.git
# cd mssql-mcp-server
# pip install -e .

Configuration and security notes

Configure credentials and connection settings via environment variables. Use SQL Server authentication or Windows authentication as needed. Enable encryption in production and validate certificates according to your security requirements.

Example environment variables you may set when starting the server: MSSQL_SERVER, MSSQL_DATABASE, MSSQL_USER, MSSQL_PASSWORD, MSSQL_TRUSTED_CONNECTION, MSSQL_DRIVER, MSSQL_ENCRYPT, MSSQL_TRUST_SERVER_CERTIFICATE, MSSQL_CONNECTION_TIMEOUT, MSSQL_PORT.

Troubleshooting

If you encounter connection issues, verify your server address, credentials, and firewall rules. For authentication errors, ensure the selected authentication method matches your SQL Server configuration.

If queries hang or fail due to GO batch separators or multi-line content, the server handles these cases by executing the first batch and processing multi-line queries correctly. Adjust your scripts if needed to separate batches.

Available tools and resources

Tools provided by the server focus on executing SQL against the connected database and inspecting the schema or sample data from tables.

Available tools

execute_sql

Execute a SQL query against the connected database and receive formatted results, with support for multi-line queries and proper error handling.