sql_mcp_server
MCP SQL Server is a FastMCP server offering a conversational AI interface for SQL database interaction. It allows users to perform database operations such as querying, listing tables, and executing non-query operations using natural language. The server emphasizes asynchronous operation and security measures.
MCP SQL Server Overview
This project creates a server that exposes MS SQL Server operations through a conversational AI interface. It uses the FastMCP framework to provide tools for querying and manipulating SQL data, allowing users to interact with databases using natural language.
Features
- Execute SQL queries and view results
- List available tables in the database
- Describe table structure with column information
- Execute non-query operations (INSERT, UPDATE, DELETE)
- List available ODBC drivers on the system
- View database information and server details
Requirements
- Python 3.7+
- pyodbc
- asyncio
- FastMCP framework
- Microsoft SQL Server
- ODBC Driver 17 for SQL Server
Usage
Run the server. The server will initialize and establish a connection to the specified SQL Server database.
Architecture
The server uses an asynchronous architecture to avoid blocking operations.
Error Handling
The server handles various error conditions and logs all errors with useful error messages.
Security Considerations
- Uses Windows Authentication ("Trusted_Connection=yes")
- Implement input validation to prevent SQL injection
- Restrict database user permissions