This guide explains what MCP is, how it works, and how pymssql-mcp connects your Microsoft SQL Server database to AI assistants like Claude.
MCP (Model Context Protocol) is an open standard created by Anthropic that allows AI assistants to connect to external tools and data sources. Think of it as a "plugin system" for AI.
Without MCP, AI assistants like Claude can only:
- Answer questions from their training data
- Help with text in the conversation
- Have no access to your specific systems or data
With MCP, AI assistants can:
- Connect to your databases and query real data
- Read and write files on your system
- Call APIs and web services
- Execute commands and run programs
- Remember information across conversations
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ │ │ │ │ │
│ Claude Desktop │◄───►│ MCP Server │◄───►│ Your System │
│ (AI Assistant) │ │ (pymssql-mcp) │ │ (SQL Server) │
│ │ │ │ │ │
└─────────────────┘ └─────────────────┘ └─────────────────┘
You talk to Translates Your actual
Claude here requests data lives here
- You ask Claude a question like "Show me all customers in California"
- Claude recognizes it needs database access and calls the MCP server
- The MCP server (pymssql-mcp) translates this into a SQL query
- SQL Server returns the data
- pymssql-mcp formats the results and sends them back to Claude
- Claude presents the information to you in a readable format
| Component | What It Is | Example |
|---|---|---|
| MCP Host | The AI application that uses MCP | Claude Desktop, Claude Code |
| MCP Server | A program that provides tools/data | pymssql-mcp (this project) |
| Tools | Actions the AI can perform | execute_query, insert_row |
| Resources | Data the AI can access | Database knowledge, syntax help |
pymssql-mcp is an MCP server specifically for Microsoft SQL Server databases.
It allows Claude to:
- Query your SQL Server database using natural language
- Read and write rows in tables
- Explore table structures and schemas
- Execute stored procedures
- Learn and remember information about your database
Without pymssql-mcp:
You: "How many customers do we have in California?" Claude: "I don't have access to your database. You would need to run a query like
SELECT COUNT(*) FROM Customers WHERE State = 'CA'..."
With pymssql-mcp:
You: "How many customers do we have in California?" Claude: "You have 1,247 customers in California. The largest by revenue is Acme Corp (CustomerID: 12345)."
Claude can actually connect to your database, run the query, and give you real answers.
pymssql-mcp runs as a local process on your computer, alongside Claude Desktop.
Your Computer
┌────────────────────────────────────────────────┐
│ │
│ ┌──────────────┐ ┌──────────────┐ │
│ │ Claude │ │ pymssql-mcp │ │
│ │ Desktop │◄────►│ (local) │ │
│ └──────────────┘ └──────┬───────┘ │
│ │ │
└───────────────────────────────┼───────────────┘
│
▼
┌──────────────────────┐
│ SQL Server │
│ Server │
└──────────────────────┘
(Can be local or remote)
- pymssql-mcp runs on your machine
- Credentials stay on your machine
- Connection goes directly to your database server
- Only you can access this instance
For teams, pymssql-mcp can run as an HTTP server:
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ User 1's Claude │ │ │ │ │
│ Desktop │────►│ │ │ │
├─────────────────┤ │ pymssql-mcp │ │ SQL Server │
│ User 2's Claude │────►│ HTTP Server │────►│ Server │
│ Desktop │ │ │ │ │
├─────────────────┤ │ │ │ │
│ User 3's Claude │────►│ │ │ │
│ Desktop │ │ │ │ │
└─────────────────┘ └─────────────────┘ └─────────────────┘
- Single pymssql-mcp instance serves multiple users
- Shared knowledge base
- Centralized credential management
When you install pymssql-mcp and configure Claude Desktop, Claude gains new abilities called tools. Here's what happens:
When Claude Desktop starts, it discovers what tools pymssql-mcp provides:
connect- Connect to the databaseexecute_query- Run SQL queriesread_rows- Read table datadescribe_table- Explore table structure- ...and 20+ more tools
When you ask a question, Claude decides which tools to use:
You: "What columns are in the Customers table?"
Claude thinks: "The user wants to know about table structure. I should use the describe_table tool."
Claude calls the tool with appropriate parameters:
describe_table(table="Customers")
Claude receives the raw data and presents it clearly:
Claude: "The Customers table has 8 columns:
- CustomerID (int) - Primary key
- Name (nvarchar) - Customer name
- Email (varchar) - Email address, nullable ..."
pymssql-mcp works with Microsoft SQL Server databases. Here are some key concepts:
| Concept | Description | Example |
|---|---|---|
| Database | Container for tables and objects | SalesDB, HRDatabase |
| Schema | Namespace within a database | dbo, Sales, HR |
| Table | Collection of rows with defined columns | dbo.Customers |
| View | Virtual table based on a query | dbo.vw_ActiveCustomers |
| Stored Procedure | Pre-compiled SQL statements | dbo.sp_GetCustomerOrders |
Tables in SQL Server are referenced as schema.table:
dbo.Customers- Customers table in dbo schemaSales.Orders- Orders table in Sales schemaCustomers- Defaults todbo.Customers
pymssql-mcp connects to your database with the credentials you provide. It can:
- Read any table/view the user account can read
- Write to tables (unless read-only mode is enabled)
- Execute stored procedures
- Switch between databases on the server
- Read-only mode - Prevents all write operations (INSERT, UPDATE, DELETE)
- Command blocking - Dangerous commands like DROP, TRUNCATE are blocked
- Query validation - Only safe query patterns are allowed
- Result limiting - Large queries are automatically limited
- Database blocklist - Certain databases can be hidden entirely
- Schema restrictions - Limit access to specific schemas only
- Use read-only mode when exploring or for most users
- Create a dedicated database user with minimal permissions
- Review the blocked commands and add more if needed
- Keep credentials secure - never commit them to source control
- Use the database blocklist to hide sensitive databases
No! That's the point of pymssql-mcp. You can ask questions in plain English:
- "Show me all open orders" instead of
SELECT * FROM Orders WHERE Status = 'Open' - "Count customers by state" instead of
SELECT State, COUNT(*) FROM Customers GROUP BY State
Claude will generate the appropriate queries.
Initially, no. But pymssql-mcp has a knowledge persistence feature. As Claude explores your database, it can save what it learns:
- "dbo.Customers is the customer master table"
- "StatusCode 1=Active, 2=Inactive, 3=Suspended"
- "OrderTotal is calculated from LineItems"
This knowledge persists across sessions, so Claude gets smarter over time.
Yes, with HTTP mode. One pymssql-mcp server can serve multiple Claude Desktop users, and they can share a common knowledge base.
Your database queries and results pass through Claude (Anthropic's AI), similar to if you typed the data into a chat. Review Anthropic's privacy policy if this is a concern for your data.
The pymssql-mcp server itself runs locally and doesn't send data anywhere except to Claude and your database.
pymssql-mcp uses the pymssql package which supports:
- SQL Server 2012 and later
- Azure SQL Database
- Azure SQL Managed Instance
Ready to get started?
- Installation Guide - Install pymssql-mcp and configure Claude Desktop
- Quickstart Guide - Get running in 10 minutes
- Configuration Reference - All configuration options
- Usage Examples - See what you can do
- Tools Reference - Detailed tool documentation