MSSQL

by c0h1b4

8 stars
Not rated
GitHub

About

Enables secure AI-driven interactions with Microsoft SQL Server databases for automated data analysis, dynamic reporting, and intelligent database management.

Details

Author
c0h1b4
Repository
c0h1b4/mssql-mcp-server
GitHub stars
8
License
MIT License
Categories
Database, Other, AI, Design, Developer Tools, Search, Infrastructure, Frontend, Knowledge Base

Setting up with Highlight

This MCP is not yet compatible with Highlight’s one-click setup. However, you can still use it with Highlight by following these steps:

  1. Download and install Highlight from highlightai.com/download
  2. Navigate to the plugins tab and select "Add Custom Plugin"
  3. Configure the plugin with the settings below
    Plugin Name MSSQL
    Command (node, npx, python, etc.) mssql-mcp-server
    Environment
    • MSSQL_HOST localhost
    • MSSQL_PORT 1433
    • MSSQL_USER sa
    • MSSQL_ENCRYPT false
    • MSSQL_DATABASE master
    • MSSQL_PASSWORD yourpassword
    • MSSQL_CONNECTION_STRING Server=localhost;Database=master;User Id=sa;Password=yourpassword;
    • MSSQL_TRUST_SERVER_CERTIFICATE true

    Please refer to the README for specific instructions on how to obtain API keys or other required environment variables.

  4. Enable "Start Automatically" if you want the plugin to start when Highlight launches

From the repository

Add the server to your MCP settings configuration file:

{
  "mcpServers": {
    "mssql": {
      "command": "mssql-mcp-server",
      "env": {
        "MSSQL_CONNECTION_STRING": "Server=localhost;Database=master;User Id=sa;Password=yourpassword;",
        // Or individual connection parameters:
        "MSSQL_HOST": "localhost",
        "MSSQL_PORT": "1433",
        "MSSQL_DATABASE": "master",
        "MSSQL_USER": "sa",
        "MSSQL_PASSWORD": "yourpassword",
        "MSSQL_ENCRYPT": "false",
        "MSSQL_TRUST_SERVER_CERTIFICATE": "true"
      }
    }
  }
}

To install MSSQL MCP Server for Claude Desktop automatically via Smithery:

npx -y @smithery/cli install @c0h1b4/mssql-mcp-server --client claude
npm install mssql-mcp-server

npm install

The evals package loads an mcp client that then runs the index.ts file, so there is no need to rebuild between tests. You can load environment variables by prefixing the npx command. Full documentation can be found here.

OPENAI_API_KEY=your-key  npx mcp-eval src/evals/evals.ts examples/simple-server.ts

query

Execute a SQL query on a MSSQL database. Parameters: connectionString (optional string), host (optional string), port (optional number), database (optional string), username (optional string), password (optional string), query (required string), encrypt (optional boolean), trustServerCertificate (optional boolean)

Claude Desktop / Cursor

Paste into your MCP client config file to install this server.

{
    "mcpServers": {
        "mssql": {
            "env": {
                "MSSQL_HOST": "localhost",
                "MSSQL_PORT": "1433",
                "MSSQL_USER": "sa",
                "MSSQL_ENCRYPT": "false",
                "MSSQL_DATABASE": "master",
                "MSSQL_PASSWORD": "yourpassword",
                "MSSQL_CONNECTION_STRING": "Server=localhost;Database=master;User Id=sa;Password=yourpassword;",
                "MSSQL_TRUST_SERVER_CERTIFICATE": "true"
            },
            "args": [],
            "command": "mssql-mcp-server"
        }
    }
}

Linux

{
    "env": {
        "MSSQL_HOST": "localhost",
        "MSSQL_PORT": "1433",
        "MSSQL_USER": "sa",
        "MSSQL_ENCRYPT": "false",
        "MSSQL_DATABASE": "master",
        "MSSQL_PASSWORD": "yourpassword",
        "MSSQL_CONNECTION_STRING": "Server=localhost;Database=master;User Id=sa;Password=yourpassword;",
        "MSSQL_TRUST_SERVER_CERTIFICATE": "true"
    },
    "args": [],
    "command": "mssql-mcp-server"
}

Macos

{
    "env": {
        "MSSQL_HOST": "localhost",
        "MSSQL_PORT": "1433",
        "MSSQL_USER": "sa",
        "MSSQL_ENCRYPT": "false",
        "MSSQL_DATABASE": "master",
        "MSSQL_PASSWORD": "yourpassword",
        "MSSQL_CONNECTION_STRING": "Server=localhost;Database=master;User Id=sa;Password=yourpassword;",
        "MSSQL_TRUST_SERVER_CERTIFICATE": "true"
    },
    "args": [],
    "command": "mssql-mcp-server"
}

Windows

{
    "env": {
        "MSSQL_HOST": "localhost",
        "MSSQL_PORT": "1433",
        "MSSQL_USER": "sa",
        "MSSQL_ENCRYPT": "false",
        "MSSQL_DATABASE": "master",
        "MSSQL_PASSWORD": "yourpassword",
        "MSSQL_CONNECTION_STRING": "Server=localhost;Database=master;User Id=sa;Password=yourpassword;",
        "MSSQL_TRUST_SERVER_CERTIFICATE": "true"
    },
    "args": [],
    "command": "mssql-mcp-server"
}

MSSQL MCP Server

smithery badge

A Model Context Protocol (MCP) server for connecting to Microsoft SQL Server databases. This server provides tools for executing SQL queries and managing database connections.

Version Notice: This project has been upgraded to use Model Context Protocol SDK 1.9.0. See UPGRADE.md for details.

Installation

Installing via Smithery

To install MSSQL MCP Server for Claude Desktop automatically via Smithery:

npx -y @smithery/cli install @c0h1b4/mssql-mcp-server --client claude

Manual Installation

npm install mssql-mcp-server

Usage

Add the server to your MCP settings configuration file:

{
  "mcpServers": {
    "mssql": {
      "command": "mssql-mcp-server",
      "env": {
        "MSSQL_CONNECTION_STRING": "Server=localhost;Database=master;User Id=sa;Password=yourpassword;",
        // Or individual connection parameters:
        "MSSQL_HOST": "localhost",
        "MSSQL_PORT": "1433",
        "MSSQL_DATABASE": "master",
        "MSSQL_USER": "sa",
        "MSSQL_PASSWORD": "yourpassword",
        "MSSQL_ENCRYPT": "false",
        "MSSQL_TRUST_SERVER_CERTIFICATE": "true"
      }
    }
  }
}

Tools

query

Execute a SQL query on a MSSQL database.

Parameters

- connectionString (string, optional): Full connection string (alternative to individual parameters)
- host (string, optional): Database server hostname
- port (number, optional): Database server port (default: 1433)
- database (string, optional): Database name (default: master)
- username (string, optional): Database username
- password (string, optional): Database password
- query (string, required): SQL query to execute
- encrypt (boolean, optional): Enable encryption (default: false)
- trustServerCertificate (boolean, optional): Trust server certificate (default: true)

Either connectionString OR (host + username + password) must be provided.

Example

const result = await use_mcp_tool({
  server_name: 'mssql',
  tool_name: 'query',
  arguments: {
    host: 'localhost',
    username: 'sa',
    password: 'yourpassword',
    query: 'SELECT * FROM Users',
  },
});

Running the Server

Local Development

```bash

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.