MS SQL Server MCP Server

by TerraCo89

1 stars
340 downloads
Not rated
GitHub

About

MCP server for Microsoft SQL Server - typed schema inspection and parameterized CRUD tools for LLM agents

Details

Author
TerraCo89
GitHub stars
1
Downloads
340
Categories
Database

- Six typed tools: list_tables, get_table_schema, read_table_rows, create_table_records, update_table_records, delete_table_records
- All queries are parameterized to prevent SQL injection
- Table and column names validated against live schema before execution
- Structured logging to a logs/ directory
- Supports row-level insert, update, and delete with affected-row counts
- Communicates over stdio with any MCP client

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 MS SQL Server MCP Server
    Command (node, npx, python, etc.)

    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

Requires Node.js 18+ and network access to a SQL Server instance. Clone the repository, install dependencies, copy .env.example to .env and fill in database connection variables (MSSQL_HOST, MSSQL_USER, MSSQL_PASSWORD, MSSQL_DATABASE), then build with npm run build. Run with node dist/server.js and configure as an MCP server (stdio) in Claude Desktop or Claude Code.

Claude Desktop / Cursor

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

{
    "mcpServers": {
        "ms sql server mcp server": {
            "mcp-server-mssql": {
                "command": "python",
                "args": [
                    "-m",
                    "venv",
                    "venv"
                ]
            }
        }
    }
}

McpServers

{
    "mcp-server-mssql": {
        "command": "python",
        "args": [
            "-m",
            "venv",
            "venv"
        ]
    }
}

mcp-server-mssql

License: MIT
TypeScript
MCP

A Model Context Protocol server that gives LLM agents safe, structured access to Microsoft SQL Server: schema inspection plus row-level CRUD, every operation parameterized and logged.

Built because agents working against real business databases need more than "run this SQL string" — they need typed tools with predictable failure modes.

How it works

flowchart LR
    A[MCP client<br/>Claude Desktop / Claude Code] -- stdio --> B[mcp-server-mssql]
    B --> C[connection pool<br/>mssql driver]
    C --> D[(SQL Server)]
    B -. structured logs .-> E[logs/]

The server connects to a single database configured via environment variables and exposes six tools. All queries are parameterized — table and column names are validated against the live schema before any statement runs, so an agent cannot inject through identifiers.

Tools

| Tool | What it does |
|---|---|
| list_tables | List all user tables in the configured database |
| get_table_schema | Column names, types, nullability, and defaults for a table |
| read_table_rows | Read rows with optional column selection, WHERE filters, ORDER BY, and LIMIT |
| create_table_records | Insert one or more rows (column/value validated against schema) |
| update_table_records | Update rows matching a filter; returns affected count |
| delete_table_records | Delete rows matching a filter; returns affected count |

Example interaction

> User: "Which customers signed up this month?"
>
> Agent calls list_tables → finds Customers → calls get_table_schema {"table_name": "Customers"} → sees CreatedAt datetime2 → calls read_table_rows {"table_name": "Customers", "filters": {"CreatedAt": {">=": "2026-07-01"}}, "limit": 50} → answers with the rows.

Setup

Requires Node.js 18+ and network access to a SQL Server instance.

git clone https://github.com/TerraCo89/mcp-server-mssql.git
cd mcp-server-mssql
npm install
cp .env.example .env   # fill in connection details
npm run build

Configuration (environment variables)

| Variable | Required | Notes |
|---|---|---|
| MSSQL_HOST / MSSQL_PORT | yes / no | Port defaults to 1433 |
| MSSQL_USER / MSSQL_PASSWORD | yes | SQL auth credentials |
| MSSQL_DATABASE | yes | Single database per server instance |
| MSSQL_ENCRYPT, MSSQL_TRUST_SERVER_CERTIFICATE | no | TLS options |
| LOG_LEVEL | no | info by default |

Use with Claude Desktop / Claude Code

{
  "mcpServers": {
    "mssql": {
      "command": "node",
      "args": ["/path/to/mcp-server-mssql/dist/server.js"],
      "env": {
        "MSSQL_HOST": "localhost",
        "MSSQL_USER": "agent_reader",
        "MSSQL_PASSWORD": "...",
        "MSSQL_DATABASE": "MyDb"
      }
    }
  }
}

Tip: point it at a least-privilege SQL login — the server can only do what the login can.

Development

npm run dev    # ts-node with live reload
npm test       # jest test suite (src/*.test.ts, tests/)
npm run build  # emit dist/

Docker: docker build -t mcp-server-mssql . then run with the same environment variables.

License

MIT

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.