Skip to main content
Glama
MSSQL MCP Server

MSSQL MCP Server

by EvilPhatBoi

MSSQL MCP Server

A Model Context Protocol (MCP) server that enables LLMs like Claude to interact with Microsoft SQL Server databases through natural language.

Features

  • 🔍 Query your SQL Server database using natural language

  • 📊 Read, insert, update, and delete data

  • 🏗️ Create and manage tables and indexes

  • 🔒 Secure connection handling with optional read-only mode

  • ⚡ Direct TypeScript execution with tsx - no build step required

Related MCP server: ExecuteAutomation Database Server

Quick Start

No installation needed! Just configure Claude Desktop:

Windows

Add to %APPDATA%\Claude\claude_desktop_config.json:

{
  "mcpServers": {
    "mssql": {
      "type": "stdio",
      "command": "cmd",
      "args": ["/c", "npx", "-y", "github:EvilPhatBoi/McpSqlServer"],
      "env": {
        "SERVER_NAME": "your-server.database.windows.net",
        "DATABASE_NAME": "your-database",
        "SQL_USERNAME": "your-username",
        "SQL_PASSWORD": "your-password",
        "PORT": "1433",
        "ENCRYPT": "true",
        "TRUST_SERVER_CERTIFICATE": "false",
        "CONNECTION_TIMEOUT": "30",
        "READONLY": "false"
      }
    }
  }
}

macOS/Linux

Add to ~/Library/Application Support/Claude/claude_desktop_config.json:

{
  "mcpServers": {
    "mssql": {
      "type": "stdio",
      "command": "npx",
      "args": ["-y", "github:EvilPhatBoi/McpSqlServer"],
      "env": {
        "SERVER_NAME": "your-server.database.windows.net",
        "DATABASE_NAME": "your-database",
        "SQL_USERNAME": "your-username",
        "SQL_PASSWORD": "your-password",
        "PORT": "1433",
        "ENCRYPT": "true",
        "TRUST_SERVER_CERTIFICATE": "false",
        "CONNECTION_TIMEOUT": "30",
        "READONLY": "false",
        "DEBUG": "false"
      }
    }
  }
}

Note for legacy SQL Servers: If you experience SSL/TLS connection issues with older SQL Server versions, try:

  • "ENCRYPT": "false" to disable TLS/SSL encryption

  • "TRUST_SERVER_CERTIFICATE": "true" to trust self-signed certificates

  • "CONNECTION_TIMEOUT": "60" or higher for slower connections

  • "DEBUG": "true" to see detailed connection logs

Option 2: Clone and run locally

  1. Clone the repository:

git clone https://github.com/EvilPhatBoi/McpSqlServer.git
cd McpSqlServer
  1. Install dependencies:

npm install
  1. Create .env file:

cp .env.example .env
# Edit .env with your database credentials
  1. Configure Claude Desktop to point to your local installation:

{
  "mcpServers": {
    "mssql": {
      "type": "stdio",
      "command": "npx",
      "args": ["tsx", "C:/path/to/McpSqlServer/src/index.ts"],
      "env": {
        "SERVER_NAME": "your-server.database.windows.net",
        "DATABASE_NAME": "your-database",
        "SQL_USERNAME": "your-username",
        "SQL_PASSWORD": "your-password"
      }
    }
  }
}

Environment Variables

Variable

Description

Default

SERVER_NAME

SQL Server hostname

Required

DATABASE_NAME

Database name

Required

SQL_USERNAME

SQL username

Required

SQL_PASSWORD

SQL password

Required

PORT

SQL Server port

1433

ENCRYPT

Enable TLS/SSL encryption

true

TRUST_SERVER_CERTIFICATE

Trust self-signed certificates

false

CONNECTION_TIMEOUT

Connection timeout in seconds

30

READONLY

Enable read-only mode

false

DEBUG

Enable debug logging

false

Usage Examples

Once configured, you can interact with your database using natural language in Claude:

  • "Show me all customers from New York"

  • "Create a table called products with columns for id, name, and price"

  • "Update the price of product with id 5 to 29.99"

  • "List all tables in the database"

  • "Describe the structure of the orders table"

Development

Running locally with tsx:

npm run start  # Run the server
npm run dev    # Run with watch mode

Type checking:

npm run typecheck

Security Notes

  • Never commit .env files with real credentials

  • Use read-only mode (READONLY=true) in production for safety

  • The server requires WHERE clauses for updates to prevent accidental mass updates

  • Consider using environment-specific credentials

Troubleshooting

Connection issues

  • Ensure your SQL Server allows remote connections

  • Check firewall rules for SQL Server port (default 1433, or your custom PORT setting)

  • Verify credentials and server name

  • Enable debug logging by setting DEBUG=true in your environment variables

