Skip to main content
Glama
mcp-server-mssql

mcp-server-mssql

by TerraCo89

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.

Related MCP server: MCP Databases Server

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

Available Tools

3 tools
get_table_schemaB

Gets the schema of a specific table

Inputs: table_name (required), schema.

list_tablesC

Lists all tables in the database

Inputs: schema.

read_table_rowsB

Reads rows from a table with optional filtering and pagination

Inputs: table_name (required), columns, filters, limit, +2 more.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3.4/5.0

    Scored across 3 tools

    Disambiguation5/5

    Each tool has a clearly distinct purpose: listing tables, getting schema, and reading rows. There is no ambiguity between them.

    Naming Consistency5/5

    All tool names follow a consistent verb_noun snake_case pattern: list_tables, get_table_schema, read_table_rows.

    Tool Count4/5

    With 3 tools, the server is slightly underpopulated but still reasonable for a focused read-only database schema and data access tool.

    Completeness2/5

    The server lacks essential database operations such as writing, updating, deleting rows, or running arbitrary SQL queries, making it incomplete for typical use cases.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      A Model Context Protocol (MCP) server that enables AI agents to interact with Microsoft SQL Server databases through secure, intelligent database operations. This server provides comprehensive CRUD capabilities, schema introspection, stored procedure execution, transaction management, and bulk opera
      1,243 npm
      47
      MIT
    • F
      license
      Not graded
      quality
      D
      maintenance
      Enables LLMs and agents to interact with relational databases (SQL Server, MySQL, PostgreSQL) through MCP tools. Supports executing queries, inserting records, listing tables, and exposing database schemas with secure credential management.
      -
    • A
      license
      A
      quality
      D
      maintenance
      Enables AI assistants to interact with Microsoft SQL Server databases through query execution, schema discovery, CRUD operations, stored procedures, and data export with built-in safety controls.
      18
      77 PyPI
      Apache 2.0
    • A
      license
      A
      quality
      D
      maintenance
      Enables AI models to interact with MS SQL Server databases through a standardized interface. Supports executing SQL queries with parameters, listing tables, and describing table schemas.
      3
      95 npm
      MIT