The SQL Server MCP server enables AI assistants like Claude to interact with Microsoft SQL Server databases through natural language and a standardized protocol.
Connection Management: Connect to and disconnect from databases, list active connections, list available databases (including system databases), and switch between database contexts.
Data Querying & Reading: Execute read-only SQL SELECT queries with automatic row limits, read rows by primary key, multiple IDs, or custom filters, validate query safety, and select specific or all columns from tables.
CRUD Operations: Insert new rows with automatic identity column handling, update existing rows by primary key, delete rows by primary key, and use schema-qualified table names.
Schema Exploration: List tables and views with optional schema and pattern filtering, examine columns, data types, nullability, primary/foreign key relationships, and indexes.
Stored Procedure Management: List available stored procedures with filtering, describe parameters (name, type, direction), execute procedures with input parameters, and retrieve multiple result sets.
Data Export: Export query results to JSON or CSV files with custom delimiters, and get file metadata including path, row count, and file size.
Transaction Control: Begin, commit, and roll back database transactions.
Safety & Security Features: Read-only mode, command blocking for dangerous SQL operations (DROP, TRUNCATE, etc.), maximum row limits, query validation with warnings and suggestions, schema restrictions, database blocklists, and parameterized queries to prevent SQL injection.
AI Integration Features: Knowledge persistence to save and retrieve learned information about the database, search saved knowledge for context-aware interactions, natural language query support, and automatic connection recovery with watchdog functionality.
Deployment Options: Run locally with Claude Desktop, as HTTP server, or with OAuth for Claude.ai integration.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@SQL Server MCPshow me the top 5 customers by total purchases"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
pymssql-mcp
An MCP (Model Context Protocol) server for Microsoft SQL Server databases. Enables AI assistants like Claude to interact with SQL Server through a standardized protocol.
Features
Natural Language Queries: Ask Claude about your data in plain English
Schema Discovery: Explore tables, views, columns, and relationships
CRUD Operations: Read, insert, update, and delete rows safely
Stored Procedures: Execute stored procedures with parameters
Multi-Database Support: List and switch between databases
Data Export: Export query results to JSON or CSV files
Transaction Support: Begin, commit, and rollback transactions
Knowledge Persistence: Claude remembers what it learns about your database
Safety Controls: Read-only mode, command blocking, row limits, schema restrictions
Connection Watchdog: Automatic recovery from hung connections
OAuth Integration: Deploy as a Claude.ai Custom Connector with SSO
Documentation
Guide | Description |
Understanding MCP and pymssql-mcp | |
Complete installation guide | |
Get running in 10 minutes | |
All configuration options | |
Detailed tool documentation | |
Common usage patterns | |
Claude.ai integration with SSO |
Quick Start
1. Install
2. Configure Claude Desktop
Edit your Claude Desktop config file:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
3. Restart Claude Desktop
Quit and reopen Claude Desktop. You'll see a hammer icon indicating tools are available.
4. Start Chatting
Ask Claude about your database:
"What tables are available?"
"Describe the Customers table"
"Show me the top 10 orders by total amount"
"How many customers do we have in each state?"
Available Tools
Connection & Database
Tool | Description |
| Connect to the database |
| Close all connections |
| List available databases |
| Switch database context |
Queries & Schema
Tool | Description |
| Run a SELECT query |
| Check if a query is safe |
| List tables and views |
| Get column information |
CRUD Operations
Tool | Description |
| Read rows by ID or filter |
| Insert a new row |
| Update an existing row |
| Delete a row |
Stored Procedures
Tool | Description |
| List available procedures |
| Get procedure parameters |
| Execute a procedure |
Export & Transactions
Tool | Description |
| Export results to JSON |
| Export results to CSV |
| Start a transaction |
| Commit changes |
| Rollback changes |
Knowledge Persistence
Tool | Description |
| Save learned information |
| Retrieve all knowledge |
| Search saved knowledge |
Configuration
Required Variables
Variable | Description |
| SQL Server hostname |
| Database username |
| Database password |
| Database name |
Safety Settings
Variable | Default | Description |
|
| Block all write operations |
|
| Maximum rows per query |
|
| Commands to block |
| (all) | Restrict to specific schemas |
| (none) | Hide specific databases |
See Configuration Reference for all options.
Deployment Modes
Local (Default)
Run as a local process with Claude Desktop:
HTTP/SSE Server
Run as a shared HTTP server for multiple users:
Streamable HTTP (Claude.ai Integration)
Run with OAuth authentication for Claude.ai:
See OAuth Setup for complete integration instructions.
Development
Security
pymssql-mcp includes multiple safety features:
Read-only mode: Prevent all write operations
Command blocking: Block dangerous SQL commands (DROP, TRUNCATE, etc.)
Schema restrictions: Limit access to specific schemas
Database blocklist: Hide sensitive databases
Row limits: Cap query results to prevent memory issues
Query validation: Analyze queries before execution
Parameterized queries: Prevent SQL injection
See SECURITY.md for security policy and best practices.
Contributing
Contributions are welcome! See CONTRIBUTING.md for guidelines.
License
Apache-2.0. See LICENSE for details.