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.
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.
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.
Before installing the connector, ensure you have:
Clone the repository:
git clone https://github.com/amornpan/py-mcp-mssql.git
cd py-mcp-mssql
Install the required dependencies:
pip install -r requirements.txt
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}
To use this connector with Claude Desktop, add the following to your Claude Desktop configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%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.
Once configured, the connector provides the following capabilities to AI assistants:
Listing Database Tables: The assistant can discover all available tables in the connected database.
Exploring Table Structure: The assistant can examine the schema of any table, including column names, data types, and constraints.
Querying Data: The assistant can execute SELECT queries to retrieve data from the database.
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.
This connector handles sensitive database credentials, so keep these security points in mind:
.env
file which should not be committed to version controlIf you encounter issues:
For more detailed information, refer to the GitHub repository.