SSL/TLS connection issues

  • For older SQL Server versions that don't support modern TLS, set ENCRYPT=false

  • If using self-signed certificates, set TRUST_SERVER_CERTIFICATE=true

  • For connection timeout issues, increase CONNECTION_TIMEOUT to 60 or higher

  • Check that your SQL Server accepts the TLS version your Node.js supports

Debug mode

To enable detailed logging for troubleshooting:

"env": {
  "DEBUG": "true",
  // ... other environment variables
}

Authentication errors

  • This server uses SQL authentication, not Windows authentication

  • Ensure SQL authentication is enabled on your server

  • Check that the SQL user has appropriate permissions

License

MIT

Available Tools

8 tools
create_indexC

Creates an index on a specified column or columns in an MSSQL Database table

Inputs: tableName (required), indexName (required), columns (required), schemaName, +2 more.

create_tableC

Creates a new table in the MSSQL Database with the specified columns.

Inputs: tableName (required), columns (required).

describe_tableA

Describes the schema (columns and types) of a specified MSSQL Database table.

Inputs: tableName (required).

drop_tableC

Drops a table from the MSSQL Database.

Inputs: tableName (required).

insert_dataA

Inserts data into an MSSQL Database table. Supports both single record insertion and multiple record insertion using standard SQL INSERT with VALUES clause. FORMAT EXAMPLES: Single Record Insert: { "tableName": "Users", "data": { "name": "John Doe", "email": "john@example.com", "age": 30, "isActive": true, "createdDate": "2023-01-15" } } Multiple Records Insert: { "tableName": "Users", "data": [ { "name": "John Doe", "email": "john@example.com", "age": 30, "isActive": true, "createdDate": "2023-01-15" }, { "name": "Jane Smith", "email": "jane@example.com", "age": 25, "isActive": false, "createdDate": "2023-01-16" } ] } GENERATED SQL FORMAT:

  • Single: INSERT INTO table (col1, col2) VALUES (@param1, @param2)

  • Multiple: INSERT INTO table (col1, col2) VALUES (@param1, @param2), (@param3, @param4), ... IMPORTANT RULES:

  • For single record: Use a single object for the 'data' field

  • For multiple records: Use an array of objects for the 'data' field

  • All objects in array must have identical column names

  • Column names must match the actual database table columns exactly

  • Values should match the expected data types (string, number, boolean, date)

  • Use proper date format for date columns (YYYY-MM-DD or ISO format)

Inputs: tableName (required), data (required).

list_tableC

Lists tables in an MSSQL Database, or list tables in specific schemas

Inputs: parameters.

read_dataA

Executes a SELECT query on an MSSQL Database table. The query must start with SELECT and cannot contain any destructive SQL operations for security reasons.

Inputs: query (required).

update_dataB

Updates data in an MSSQL Database table using a WHERE clause. The WHERE clause must be provided for security.

Inputs: tableName (required), updates (required), whereClause (required).

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    A3.6/5.0

    Scored across 8 tools

    Disambiguation5/5

    Each tool has a clearly distinct purpose with no ambiguity. create_index, create_table, describe_table, drop_table, insert_data, list_table, read_data, and update_data each target specific database operations with no overlap in functionality. The descriptions clearly differentiate between schema operations, data manipulation, and querying.

    Naming Consistency5/5

    All tools follow a consistent verb_noun pattern with snake_case throughout. The naming convention is perfectly uniform: create_index, create_table, describe_table, drop_table, insert_data, list_table, read_data, and update_data all maintain the same structure and style.

    Tool Count5/5

    With 8 tools, this server is well-scoped for MSSQL database operations. Each tool earns its place by covering essential database tasks: schema management (create/drop/describe/list tables, create index) and data operations (insert/read/update). The count is appropriate for the domain without being overwhelming.

    Completeness4/5

    The tool surface covers most essential MSSQL operations well, including table lifecycle management and core CRUD operations. However, there are minor gaps: no delete_data tool (only update_data with WHERE clause), no transaction management tools, and no stored procedure or view operations. Agents can work around these gaps using existing tools.

    Maintenance

    ActivityStale
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      B
      quality
      C
      maintenance
      A Model Context Protocol server that enables secure interaction with Microsoft SQL Server databases, allowing AI assistants to list tables, read data, and execute SQL queries through a controlled interface.
      1
      406
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      A Model Context Protocol server that enables LLMs like Claude to interact with SQLite and SQL Server databases, allowing for schema inspection and SQL query execution.
      410
      MIT
    • F
      license
      Not graded
      quality
      C
      maintenance
      A Model Context Protocol server that allows Large Language Models like Claude to execute SQL queries, explore database schemas, and maintain persistent connections to SQL Server databases.
      -
    • A
      license
      B
      quality
      D
      maintenance
      A Model Context Protocol server that enables AI assistants (Cursor, Windsurf, Claude Code) to interact with Microsoft SQL Server databases by providing connectivity through environment-configurable connections.
      8
      581 npm
      8
      MIT