
MCP server for MS SQL Server
概览
An easy-to-use bridge that lets AI assistants like Claude directly query and explore Microsoft SQL Server databases. No coding experience required! This tool allows AI assistants to: 1. tables in your SQL Server database 2. table structures (columns, data types, etc.) 3. read-only SQL queries safely 4. SQL queries from natural language requests - Install Node.js (version 14 or higher) - Have access to a Microsoft SQL Server database (on-premises or Azure) Edit the .env file with your database credentials: Best for: Using directly with Claude Desktop or the bundled client Best for: Network access or when used with web applications The bundled client provides an easy menu-driven interface: 1. - See what information is available 2. - See what actions you can perform 3. - Run a read-only SQL query 4. - View structure of any table 5. - See all tables and their relationships 6. - Convert natural language to SQL
README
以下为原文 README 节选,完整内容请查看原文。
MS SQL MCP Server
An easy-to-use bridge that lets AI assistants like Claude directly query and explore Microsoft SQL Server databases. No coding experience required!
What Does This Tool Do?
This tool allows AI assistants to:
- Discover tables in your SQL Server database
- View table structures (columns, data types, etc.)
- Execute read-only SQL queries safely
- Generate SQL queries from natural language requests
🚀 Quick Start Guide
Step 1: Install Prerequisites
- Install Node.js (version 14 or higher)
- Have access to a Microsoft SQL Server database (on-premises or Azure)
Step 2: Clone and Setup
# Clone this repository
git clone https://github.com/dperussina/mssql-mcp-server.git
# Navigate to the project directory
cd mssql-mcp-server
# Install dependencies
npm install
# Copy the example environment file
cp .env.example .env
Step 3: Configure Your Database Connection
Edit the .env file with your database credentials:
DB_USER=your_username
DB_PASSWORD=your_password
DB_SERVER=your_server_name_or_ip
DB_DATABASE=your_database_name
PORT=3333
TRANSPORT=stdio
SERVER_URL=http://localhost:3333
DEBUG=false # Set to 'true' for detailed logging (helpful for troubleshooting)
QUERY_RESULTS_PATH=/path/to/query_results # Directory where query results will be saved as JSON files
Step 4: Start the Server
# Start with default stdio transport
npm start
# OR start with HTTP/SSE transport for network access
npm run start:sse
Step 5: Try it out!
# Run the interactive client
npm run client
📊 Example Use Cases
-
Explore your database structure without writing SQL
mcp__discover_database() -
Get detailed information about a specific table
mcp__table_details({ tableName: "Customers" }) -
Run a safe query
mcp__execute_query({ sql: "SELECT TOP 10 * FROM Customers" }) -
Ask natural language questions
"Show me the top 5 customers with the most orders in the last month"
🔄 Transport Methods Explained
Option 1: stdio Transport (Default)
Best for: Using directly with Claude Desktop or the bundled client
npm start
Option 2: HTTP/SSE Transport
Best for: Network access or when used with web applications
npm run start:sse
🖥️ Interactive Client Features
The bundled client provides an easy menu-driven interface:
- List available resources - See what information is available
- List available tools - See what actions you can perform
- Execute SQL query - Run a read-only SQL query
- Get table details - View structure of any table
- Read database schema - See all tables and their relationships
- Generate SQL query - Convert natural language to SQL
🔗 Claude Desktop Integration
安装
This server does not publish a one-line install command.
Open the repository installation guide 新手?先看 mcpskill.org 教程 →配置
{
"mcpServers": {
"mssql": {
"command": "node",
"args": [
"/FULL/PATH/TO/mssql-mcp-server/server.mjs"
]
}
}
}