MCP MS SQL Server
Generates Jupyter notebooks with automated analysis code from database queries.
Click on "Deploy 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., "@MCP MS SQL Server list all tables in the database"
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.
MCP MS SQL Server
A Model Context Protocol (MCP) server for Microsoft SQL Server that provides tools for database operations, data analysis, and visualization generation.
Table of Contents
Related MCP server: MSSQL MCP Server
Features
8 Powerful Database Tools - Query execution, schema exploration, and data analysis
Interactive Visualizations - Bar charts, scatter plots, heatmaps, and more
Jupyter Notebook Generation - Automated analysis code creation
Power BI Integration - Export data in Power BI compatible formats
Security Controls - Granular permissions for write operations
Connection Pooling - Optimized performance with configurable pools
Quick Start
Install the package
pip install mcp-mssql-serverCreate configuration
# Create .env file DB_TYPE=mssql MSSQL_SERVER=tcp:your-server.database.windows.net MSSQL_USER=your-username MSSQL_PASSWORD=your-password MSSQL_DATABASE=your-databaseRun the server
uv run python mssql.py or uv run python main.py
Installation
Option 1: Using pip
pip install mcp-mssql-serverOption 2: Using uv
uv pip install mcp-mssql-serverOption 3: From source
git clone https://github.com/SerenaHangSinclair/mcp-mssql-server.git
cd mcp-mssql-server
pip install -e .Configuration
Create a .env file in your project root with the basic required settings:
# Database Connection (Required)
DB_TYPE=mssql
MSSQL_SERVER=tcp:your-server.database.windows.net
MSSQL_PORT=1433
MSSQL_USER=your-username
MSSQL_PASSWORD=your-password
MSSQL_DATABASE=your-database
# Security (Recommended)
ALLOW_WRITE_OPERATIONS=false# Database Type (mssql)
DB_TYPE=mssql
# SQL Server Configuration
MSSQL_SERVER=tcp:your-server.database.windows.net
MSSQL_PORT=1433
MSSQL_USER=your-username
MSSQL_PASSWORD=your-password
MSSQL_DATABASE=your-database
MSSQL_ENCRYPT=true
MSSQL_TRUST_SERVER_CERTIFICATE=true
# Security Settings
ALLOW_WRITE_OPERATIONS=false
ALLOW_INSERT_OPERATION=false
ALLOW_UPDATE_OPERATION=false
ALLOW_DELETE_OPERATION=false
# Performance Settings
CONNECTION_POOL_MIN=1
CONNECTION_POOL_MAX=10
QUERY_TIMEOUT=30000Usage
Running the MCP Server
Suggest to use uv to create a sperate virtual environment for the MCP construction. Remember to install uv/:
Windows
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"MacOS/Linux
curl -LsSf https://astral.sh/uv/install.sh | sh uv venvRunning the MCP Server
Basic usage:
uv run python main.py or uv run python mssql.py
With logging enabled:
uv run python main.py --logUsing with Claude Desktop
Add this configuration to your Claude Desktop settings:
{
"mcp-mssql-server": {
"command": "uv",
"args": ["run", "python", "/path/to/mcp-mssql-server/main.py"]
}
}Tools Overview
Tool | Purpose | Output |
sql_query | Execute SQL queries with permission controls | Query results |
get_database_info | Get server and database information | Server details |
show_tables | List all tables in the database | Table list |
describe_table | Get detailed table structure information | Column details |
show_indexes | Display table indexes | Index information |
generate_analysis_notebook | Create Jupyter notebooks for data analysis |
|
generate_visualization | Create interactive visualizations |
|
generate_powerbi_visualization | Generate Power BI compatible exports |
|
sql_query
Execute any SQL query on the database:
{
"query": "SELECT TOP 10 * FROM users WHERE status = 'active'"
}show_tables
List tables, optionally filtered by schema:
{
"schema": "dbo"
}describe_table
Get detailed table structure:
{
"table_name": "users",
"schema": "dbo"
}generate_visualization
Create interactive charts from query results:
{
"query": "SELECT category, SUM(amount) as total FROM sales GROUP BY category",
"viz_type": "bar",
"title": "Sales by Category"
}Supported visualization types: auto, bar, scatter, pie, line, heatmap, table
generate_analysis_notebook
Create Jupyter notebook with automated analysis:
{
"query": "SELECT * FROM sales_data WHERE date >= '2024-01-01'",
"output_file": "sales_analysis.ipynb"
}Security
Built-in Security Features:
Write operations disabled by default - All INSERT, UPDATE, DELETE operations are blocked
Granular permissions - Enable specific operations via environment variables
Encrypted connections - Uses TLS encryption by default
Credential protection - Database credentials stored in
.envfile (excluded from git)
To enable write operations:
# Enable specific operations as needed
ALLOW_INSERT_OPERATION=true
ALLOW_UPDATE_OPERATION=true
ALLOW_DELETE_OPERATION=trueTroubleshooting
Connection Issues
Problem: Cannot connect to SQL Server
# Check server address format
MSSQL_SERVER=tcp:your-server.database.windows.net # For Azure SQL
# Verify firewall settings allow your IP
# Ensure SQL Server authentication is enabled
# Double-check credentials in .env filePermission Errors
Problem: Access denied or operation not allowed
# Check security settings
ALLOW_WRITE_OPERATIONS=true # If you need write access
# Verify database user permissions
# Ensure user has appropriate SQL Server rolesVisualization Errors
Problem: Charts not generating correctly
Ensure query returns data suitable for the visualization type
Bar/pie charts need categorical columns
Scatter/line charts need numeric columns
Check that query returns at least one row
Common Error Messages
Error: "Login failed for user"
Check username and password in
.envVerify SQL Server authentication is enabled
Error: "Cannot open database"
Verify database name is correct
Check user has access to the specified database
Error: "Connection timeout"
Increase
QUERY_TIMEOUTin.envCheck network connectivity to SQL Server
Development
Extending the Server
File Structure:
mssql.py- Database tools implementationmain.py- MCP server interface.env- Configuration file
Adding New Tools:
Create method in
MSSQLToolsclassAdd tool definition in
list_tools()Add handler in
call_tool()
Output Files
The tools generate various output files in your working directory:
Jupyter Notebooks:
.ipynbfiles with analysis codeVisualizations:
.htmlfiles with interactive chartsPower BI Data:
.csvand.jsonfiles for import
License
MIT License - see the LICENSE file for details.
Available Tools
8 toolsdescribe_tableC
Get detailed information about a table's structure
Inputs: table_name (required), schema_name. Returns: result
generate_analysis_notebookC
Generate a Jupyter notebook with Python code to analyze SQL query results
Inputs: query (required), output_file. Returns: result
generate_powerbi_visualizationC
Generate Power BI compatible data and visualization metadata
Inputs: query (required), viz_type. Returns: result
generate_visualizationB
Generate visualizations (bar, scatter, pie, line, heatmap, table) from SQL query results
Inputs: query (required), viz_type, title. Returns: result
get_database_infoA
Get information about the database server and available databases
Inputs: no named parameters. Returns: result
show_indexesC
Show indexes for a table or all tables
Inputs: table_name, schema_name. Returns: result
show_tablesB
Show all tables in the current database
Inputs: schema_name. Returns: result
sql_queryC
Execute a SQL query on the MS SQL Server database
Inputs: query (required). Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 8 tools
Each tool has a distinct purpose: query execution, metadata retrieval (tables, indexes, database info), and three different output generation types (notebook, PowerBI, general viz). No two tools overlap in functionality.
Most tools follow a verb_noun pattern (describe_table, generate_*, show_indexes, etc.) using lowercase snake_case. Slight inconsistency with 'sql_query' being noun-focused instead of verb_noun, but overall pattern is clear and predictable.
8 tools is appropriate for a database analysis server. It covers core needs (query, metadata, visualization) without being excessive or too sparse. The count is well within the ideal 3-15 range.
The tool set covers querying, table/index metadata, and generating analysis outputs. Minor gaps like listing views or stored procedures exist, but for the stated analysis purpose it is reasonably complete.
Related MCP Connectors
MCP server for querying and analyzing data from ad platforms, analytics tools, and spreadsheets
Hosted SQL Server MCP server for Claude, ChatGPT and Cursor, with each action switched per account.
The BigQuery remote MCP server is a fully managed service that uses the Model Context Protocol to connect AI applications and LLMs to BigQuery data sources. It provides secure, standardized tools for AI agents to list datasets and tables, retrieve schemas, generate and execute SQL queries through natural language, and analyze data—enabling direct access to enterprise analytics data without requiring manual SQL coding.
The Mercado Pago MCP Server implements the Model Context Protocol to provide AI agents and LLMs with access to Mercado Pago's APIs and tools within compatible development environments. It acts as an intermediary that translates Mercado Pago resources into executable functions (tools) that AI applications can invoke to perform actions and automate flows. The server simplifies integration, enables using documentation to implement or improve code, and optimizes operations through natural language interactions without manual implementations.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceA Model Context Protocol server that enables SQL query execution, database management, and business intelligence capabilities through MySQL connections.1,462 npmMIT
- AlicenseBqualityDmaintenanceA Model Context Protocol server that enables executing SQL queries and managing connections with Microsoft SQL Server databases.12,112 npm6MIT
- FlicenseCqualityDmaintenanceA Model Context Protocol server that provides a standardized interface for interacting with SQL databases through the MCP protocol.323 npm4-
- AlicenseBqualityDmaintenanceA comprehensive Model Context Protocol server for SQL Server database operations that provides 10 powerful tools for database analysis, object discovery, and data manipulation.11542 npm15MIT