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.
Before setting up the SQL Server Agent, ensure you have:
git clone https://github.com/Amanp17/mcp-sql-server-natural-lang.git
cd mcp-sql-server-natural-lang
pip install -r requirements.txt
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}
Run the client script to start interacting with your database:
python mcp-ssms-client.py
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.
You can ask various types of questions or give commands, such as:
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]
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.
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.
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"
]
}
}
}
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.
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.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.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