Enable natural language SQL queries with Claude using direct SQL Server MCP integration for easy data analysis
The SQL Server MCP (Model Context Protocol) Server is designed to enable advanced integration of natural language processing and query capabilities directly with data stored in a Microsoft SQL Server database. This server leverages the Model Context Protocol (MCP), Anthropic’s standardized communication protocol, allowing AI applications such as Claude Desktop, Continue, Cursor, and others to interact with SQL Server without requiring intermediate tools or additional setup.
The SQL Server MCP integration offers several key features that enhance the usability and efficiency of integrating natural language queries into AI workflows:
pymssql
, a Python DB-API interface for SQL Server, this integration avoids the complexity of setting up and maintaining an ODBC connection, simplifying setup.graph TD
A[AI Application] -->|MCP Client| B[MCP Protocol]
B --> C[MCP Server]
C --> D[SQL Query Execution]
style A fill:#e1f5fe
style C fill:#f3e5f5
style D fill:#e8f5e8
graph TD
SQLServerDB[SQL Server Database] -->|MCP Request| MCPAPI{MCP API}
MCPAPI -->|Data Conversion| PyMSSQL{pymssql}
PyMSSQL -->|Query Execution| ResultParser
ResultParser --> AIApp[AI Application]
pymssql
.To set up this MCP server, follow these steps:
./install_sql_mcp.sh
Follow prompts to enter SQL Server connection details:
The installation script will handle the setup of dependencies, configuration for FreeTDS, Python virtual environment creation, package installations, and script setup.
Verification: Run a simple query to verify:
./run_simple_sql.sh "SELECT 1 AS TestQuery"
Before executing specific queries, it's beneficial to first understand the schema of your database.
Action: @sql execute_sql
Command:
SELECT TABLE_NAME, COLUMN_NAME, DATA_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = 'dbo' ORDER BY TABLE_NAME, ORDINAL_POSITION
Understanding user data within specific contexts can be crucial for personalized applications.
Action: @sql execute_sql
Command:
SELECT COUNT(*) FROM Users WHERE IsActive = 1
MCP clients that support this SQL Server integration include:
MCP Client | Resources | Tools | Prompts | Status |
---|---|---|---|---|
Claude Desktop | ✅ | ✅ | ✅ | Full Support |
Continue | ✅ | ✅ | ✅ | Full Support |
Cursor | ❌ (Tools Only) | ✅ (Analytical Tools) | ❌ | N/A |
{
"mcpServers": {
"[server-name]": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-sql"],
"env": {
"API_KEY": "your-api-key"
}
}
}
}
For security, use a database account with restricted permissions:
pymssql
provides a simpler setup process without requiring additional configuration or dependencies.Contributing to this project involves several steps:
Clone the Repository:
git clone https://github.com/anthropic/sql-server-mcp.git
Install Dependencies:
brew install freetds
).Testing:
Contributing Code:
This SQL Server MCP integration is part of a larger MCP ecosystem that includes various tools and resources such as FreeTDS and pymssql. Engage with the community and explore additional MCP integrations available in the Anthropic cookbook repository.
Resources:
By integrating this SQL Server MCP server, developers can streamline their AI workflows and provide more sophisticated data analysis capabilities to users.
Learn how to use MCProto Ruby gem to create and chain MCP servers for custom solutions
AI Vision MCP Server offers AI-powered visual analysis, screenshots, and report generation for MCP-compatible AI assistants
Analyze search intent with MCP API for SEO insights and keyword categorization
Next-generation MCP server enhances documentation analysis with AI-powered neural processing and multi-language support
Connects n8n workflows to MCP servers for AI tool integration and data access
Expose Chicago Public Schools data with a local MCP server accessing SQLite and LanceDB databases