Back to MCP Catalog

Microsoft SQL Server Connector MCP Server

DatabasesPython
Connect to and query Microsoft SQL Server databases
Available Tools

execute_sql

Executes SQL queries against the connected Microsoft SQL Server database. Supports both SELECT queries for data retrieval and modification queries (INSERT, UPDATE, DELETE) for data manipulation.

query

A Python-based connector that provides access to Microsoft SQL Server databases through the Model Context Protocol. This implementation enables language models to inspect table schemas and execute SQL queries against MSSQL databases through a standardized interface. The connector features asynchronous operation, environment-based configuration, connection pooling, and comprehensive error handling. It allows AI assistants to explore database structure, retrieve data, and perform both read and write operations with proper security controls.

Overview

The Microsoft SQL Server Connector provides a bridge between AI assistants and Microsoft SQL Server databases. It implements the Model Context Protocol (MCP) to allow language models to interact with SQL Server databases in a secure and structured way.

Installation

Prerequisites

Before installing the connector, ensure you have:

  1. Python 3.8 or higher
  2. ODBC Driver 17 for SQL Server installed on your system
  3. Access credentials for your SQL Server database

Setup Steps

  1. Clone the repository:

    git clone https://github.com/amornpan/py-mcp-mssql.git
    cd py-mcp-mssql
    
  2. Install the required dependencies:

    pip install -r requirements.txt
    
  3. Create a .env file in the project root with your database connection details:

    MSSQL_SERVER=your_server
    MSSQL_DATABASE=your_database
    MSSQL_USER=your_username
    MSSQL_PASSWORD=your_password
    MSSQL_DRIVER={ODBC Driver 17 for SQL Server}
    

Configuration with Claude Desktop

To use this connector with Claude Desktop, add the following to your Claude Desktop configuration file:

  • On MacOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • On Windows: %APPDATA%/Claude/claude_desktop_config.json
{
  "mcpServers": {
    "mssql": {
      "command": "python",
      "args": [
        "PATH_TO_REPOSITORY/src/mssql/server.py"
      ],
      "env": {
        "MSSQL_SERVER": "your_server",
        "MSSQL_DATABASE": "your_database",
        "MSSQL_USER": "your_username",
        "MSSQL_PASSWORD": "your_password",
        "MSSQL_DRIVER": "{ODBC Driver 17 for SQL Server}"
      }
    }
  }
}

Replace PATH_TO_REPOSITORY with the actual path to where you cloned the repository.

Usage

Once configured, the connector provides the following capabilities to AI assistants:

  1. Listing Database Tables: The assistant can discover all available tables in the connected database.

  2. Exploring Table Structure: The assistant can examine the schema of any table, including column names, data types, and constraints.

  3. Querying Data: The assistant can execute SELECT queries to retrieve data from the database.

  4. Modifying Data: The assistant can execute INSERT, UPDATE, and DELETE queries to modify data (if permissions allow).

All results are returned in a structured format that the AI can process and present to the user.

Security Considerations

This connector handles sensitive database credentials, so keep these security points in mind:

  • Store credentials in the .env file which should not be committed to version control
  • The connector implements input validation to help prevent SQL injection
  • Consider using a database user with limited permissions (read-only if possible)
  • Result sets are limited to prevent memory issues with large data retrieval

Troubleshooting

If you encounter issues:

  1. Verify your ODBC driver is correctly installed
  2. Check that your database credentials are correct
  3. Ensure your database user has appropriate permissions
  4. Look for error messages in the console where the server is running

For more detailed information, refer to the GitHub repository.

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.