mssql-mcp-server

ConnorDaytonaHolmes/mssql-mcp-server

3.2

If you are the rightful owner of mssql-mcp-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

A Model Context Protocol (MCP) server for read-only Microsoft SQL Server interactions.

Tools
2
Resources
0
Prompts
0

MSSQL MCP Server

A Model Context Protocol (MCP) server for read-only Microsoft SQL Server interactions. This server provides safe, read-only access to MSSQL databases through the MCP protocol.

Features

  • Read-only operations: Only SELECT, DECLARE, and SET (for local variables) queries are allowed
  • Schema exploration: Browse databases, tables, columns, and indexes
  • Safe querying: SQL injection protection and query validation
  • Connection management: Secure connection handling with proper cleanup

Installation

  1. Clone this repository:
git clone <repository-url>
cd mssql-mcp
  1. Install dependencies:
pip install -e .
  1. Set up environment variables:
cp .env.example .env
# Edit .env with your database connection details

Important: The server automatically loads environment variables from a .env file in the current directory. Make sure to create this file with your database connection details.

Configuration

Create a .env file with your MSSQL connection details:

MSSQL_SERVER=localhost
MSSQL_DATABASE=your_database
MSSQL_USERNAME=your_username
MSSQL_PASSWORD=your_password
MSSQL_PORT=1433
MSSQL_TIMEOUT=30
MSSQL_CHARSET=UTF-8
MSSQL_AUTOCOMMIT=true

Usage

Development Mode

mcp dev src/mssql_mcp/server.py

Claude Desktop Integration

mcp install src/mssql_mcp/server.py --name "MSSQL Server"

Direct Execution

python -m mssql_mcp.server

Available Resources

  • db://schemas - List all schemas in the current database
  • db://tables/{database} - List all tables in the current database
  • db://schema_tables/{schema_name} - List tables in a specific schema
  • db://columns/{schema_name}/{table_name} - Get column information for a table
  • db://indexes/{database}/{schema_name}/{table_name} - Get index information for a table

Available Tools

  • list_databases - List all accessible databases
  • list_tables - List tables in the current database

Security

This server implements several security measures:

  • Only SELECT, DECLARE, and SET (for local variables) statements are allowed
  • SQL parsing and validation
  • Parameterized queries where possible
  • Connection string security
  • No DDL or DML operations permitted

Requirements

  • Python 3.9+
  • Access to a Microsoft SQL Server instance
  • pymssql library (automatically installed with dependencies)

License

MIT License