SQL Server

Provides AI assistants with SQL Server database access capabilities, including query execution, schema inspection, and data operations.
  • python

0

GitHub Stars

python

Language

4 months ago

First Indexed

2 months ago

Catalog Refreshed

Documentation & install

Readme and setup notes from the catalogue, plus a client-ready config you can copy for your MCP host.

Installation

Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "nebhg-sql-server-mcp": {
      "command": "python",
      "args": [
        "-m",
        "sql_server_mcp.server"
      ],
      "env": {
        "SQL_SERVER_HOST": "192.168.1.117",
        "SQL_SERVER_PORT": "1433",
        "SQL_SERVER_DATABASE": "EM_Data",
        "SQL_SERVER_PASSWORD": "your_actual_password",
        "SQL_SERVER_USERNAME": "benhg"
      }
    }
  }
}

You can use this MCP server to give AI assistants safe, on-demand access to a SQL Server database. It lets you run queries with safety limits, inspect schemas, monitor table statistics, back up tables, insert data with conflict handling, and analyze query plans—all through an MCP client.

How to use

Connect your MCP client to the local server using the standard stdio setup. Start the server from your project directory and ensure you provide the required SQL Server connection details via environment variables. Once running, you can ask your AI assistant to run queries, inspect schemas, retrieve table information, backup tables, or check connection health. Practical usage patterns include querying for top records, exploring the database structure, and requesting execution plan details for complex queries.

How to install

Prerequisites you need before installation:

Python is required. You also need a SQL Server instance accessible from your machine.

# Navigate to project directory
cd C:\Users\benha\Desktop\sql-server-mcp

# Create virtual environment
python -m venv venv
venv\Scripts\activate

# Install dependencies
pip install -r requirements.txt

Prepare the database connection by creating or editing the configuration file that holds the connection details.

# Example .env contents
SQL_SERVER_HOST=192.168.1.117
SQL_SERVER_DATABASE=EM_Data
SQL_SERVER_USERNAME=benhg
SQL_SERVER_PASSWORD=your_actual_password
SQL_SERVER_PORT=1433

Test and run the server to verify the connection works.

python -m sql_server_mcp.server

Configuration and runtime details

The server relies on environment variables to configure the SQL Server connection. Ensure these are set before starting the server.

In addition to local setup, you can configure integration with AI tools to point at the MCP server. The following variables are used to connect to your SQL Server from clients.

Security and reliability notes

Automatic query limits help prevent runaway queries (TOP 1000 by default). All queries use parameterization to protect against injection. Environment-based configuration and connection health checks help maintain reliable operation.

Troubleshooting

If you encounter a connection issue, verify that the host, database, user, and password are correct and that the server is reachable over the specified port. Ensure the SQL Server user has the necessary permissions for the requested operations.

Common driver-related problems can be resolved by confirming you have the SQL Server ODBC driver installed and that your Python environment can import the necessary modules.

Examples of common tasks

Show me the schema of a table, e.g., SeriesRecord.

Execute a query such as a small SELECT with a limit to test the connection.

Create a backup of a table to preserve data before making changes.

Notes on usage with MCP clients

Once the server is running, you can direct your MCP client to use the sql_server_mcp.server module. The client will expose tools to execute queries, inspect schemas, retrieve table info, and perform backups through the MCP interface.

Available tools

execute_query

Run SQL queries with automatic safety limits and parameterized support to prevent injection.

get_schema

Inspect and explore the database schema to understand tables, columns, and relationships.

get_table_info

Provide detailed information about a specific table, including sample data.

explain_query

Analyze a query’s execution plan to help optimize performance.

check_connection

Verify connectivity to the SQL Server and validate credentials.

get_table_stats

Retrieve statistics for tables, including size and performance metrics.

search_tables

Search for tables and columns by name or pattern across the database.

backup_table

Create backups of a table for data safety and recovery.

insert_data

Insert data into tables with conflict handling strategies.

Built by
VeilStrat
AI signals for GTM teams
© 2026 VeilStrat. All rights reserved.All systems operational