This repository provides a Python implementation of an MCP server for accessing Microsoft SQL Server databases, enabling language models to inspect schemas and execute queries through a standardized API.
This Python-based Model Context Protocol (MCP) server facilitates access to Microsoft SQL Server databases, enabling Language Models to inspect schemas and execute SQL queries via a standardized interface. Built with asynchronous operations using asyncio
, it leverages python-dotenv
for environment-based configuration, a comprehensive logging system, and pyodbc
for connection pooling and management.
Key features include FastAPI integration for API endpoints, Pydantic models for data validation, and robust error handling. The server supports listing available tables, reading data from specified tables (returning the first 100 rows in CSV format), and executing SQL queries (both SELECT and modification queries). It's designed for use with tools like Claude Desktop, allowing analysis and visualization of SQL data. Security features include environment variable-based configuration, connection string security, result set size limits, and input validation. The project is licensed under the MIT License.
amornpan/py-mcp-mssql
January 26, 2025
March 28, 2025
Python