home / mcp / sql server

SQL Server

Provides an MCP-enabled interface to interact with SQL Server using natural language and stored procedures.

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "aman-panjwani-mcp-sql-server-natural-lang": {
      "command": "python",
      "args": [
        "mcp-ssms-client.py"
      ],
      "env": {
        "MSSQL_DRIVER": "{ODBC Driver 17 for SQL Server}",
        "MSSQL_SERVER": "localhost",
        "MSSQL_DATABASE": "your_database_name",
        "MSSQL_PASSWORD": "your_password",
        "MSSQL_USERNAME": "your_username",
        "OPENAI_API_KEY": "YOUR_OPENAI_API_KEY"
      }
    }
  }
}

You can query and manage your SQL Server using natural language with the SQL Server Agent powered by the Modal Context Protocol (MCP). This MCP-enabled agent connects your conversations to the database, enabling you to run queries, explore data, and execute stored procedures through plain English while preserving context across steps.

How to use

Launch the MCP client and start interacting with your SQL Server in conversational style. You type questions or requests in plain English, such as asking to create tables, retrieve employee data, or run stored procedures, and the agent handles translating these into database operations through the MCP layer. You can continue with follow-up questions to refine results or perform additional actions without restarting the session.

How to install

Follow these concrete steps to set up the SQL Server Agent locally.

# 1. Prerequisites
- Python 3.12+
- OpenAI API Key

# 2. Clone the project
git clone https://github.com/Amanp17/mcp-sql-server-natural-lang.git
cd mcp-sql-server-natural-lang

# 3. Install dependencies
pip install -r requirements.txt

# 4. Prepare environment variables
# Create a .env file in the project root with the following values
# (replace placeholders with your actual credentials)
OPENAI_API_KEY=your_openai_api_key
MSSQL_SERVER=localhost
MSSQL_DATABASE=your_database_name
MSSQL_USERNAME=your_username
MSSQL_PASSWORD=your_password
MSSQL_DRIVER={ODBC Driver 17 for SQL Server}

# 5. Run the client
python mcp-ssms-client.py

Additional sections

Configuration, security, and usage notes follow to help you operate safely and efficiently.

- Environment variables control access to the OpenAI API and your SQL Server connection. Keep your keys secret and avoid sharing the .env file.

- The MCP layer preserves conversation context across multiple steps, so you can build multi-step workflows like creating a table, inserting data, and then querying it in a single session.