
py-mcp-mssql
py-mcp-mssql
A Model Context Protocol server implementation in Python that provides access to Microsoft SQL Server databases. This server enables Language Models to inspect table schemas and execute SQL queries through a standardized interface.
asynciopython-dotenvgit clone https://github.com/amornpan/py-mcp-mssql.git
cd py-mcp-mssql
pip install -r requirements.txtThe screenshot above demonstrates the server being used with Claude to analyze and visualize SQL data.
PY-MCP-MSSQL/
├── src/
│ └── mssql/
│ ├── __init__.py
│ └── server.py
├── tests/
│ ├── __init__.py
│ ├── test_mssql.py
│ └── test_packages.py
├── .env
├── .env.example
├── .gitignore
├── README.md
└── requirements.txtsrc/mssql/ - Main source code directory
__init__.py - Package initializationserver.py - Main server implementationtests/ - Test files directory
__init__.py - Test package initializationtest_mssql.py - MSSQL functionality teststest_packages.py - Package dependency tests.env - Environment configuration file (not in git).env.example - Example environment configuration.gitignore - Git ignore rulesREADME.md - Project documentationrequirements.txt - Project dependenciesCreate a .env file in the project root:
MSSQL_SERVER=your_server
MSSQL_DATABASE=your_database
MSSQL_USER=your_username
MSSQL_PASSWORD=your_password
MSSQL_DRIVER={ODBC Driver 17 for SQL Server}@app.list_resources()
async def list_resources() -> list[Resource]mssql://<table_name>/data@app.read_resource()
async def read_resource(uri: AnyUrl) -> strmssql://<table_name>/data@app.call_tool()
async def call_tool(name: str, arguments: dict) -> list[TextContent]Add to your Claude Desktop configuration:
On MacOS: ~/Library/Application Support/Claude/claude_desktop_config.json
On Windows: %APPDATA%/Claude/claude_desktop_config.json
{
"mcpServers": {
"mssql": {
"command": "python",
"args": [
"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}"
}
}
}
}The server implements comprehensive error handling for:
All errors are logged and returned with appropriate error messages.
Feel free to reach out to me if you have any questions about this project or would like to collaborate!
Made with ❤️ by Amornpan Phornchaicharoen
This project is licensed under the MIT License - see the LICENSE file for details.
Amornpan Phornchaicharoen
git checkout -b feature/amazing-feature)git commit -m 'Add some amazing feature')git push origin feature/amazing-feature)Create a requirements.txt file with:
fastapi>=0.104.1
pydantic>=2.10.6
uvicorn>=0.34.0
python-dotenv>=1.0.1
pyodbc>=4.0.35
anyio>=4.5.0
mcp==1.2.0These versions have been tested and verified to work together. The key components are:
fastapi and uvicorn for the API serverpydantic for data validationpyodbc for SQL Server connectivitymcp for Model Context Protocol implementationpython-dotenv for environment configurationanyio for asynchronous I/O supportPick your client and paste the snippet. Each one is the same server, written the way that client expects it.
claude mcp add mssql -- python server.py{
"mcpServers": {
"mssql": {
"env": {
"MSSQL_USER": "",
"MSSQL_DRIVER": "",
"MSSQL_SERVER": "",
"MSSQL_DATABASE": "",
"MSSQL_PASSWORD": ""
},
"args": [
"server.py"
],
"command": "python"
}
}
}code --add-mcp '{"name":"mssql","env":{"MSSQL_USER":"","MSSQL_DRIVER":"","MSSQL_SERVER":"","MSSQL_DATABASE":"","MSSQL_PASSWORD":""},"args":["server.py"],"command":"python"}'[mcp_servers.mssql]
command = "python"
args = ["server.py"]Runs locally on your device. Your client starts the server itself, so nothing has to be hosted.
Paste this prompt into your agent. It reads this page and does the setup for you.
Read https://aiagentslisting.com/mcp/python-mssql-mcp-server to learn what the "Python MSSQL MCP Server" MCP server does and how to install it. Add it to my coding agent's MCP configuration as documented on that page, then confirm the server connects and list the tools it exposes.Agents can also browse this directory over MCP at https://aiagentslisting.com/api/mcp
This server runs locally, so we can't read its tool list over the web yet.
Maintain this server? Claiming proves you own the listing and earns the last 4 points.
Claim this listingPaste this line near the top of your repository's README. The badge always renders the current score.
[](https://aiagentslisting.com/mcp/python-mssql-mcp-server)Nothing comparable is listed yet.
No tagged releases on record.
Connect to the AI Agents Listing MCP server at https://aiagentslisting.com/api/mcp using the HTTP transport and complete the sign-in when it asks. Then call the submit_review tool for the listing "python-mssql-mcp-server" with a rating from 1 to 5 and a short note on what worked and what did not.No reviews yet
Be the first to share your experience with this tool.
One email a week. New agents, MCP servers and skills, and what is actually getting traction.