by JexinSam
Provides secure, structured access to Microsoft SQL Server databases for AI assistants, enabling table listing, data retrieval, and controlled query execution.
Mssql Mcp Server enables AI assistants or other clients to interact with Microsoft SQL Server instances in a safe, permission‑controlled manner. It abstracts common database actions—listing tables, reading rows, and running ad‑hoc SQL—while enforcing strict access rules and logging every operation.
pip install mssql-mcp-server
export MSSQL_DRIVER=ODBC+Driver+17+for+SQL+Server
export MSSQL_HOST=localhost
export MSSQL_USER=my_user
export MSSQL_PASSWORD=secret
export MSSQL_DATABASE=my_db
# optional
export TrustServerCertificate=yes
export Trusted_Connection=no
python -m mssql_mcp_server
claude_desktop_config.json as shown in the README.Q: Do I need a dedicated database user? A: Yes. Create a user with only the permissions required for the allowed operations (e.g., SELECT on specific tables).
Q: Can I run write queries (INSERT/UPDATE)? A: The server can be configured to allow them, but it is recommended to keep the default read‑only mode for safety.
Q: How is logging handled? A: All incoming requests and their outcomes are logged to the standard output; you can redirect or extend this to file or monitoring services.
Q: What if I need to connect over SSL?
A: Use the TrustServerCertificate and related connection string options in the environment variables.
Q: Is the server compatible with other MCP clients? A: Yes, any client that follows the Model Context Protocol specification can communicate with this server.
MSSQL MCP Server is a Model Context Protocol (MCP) server that enables secure and structured interaction with Microsoft SQL Server (MSSQL) databases. It allows AI assistants to:
This ensures safer database exploration, strict permission enforcement, and logging of database interactions.
pip install mssql-mcp-server
Set the following environment variables to configure database access:
MSSQL_DRIVER=mssql_driver
MSSQL_HOST=localhost
MSSQL_USER=your_username
MSSQL_PASSWORD=your_password
MSSQL_DATABASE=your_database
#optional
TrustServerCertificate=yes
Trusted_Connection=no
To integrate with Claude Desktop, add this configuration to claude_desktop_config.json:
{
"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"
}
}
}
}
# Install dependencies
pip install -r requirements.txt
# Run the server
python -m mssql_mcp_server
# Clone the repository
git clone https://github.com/yourusername/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
For a secure setup:
For detailed instructions, refer to the MSSQL Security Configuration Guide.
⚠️ IMPORTANT: Always follow the Principle of Least Privilege when configuring database access.
This project is licensed under the MIT License. See the LICENSE file for details.
We welcome contributions! To contribute:
git checkout -b feature/amazing-featuregit commit -m 'Add amazing feature'git push origin feature/amazing-featureFor any questions or issues, feel free to open a GitHub Issue or reach out to the maintainers.
Please log in to share your review and rating for this MCP.
{
"mcpServers": {
"mssql": {
"command": "python",
"args": [
"-m",
"mssql_mcp_server"
],
"env": {
"MSSQL_DRIVER": "<YOUR_DRIVER>",
"MSSQL_HOST": "<YOUR_HOST>",
"MSSQL_USER": "<YOUR_USER>",
"MSSQL_PASSWORD": "<YOUR_PASSWORD>",
"MSSQL_DATABASE": "<YOUR_DATABASE>",
"TrustServerCertificate": "yes",
"Trusted_Connection": "no"
}
}
}
}claude mcp add mssql python -m mssql_mcp_serverExplore related MCPs that share similar capabilities and solve comparable challenges
by googleapis
An MCP server that streamlines database tool development by handling connection pooling, authentication, observability, and secure access, allowing agents to interact with databases via natural language.
by bytebase
Provides a universal gateway that lets MCP‑compatible clients explore and query MySQL, PostgreSQL, SQL Server, MariaDB, and SQLite databases through a single standardized interface.
by designcomputer
Enables secure interaction with MySQL databases via the Model Context Protocol, allowing AI applications to list tables, read contents, and execute queries safely.
by benborla
Provides read‑only access to MySQL databases for large language models, allowing schema inspection and safe execution of SQL queries.
by neo4j-contrib
Enables natural‑language interaction with Neo4j databases, allowing large language models to query, modify, and manage graph data through multiple transport modes.
by mongodb-js
Provides a Model Context Protocol server that enables interaction with MongoDB databases and MongoDB Atlas clusters through a unified API.
by ClickHouse
Enables AI assistants to run read‑only ClickHouse queries, list databases and tables, and execute embedded chDB queries through an MCP interface.
by neondatabase
Interact with Neon Postgres databases using natural language commands through the Model Context Protocol, enabling conversational database creation, migration, and query execution.
by motherduckdb
Enables SQL analytics on DuckDB and MotherDuck databases via a Model Context Protocol server, allowing AI assistants and IDEs to query data directly.