SQL Server Natural Language MCP server

Enables natural language querying of Microsoft SQL Server databases by translating conversational input into SQL and interpreting results for database administrators and analysts
Back to servers
Setup instructions
Provider
Aman Panjwani
Release date
Mar 25, 2025
Language
Python
Stats
1 star

This MCP server acts as a bridge between natural language and SQL Server databases, allowing you to interact with your database using plain English. The Modal Context Protocol (MCP) serves as an intelligent layer, enabling conversational database operations without writing any SQL code.

Prerequisites

Before setting up the SQL Server Agent, ensure you have:

  • Python 3.12+ installed on your machine
  • A valid OpenAI API Key

Installation

1. Clone the Repository

git clone https://github.com/Amanp17/mcp-sql-server-natural-lang.git
cd mcp-sql-server-natural-lang

2. Install Dependencies

pip install -r requirements.txt

3. Configure Environment Variables

Create a .env file in the project root and add your configuration details:

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}

Using the SQL Server Agent

Starting the Agent

Run the client script to start interacting with your database:

python mcp-ssms-client.py

Querying Your Database

When prompted, you can enter natural language queries. For example:

Enter your Query: Create a Employee table with 10 dummy data in it with their departments and salaries.

The agent will interpret your request, generate the appropriate SQL, and execute it against your database.

Sample Interactions

You can ask various types of questions or give commands, such as:

  • Creating tables and data: "Create a customers table with fields for name, email and purchase date"
  • Querying data: "Show me the employees and their departments"
  • Filtering results: "How many employees are having salary under $40K?"
  • Executing procedures: "Run the monthly sales report procedure"

Context-Aware Conversations

The SQL Server Agent maintains context throughout your conversation, so you can ask follow-up questions without repeating information:

Enter your Query: Show me all employees
[Results display]

Enter your Query: Which ones are in the Marketing department?
[Filtered results display]

Key Features

  • Natural language database interaction - query and manipulate your database using plain English
  • No SQL knowledge required - the agent translates your requests into proper SQL commands
  • Context preservation - maintains conversation history for more intuitive interactions
  • Stored procedure execution - run complex database operations with simple commands
  • Intelligent query interpretation - uses MCP to accurately understand your intentions

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "sql-server-natural-lang" '{"command":"python","args":["mcp-ssms-client.py"]}'

See the official Claude Code MCP documentation for more details.

For Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "sql-server-natural-lang": {
            "command": "python",
            "args": [
                "mcp-ssms-client.py"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

{
    "mcpServers": {
        "sql-server-natural-lang": {
            "command": "python",
            "args": [
                "mcp-ssms-client.py"
            ]
        }
    }
}

3. Restart Claude Desktop for the changes to take effect

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later