MSSQL MCP Server
Overview
MSSQL MCP Server, provides database interaction and business intelligence capabilities. This server enables running SQL queries, analyzing business data, and automatically generating business insight memos.
Refer to the official website's SQLite for modifications to adapt to MSSQL
Components
read_query
- Execute SELECT queries to read data from the database
write_query
- Execute INSERT, UPDATE, or DELETE queries
create_table
- Create new tables in the database
list_tables
- Get a list of all tables in the database
describe-table
- View schema information for a specific table
append_insight
- Add new business insights to the memo resource
Demo
The database table is as follows. The column names are not standardized, and AI will match them on its own. Errors during SQL execution will self correct.
The following is the demo.
Operating environment
Python 3.x
Packages
- pyodbc>=4.0.39
- pydantic>=2.0.0
- mcp>=0.1.0
ODBC Driver 17 for SQL Server
Usage
Install packages
1CD /d ~/mssql-mcp 2pip install -r requirements.txt
config
1#with server.py same folder create config.json,add: 2{ 3 "database": { 4 "driver": "ODBC Driver 17 for SQL Server", 5 "server": "server ip", 6 "database": "db name", 7 "username": "username", 8 "password": "password", 9 "trusted_connection": false 10 }, 11 "server": { 12 "name": "mssql-manager", 13 "version": "0.1.0", 14 "host": "0.0.0.0", 15 "port": 8080 16 } 17}
Claude Desktop 、 Windsurf
1# add to claude_desktop_config.json. Note:use your path 2{ 3 "mcpServers": { 4 "mssql": { 5 "command": "python", 6 "args": [ 7 # your path,e.g.:"C:\\mssql-mcp\\src\\server.py" 8 "~/server.py" 9 ] 10 } 11 } 12}
Cursor
1# Add according to the following diagram Cursor MCP. Note:use your path
MCP Inspector
1# Note:use your path 2npx -y @modelcontextprotocol/inspector python C:\\mssql-mcp\\src\\server.py
Project Structure
mssql-mcp
├── .git
├── .gitignore
├── LICENSE
├── README.md
├── README_en.md
├── README_zh.md
├── imgs
│ ├── cursor_config.png
│ ├── table.png
│ └── demo.gif
├── requirements.txt
└── src
├── __init__.py
└── server.py
License
MIT License