home / mcp / mcp sql server

MCP SQL Server

Provides SQL server operations via a conversational MCP interface for querying and managing databases.

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "dennismartis-sql_mcp_server": {
      "command": "python",
      "args": [
        "mcp_sql_server.py"
      ]
    }
  }
}

You can run a FastMCP-based server that exposes MS SQL Server operations through a conversational interface. This enables you to query, describe, and modify your SQL databases using natural language, while handling the underlying SQL interactions in a non-blocking, scalable way.

How to use

You interact with the MCP server via a client that sends natural language requests. You can ask it to run SQL queries, list tables, describe a table’s columns, and perform data-changing operations like INSERTs, UPDATEs, or DELETEs. You can also view which ODBC drivers are installed and retrieve general information about the connected database. The server handles non-blocking execution, error reporting, and transaction management so you can focus on results and data insights.

How to install

Prerequisites you need before starting are Python 3.7 or newer and a SQL Server instance with the appropriate ODBC driver.

Install the required Python packages.

{
  "step": "Install dependencies",
  "command": "pip install pyodbc asyncio fastmcp"
}

Run the MCP SQL Server

Start the MCP SQL Server using Python to execute the server script. Ensure your connection parameters are configured in the script or environment as needed.

{
  "step": "Run the server",
  "command": "python mcp_sql_server.py",
  "notes": "The server initializes and connects to the configured SQL Server database."
}

Available tools

query_sql

Execute a SQL query and return the results. Accepts an optional query parameter; if omitted, defaults to selecting all rows from [dbo].[Table_1]. Returns the results as a formatted string.

list_tables

List all tables in the connected database and return their names as a string.

describe_table

Return the column information for a specified table, including column names and data types.

execute_nonquery

Execute non-query SQL statements such as INSERT, UPDATE, or DELETE. Returns the number of affected rows and handles transactions (commit/rollback) automatically.

list_odbc_drivers

List all ODBC drivers installed on the system, returned as a comma-separated string.

database_info

Provide high-level information about the connected database, including server name, database name, SQL Server version, current server time, and table count.