Get pymssql-mcp running with Claude Desktop in 10 minutes.
Before starting, make sure you have:
- Claude Desktop installed (download here)
- Python 3.10 or later installed
- Access to a SQL Server database with:
- Hostname or IP address
- Username and password
- Database name to connect to
- Network access from your computer
Open your terminal (Command Prompt on Windows, Terminal on Mac/Linux) and run:
pip install pymssql-mcpTo verify it installed correctly:
pymssql-mcp --helpYou should see:
usage: pymssql-mcp [-h] [--http] [--streamable-http] [--host HOST] [--port PORT]
MS SQL MCP Server - Connect AI assistants to SQL Server databases
Claude Desktop stores its configuration in a JSON file. Find it at:
| Operating System | Config File Location |
|---|---|
| macOS | ~/Library/Application Support/Claude/claude_desktop_config.json |
| Windows | %APPDATA%\Claude\claude_desktop_config.json |
| Linux | ~/.config/Claude/claude_desktop_config.json |
Quick way to open on macOS:
open ~/Library/Application\ Support/Claude/Quick way to open on Windows:
explorer %APPDATA%\Claude
If the file doesn't exist, create it.
Edit claude_desktop_config.json and add the pymssql-mcp configuration:
{
"mcpServers": {
"mssql": {
"command": "pymssql-mcp",
"env": {
"MSSQL_HOST": "your-server-hostname",
"MSSQL_USER": "your-username",
"MSSQL_PASSWORD": "your-password",
"MSSQL_DATABASE": "your-database-name",
"MSSQL_READ_ONLY": "true"
}
}
}
}Replace the placeholder values:
| Setting | Replace With | Example |
|---|---|---|
MSSQL_HOST |
Your SQL Server hostname | sqlserver.company.com |
MSSQL_USER |
Your database username | appuser |
MSSQL_PASSWORD |
Your database password | secretpassword |
MSSQL_DATABASE |
Your database name | SalesDB |
Important: We set MSSQL_READ_ONLY=true for safety while you're learning. This prevents any accidental data changes.
If you're connecting to Azure SQL Database:
{
"mcpServers": {
"mssql": {
"command": "pymssql-mcp",
"env": {
"MSSQL_HOST": "your-server.database.windows.net",
"MSSQL_USER": "your-admin@your-server",
"MSSQL_PASSWORD": "your-password",
"MSSQL_DATABASE": "your-database",
"MSSQL_READ_ONLY": "true"
}
}
}
}Completely quit Claude Desktop (not just close the window):
- macOS: Press Cmd+Q or right-click the dock icon and choose Quit
- Windows: Right-click the system tray icon and choose Exit
Then reopen Claude Desktop.
In Claude Desktop, you should see a hammer icon in the input area, indicating tools are available.
Try asking Claude:
"Connect to the database and tell me the current database name"
Claude should respond with your connection details:
"I've connected to SQL Server. You're connected to the 'SalesDB' database on server 'sqlserver.company.com'."
Now you can ask Claude about your database:
"What tables are available in this database?"
"Describe the Customers table"
"Show me the first 10 rows from the Orders table"
"Count how many customers we have"
"Read the customer with ID 12345"
- Make sure you completely quit and reopened Claude Desktop
- Check your config file for JSON syntax errors (missing commas, quotes)
- Verify pymssql-mcp is installed:
pymssql-mcp --help
- Verify your credentials work with other SQL tools (SSMS, Azure Data Studio)
- Check the hostname is reachable from your computer
- Verify the port - default is 1433
- Check firewall rules allow connections
Claude Desktop logs MCP server output. Check:
macOS:
cat ~/Library/Logs/Claude/mcp-server-mssql.logWindows:
%APPDATA%\Claude\Logs\mcp-server-mssql.log
If Claude can't find Python or pymssql-mcp, use the full path:
{
"mcpServers": {
"mssql": {
"command": "/usr/local/bin/pymssql-mcp",
"env": { ... }
}
}
}Find your pymssql-mcp path with: which pymssql-mcp (Mac/Linux) or where pymssql-mcp (Windows)
Now that you're connected:
- Learn what Claude can do - See Usage Examples
- Understand the tools - See Tools Reference
- Configure more options - See Configuration Reference
- Learn how it works - See What is MCP?
| What You Want | Ask Claude |
|---|---|
| List tables | "What tables are in this database?" |
| Table structure | "Describe the Orders table" |
| Query data | "List customers in California" |
| Read row | "Read the order with OrderID 123" |
| Count records | "How many open invoices are there?" |
| Column info | "What columns are in the Products table?" |
{
"mcpServers": {
"mssql": {
"command": "pymssql-mcp",
"env": {
"MSSQL_HOST": "server.example.com",
"MSSQL_USER": "username",
"MSSQL_PASSWORD": "password",
"MSSQL_DATABASE": "DatabaseName",
"MSSQL_PORT": "1433",
"MSSQL_READ_ONLY": "true",
"MSSQL_MAX_ROWS": "1000"
}
}
}
}| Variable | Required | Description |
|---|---|---|
MSSQL_HOST |
Yes | Server hostname |
MSSQL_USER |
Yes | Username |
MSSQL_PASSWORD |
Yes | Password |
MSSQL_DATABASE |
Yes | Database name |
MSSQL_PORT |
No | Port (default: 1433) |
MSSQL_READ_ONLY |
No | Set to true to prevent writes |
MSSQL_MAX_ROWS |
No | Limit query results (default: 1000) |