Back to MCP Catalog

MSSQL Database Access MCP Server

DatabasesPython
Secure and structured interaction with Microsoft SQL Server databases
Available Tools

list_tables

Lists all available tables in the connected MSSQL database

read_table

Retrieves and displays the contents of a specified table

execute_query

Executes a custom SQL query with controlled access and error handling

MSSQL Database Access provides a secure interface for AI assistants to interact with Microsoft SQL Server databases. It enables listing available tables, reading table contents, and executing SQL queries with controlled access and proper permission enforcement. This tool ensures safer database exploration by implementing security best practices, restricting database access to only necessary operations, and providing comprehensive logging of all database interactions. It's designed to follow the principle of least privilege, making it suitable for production environments.

Overview

MSSQL Database Access enables AI assistants to interact with Microsoft SQL Server databases in a secure and structured manner. This tool provides controlled access to database operations while enforcing proper security measures.

Installation

You can install the MSSQL Database Access tool using pip:

pip install mssql-mcp-server

Configuration

To use this tool, you need to configure database access through environment variables:

MSSQL_DRIVER=mssql_driver
MSSQL_HOST=localhost
MSSQL_USER=your_username
MSSQL_PASSWORD=your_password
MSSQL_DATABASE=your_database

Optional configuration parameters:

TrustServerCertificate=yes
Trusted_Connection=no

Security Best Practices

For secure operation, follow these guidelines:

  1. Create a dedicated MSSQL user with restricted permissions
  2. Never use root credentials or administrative accounts
  3. Restrict database access to only necessary tables and operations
  4. Enable SQL Server logging and monitoring for auditing
  5. Regularly review database permissions

Always follow the Principle of Least Privilege when configuring database access.

Integration with Claude Desktop

To integrate with Claude Desktop, add the following configuration to your claude_desktop_config.json file:

{
  "mcpServers": {
    "mssql": {
      "command": "uv",
      "args": [
        "--directory",
        "path/to/mssql_mcp_server",
        "run",
        "mssql_mcp_server"
      ],
      "env": {
        "MSSQL_DRIVER": "mssql_driver",
        "MSSQL_HOST": "localhost",
        "MSSQL_USER": "your_username",
        "MSSQL_PASSWORD": "your_password",
        "MSSQL_DATABASE": "your_database"
      }
    }
  }
}

Running as a Standalone Server

If you prefer to run the server independently:

# Install dependencies
pip install -r requirements.txt

# Run the server
python -m mssql_mcp_server

Development

For contributing to the development:

# Clone the repository
git clone https://github.com/JexinSam/mssql_mcp_server.git
cd mssql_mcp_server

# Set up a virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install development dependencies
pip install -r requirements-dev.txt

# Run tests
pytest

Related MCPs

Milvus Vector Database
DatabasesPython

Connect to Milvus vector database for semantic search and vector operations

MotherDuck DuckDB
DatabasesPython

SQL analytics with DuckDB and MotherDuck for AI assistants

Alibaba Cloud Tablestore
DatabasesJava, Python

Connect to Alibaba Cloud Tablestore for vector search and RAG applications

About Model Context Protocol

Model Context Protocol (MCP) allows AI models to access external tools and services, extending their capabilities beyond their training data.

Generate Cursor Documentation

Save time on coding by generating custom documentation and prompts for Cursor IDE.