SQL Server
About
Integrates with SQL Server to enable database schema exploration, query execution, and stored procedure management via JSON-RPC communication for relational data analysis and natural language querying.
Details
- Author
- ian-cowley
- Repository
- ian-cowley/MCPSqlServer
- GitHub stars
- 14
- Downloads
- 452
- License
- MIT License
- Categories
- AI, Design, Developer Tools, Search, Infrastructure, Database
- Tags
- #integration
Jump to
- SQL Server connectivity
- Database schema exploration
- Table and view inspection
- Column metadata retrieval
- Stored procedure enumeration
- SQL query execution
- Stored procedure execution
- Debug mode for troubleshooting
- Configurable logging path
- Dynamic Project Connection Resolver: Automatically resolves and overrides database connection strings dynamically based on the active file in the editor
Setting up with Highlight
This MCP is not yet compatible with Highlight’s one-click setup. However, you can still use it with Highlight by following these steps:
- Download and install Highlight from highlightai.com/download
- Navigate to the plugins tab and select "Add Custom Plugin"
-
Configure the plugin with the settings below
Plugin Name
SQL ServerCommand (node, npx, python, etc.)path/to/your/MCPSqlServer.exePlease refer to the README for specific instructions on how to obtain API keys or other required environment variables.
- Enable "Start Automatically" if you want the plugin to start when Highlight launches
From the repository
1. Build the project:
dotnet build
2. Configure the application:
- Copy appsettings.example.json to appsettings.json
- Update the connection string and other settings in appsettings.json with your SQL Server details
{
"ConnectionStrings": {
"DefaultConnection": "Server=your-server;Database=master;User ID=your-username;Password=your-password;TrustServerCertificate=True"
},
"LogPath": "C:\\Path\\To\\Your\\LogDirectory\\",
"DebugMode": "false"
}
3. Configure the MCP server in your IDE / client:
- Add the server configuration to your IDE's MCP config file (e.g., Windsurf, Claude Desktop config, or Cline/Cursor settings).
- Point the command to the path of your built executable:
{
"mcpServers": {
"sqlMcpService": {
"command": "path/to/your/MCPSqlServer.exe",
"args": [],
"description": "SQL Server MCP Service"
}
}
}
4. Set up GitHub integration:
- Create a new GitHub repository for your project
- Initialize a new Git repository in your project directory using git init
- Add your GitHub repository as a remote using git remote add origin <repository-url>
- Push your changes to the remote repository using git push -u origin master
The appsettings.json file contains the following configuration options:
- ConnectionStrings:DefaultConnection: The SQL Server connection string
- LogPath: Directory where log files will be stored
- DebugMode: Set to "true" to enable detailed debug logging
- AllowWorkspaceOverride: Set to "false" to disable dynamic project connection overrides (defaults to "true")
get_databases
List all available non-system SQL Server databases.
get_tables
List all tables and views in a specified database. Parameters: database (string), schema (string)
get_columns
List all columns and column metadata in a specified table. Parameters: database (string), schema (string), table (string)
get_procedures
List all stored procedures in a specified database. Parameters: database (string), schema (string)
get_procedure_definition
Get the definition of a stored procedure. Parameters: database (string), schema (string), name (string)
execute_database_query
Execute a SQL query in the context of a specific database. Parameters: database (string), query (string)
execute_system_query
Execute a SQL query at the server instance level (no database context required). Parameters: query (string)
execute_procedure
Execute a stored procedure. Parameters: database (string), schema (string), procedure (string), parameters (object)
Claude Desktop / Cursor
Paste into your MCP client config file to install this server.
{
"mcpServers": {
"sql server": {
"env": {},
"args": [],
"shell": false,
"command": "path/to/your/MCPSqlServer.exe"
}
}
}
Linux
{
"env": [],
"args": [],
"shell": false,
"command": "path/to/your/MCPSqlServer.exe"
}
Macos
{
"env": [],
"args": [],
"shell": false,
"command": "path/to/your/MCPSqlServer.exe"
}
Windows
{
"env": [],
"args": [],
"shell": false,
"command": "path/to/your/MCPSqlServer.exe"
}
SQL Server MCP Server
A standalone MCP (Model Context Protocol) server written in C# that provides SQL Server integration capabilities for any MCP-compliant IDE or client.
Features
- SQL Server connectivity
- Database schema exploration
- Table and view inspection
- Column metadata retrieval
- Stored procedure enumeration
- SQL query execution
- Stored procedure execution
- Debug mode for troubleshooting
- Configurable logging path
- Dynamic Project Connection Resolver: Automatically resolves and overrides database connection strings dynamically based on the active file in the editor
Prerequisites
- .NET 10.0 SDK or higher
- SQL Server instance (local or remote)
- SQL Server client tools
Setup
1. Build the project:
dotnet build
2. Configure the application:
- Copy appsettings.example.json to appsettings.json
- Update the connection string and other settings in appsettings.json with your SQL Server details
{
"ConnectionStrings": {
"DefaultConnection": "Server=your-server;Database=master;User ID=your-username;Password=your-password;TrustServerCertificate=True"
},
"LogPath": "C:\\Path\\To\\Your\\LogDirectory\\",
"DebugMode": "false"
}
3. Configure the MCP server in your IDE / client:
- Add the server configuration to your IDE's MCP config file (e.g., Windsurf, Claude Desktop config, or Cline/Cursor settings).
- Point the command to the path of your built executable:
{
"mcpServers": {
"sqlMcpService": {
"command": "path/to/your/MCPSqlServer.exe",
"args": [],
"description": "SQL Server MCP Service"
}
}
}
4. Set up GitHub integration:
- Create a new GitHub repository for your project
- Initialize a new Git repository in your project directory using git init
- Add your GitHub repository as a remote using git remote add origin <repository-url>
- Push your changes to the remote repository using git push -u origin master
Configuration Options
The appsettings.json file contains the following configuration options:
- ConnectionStrings:DefaultConnection: The SQL Server connection string
- LogPath: Directory where log files will be stored
- DebugMode: Set to "true" to enable detailed debug logging
- AllowWorkspaceOverride: Set to "false" to disable dynamic project connection overrides (defaults to "true")
Dynamic Project Connection Resolver
In multi-project workspaces where different folders or subprojects connect to different databases, you can avoid updating the main configuration constantly:
1. All database tools accept an optional currentFilePath parameter (typically automatically populated by the IDE client with the active file's path).
2. The server walks up the directory tree from the file's parent folder looking for the nearest appsettings.json.
3. If found, it dynamically extracts and uses that file's ConnectionStrings:DefaultConnection for the query execution.
4. If no config file is found, or if AllowWorkspaceOverride is set to "false", it falls back to the primary connection string loaded at startup.
Publishing
You can publish the application as a self-contained executable:
dotnet publish -c Release -r win-x64 --self-contained true -p:PublishSingleFile=true
This will create a single executable file that includes all dependencies.
Protocol
The MCP server communicates through standard input/output using the standard JSON-RPC 2.0 Model Context Protocol.
Request Format (tools/call)
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "tool-name",
"arguments": {
"param1": "value1",
"param2": "value2"
}
}
}
Response Format
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"content": [
{
"type": "text",
"text": "JSON-serialized tool output"
}
]
}
}
Or in case of error:
{
"jsonrpc": "2.0",
"id": 1,
"error": {
"code": -32602,
"message": "Error description"
}
}
Supported Tools
1. List Databases (get_databases)
List all available non-system SQL Server databases.
Sign in to leave a review
Use Google, GitHub, or an email account so ratings stay tied to real people.
No reviews posted yet.




