MsSqlMCP: an MCP server for SQL Server inspection

MsSqlMCP: an MCP server for SQL Server inspection

mssqlmcp•byjdlemes

MsSqlMCP is a Model Context Protocol server that exposes SQL Server schema discovery and read-only SELECT query tools to MCP clients over stdio and HTTP/SSE.

License: MIT•Runtime: Awaiting documentation review•Category: databases storage

WHAT IT DOES

  • •Exposes MCP tools for discovering tables, columns, foreign key relationships and stored procedure definitions in a SQL Server database.
  • •Provides an ExecuteSql tool that runs only read-only SELECT queries, blocking DML, DDL, DCL and execution statements.
  • •Supports both stdio and HTTP/SSE transports and can run as a Windows Service.
  • •Lets tools target different databases on the same SQL Server instance via an optional databaseName parameter.

BEST FOR

  • •Allowing MCP clients such as VS Code Copilot or Claude Desktop to explore SQL Server schemas.
  • •Running safe, read-only SELECT queries against a SQL Server database from an AI client.
  • •Production deployments that need the server hosted as a Windows Service.

ABOUT MSSQLMCP

MsSqlMCP: an MCP server for SQL Server inspection is cataloged as an MCP server attributed to jdlemes. MsSqlMCP is a Model Context Protocol server that exposes SQL Server schema discovery and read-only SELECT query tools to MCP clients over stdio and HTTP/SSE. It is categorized under databases storage. See the capability inspector for recorded interfaces and their independent review status; consult upstream documentation for the current interface.

HOW TO INSTALL

Installation configuration is not reviewed. No executable setup is offered for this entry; inspect the source repository before proceeding.

LICENSE

Catalog license label: MIT. Check the source repository's current license and terms before using, modifying or distributing this software.

能力检查器

能力定义尚未审核。未核验的采集内容不会作为可信接口展示。

Tools (0)

暂无可展示的已审核记录。这不表示上游不支持此能力。

Resources (0)

暂无可展示的已审核记录。这不表示上游不支持此能力。

Prompts (0)

暂无可展示的已审核记录。这不表示上游不支持此能力。

NEWSLETTER - COMING LATER

Newsletter subscriptions are not open yet

Email delivery is not connected. This page does not collect email addresses or create subscriptions.

Browse the registry for current listings instead.

Community Reviews

Coming later

Reviews for MsSqlMCP: an MCP server for SQL Server inspection are not available yet

Review publishing and storage are not connected. This page does not collect or publish ratings or comments, including after sign-in.

FREQUENTLY ASKED QUESTIONS

Which MCP tools does the server expose?

It exposes GetTables, GetColumns, GetRelationships, GetStoreProcedure and ExecuteSql tools.

Can the server modify data in the database?

No; queries are validated to block data modification, and ExecuteSql allows only SELECT queries.

上游原版 README

在 GitHub 查看同一版本原文

README.md · a80450420d64 · 采集于 2026-11-13 10:28:45 UTC

保留上游原文,不做 AI 改写。为安全起见过滤脚本、表单和不安全链接。

当前显示最后一次成功采集的文档快照,请以来源页面为准。

MsSqlMCP

MCP Server for SQL Server database schema inspection and read-only query execution.

Features

  • Read-only access: All queries are validated to prevent data modification (INSERT, UPDATE, DELETE, DROP, EXEC, etc. are blocked)
  • Schema discovery: Tables, columns, relationships, and stored procedures
  • SQL execution: Safe SELECT queries only
  • Dual transport: Supports both stdio and HTTP/SSE protocols
  • Windows Service: Can run as a Windows Service for production deployments
  • MCP Protocol: Compatible with VS Code Copilot, Claude Desktop, and other MCP clients

Prerequisites

  • .NET 10 (or .NET 9 with minor adjustments)
  • SQL Server

Architecture

The project follows SOLID principles with dependency injection:

MsSqlMCP/
├── Program.cs                    # Entry point with DI and dual transport
├── SchemaTool.cs                 # MCP tool definitions
├── Interfaces/
│   ├── IConnectionFactory.cs     # SQL connection abstraction
│   ├── IQueryExecutor.cs         # Query execution abstraction
│   ├── ISchemaRepository.cs      # Schema queries abstraction
│   └── ISqlQueryValidator.cs     # Query validation abstraction
├── Services/
│   ├── SqlConnectionFactory.cs   # Connection management
│   ├── SafeQueryExecutor.cs      # Validated query execution
│   ├── SchemaRepository.cs       # Schema query implementation
│   └── ReadOnlySqlQueryValidator.cs # Security validation (27 blocked keywords)
└── Tests/
    └── ReadOnlySqlQueryValidatorTests.cs # 42 security tests

Configuration

Connection String

Edit appsettings.json:

{
  "ConnectionStrings": {
    "DefaultConnection": "Data Source=(local);Initial Catalog=YourDatabase;Encrypt=False;Trusted_Connection=True;MultipleActiveResultSets=true"
  },
  "Urls": "http://localhost:5000"
}

Running

Console Mode (Development)

# Run with both stdio and HTTP transports
dotnet run

# Run with HTTP transport only (for debugging)
dotnet run -- --http-only

Run Tests

dotnet test --filter "FullyQualifiedName~Tests"

MCP Client Configuration

Option 1: stdio Transport (VS Code)

Add to your VS Code settings.json:

{
  "mcp": {
    "servers": {
      "MsSqlMCP": {
        "type": "stdio",
        "command": "dotnet",
        "args": ["run", "--project", "c:\\path\\to\\MsSqlMCP.csproj"]
      }
    }
  }
}

Option 2: HTTP Transport (VS Code)

First, start the server:

dotnet run -- --http-only

Then add to your VS Code settings.json:

{
  "mcp": {
    "servers": {
      "MsSqlMCP": {
        "type": "http",
        "url": "http://localhost:5000/sse",
        "autoApprove": [
          "get_tables",
          "get_columns", 
          "get_relationships",
          "execute_sql",
          "get_store_procedure"
        ]
      }
    }
  }
}

Option 3: Claude Desktop

Add to claude_desktop_config.json:

{
  "mcpServers": {
    "MsSqlMCP": {
      "command": "dotnet",
      "args": ["run", "--project", "c:\\path\\to\\MsSqlMCP.csproj"]
    }
  }
}

Available Tools

ToolDescriptionRequired Parameters
GetTablesGet all table names in the databaseNone
GetColumnsGet columns (fields) for a specific tabletableName
GetRelationshipsGet foreign key relationships between tablesNone
GetStoreProcedureGet stored procedure definitionspName
ExecuteSqlExecute a read-only SELECT querysqlQuery

All tools accept an optional databaseName parameter to query different databases in the same SQL Server instance.

Security

The ExecuteSql tool only allows SELECT queries. The following statements are blocked:

  • DML: INSERT, UPDATE, DELETE, MERGE, TRUNCATE
  • DDL: CREATE, ALTER, DROP
  • DCL: GRANT, REVOKE, DENY
  • Execution: EXEC, EXECUTE, SP_EXECUTESQL, XP_
  • Others: BACKUP, RESTORE, BULK, OPENROWSET, OPENQUERY, OPENDATASOURCE

Windows Service Installation

1. Publish the Application

On your development machine:

cd c:\path\to\MsSqlMCP
dotnet publish -c Release -r win-x64 --self-contained true

This creates files in: bin\Release\net10.0\win-x64\publish\

2. Copy to Server

Copy the contents of the publish folder to the server:

Source: bin\Release\net10.0\win-x64\publish\*
Destination: C:\Services\MsSqlMCP\

3. Configure on Server

Edit C:\Services\MsSqlMCP\appsettings.json with your SQL Server connection string:

{
  "ConnectionStrings": {
    "DefaultConnection": "Data Source=YOUR_SQL_SERVER;Initial Catalog=YOUR_DATABASE;Encrypt=False;Trusted_Connection=True;MultipleActiveResultSets=true"
  },
  "Urls": "http://localhost:5000"
}

4. Install the Service

Open PowerShell as Administrator and run:

# Create the Windows Service
sc.exe create MsSqlMCP binPath= "C:\Services\MsSqlMCP\MsSqlMCP.exe --http-only" start= auto DisplayName= "MsSql MCP Server"

# Add description
sc.exe description MsSqlMCP "Model Context Protocol server for SQL Server database inspection"

# Create logs directory
mkdir C:\Services\MsSqlMCP\logs -Force

# Start the service
net start MsSqlMCP

# Verify status
sc.exe query MsSqlMCP

5. Verify Installation

# Check service status
Get-Service -Name MsSqlMCP

# Test the endpoint
Invoke-RestMethod -Uri "http://localhost:5000/sse/tools"

Service Management Commands

# Stop service
net stop MsSqlMCP

# Start service
net start MsSqlMCP

# Restart service
net stop MsSqlMCP; net start MsSqlMCP

# Uninstall service
net stop MsSqlMCP
sc.exe delete MsSqlMCP

Firewall Configuration (if accessing remotely)

# Allow inbound traffic on port 5000
New-NetFirewallRule -DisplayName "MsSqlMCP" -Direction Inbound -Port 5000 -Protocol TCP -Action Allow

HTTP API Endpoints

When running in HTTP mode, the following endpoints are available:

EndpointMethodDescription
/sseGETSSE stream for MCP protocol
/sse/toolsGETList all available tools
/sse/invokePOSTInvoke a tool

Example: Invoke Tool via HTTP

curl -X POST http://localhost:5000/sse/invoke \
  -H "Content-Type: application/json" \
  -d '{"Tool": "GetTables", "Params": {}}'
Invoke-RestMethod -Uri "http://localhost:5000/sse/invoke" -Method POST -ContentType "application/json" -Body '{"Tool": "GetTables", "Params": {}}'

Troubleshooting

Service won't start

  1. Check logs in C:\Services\MsSqlMCP\logs\
  2. Verify connection string in appsettings.json
  3. Ensure SQL Server is accessible from the service account
  4. Run manually to see errors: C:\Services\MsSqlMCP\MsSqlMCP.exe --http-only

Connection issues

  1. Verify SQL Server is running
  2. Check firewall rules for SQL Server port (1433)
  3. If using Windows Authentication, ensure the service account has database access

Port already in use

Change the port in appsettings.json:

{
  "Urls": "http://localhost:5001"
}

License

MIT

Install configuration

Are you the maintainer?

Claim this server with your GitHub account to request manual ownership verification.

README Embed Badge
Markdown

Link to the catalog listing for MsSqlMCP: an MCP server for SQL Server inspection from your README. This badge does not certify ownership, compatibility or security.

[![MCP catalog listing](https://img.shields.io/badge/MCP-awesome--mcp-orange?style=flat-square)](https://awesome-mcp.com/servers/mssqlmcp)

REPOSITORY STATS

GitHub StarsUnavailable
ForksUnavailable

Public repository statistics could not be verified. Check the configured source address; unavailable counts are not zero.

下载与拉取统计

来源、范围和时段分别列出;不相加,不代表安装人数、活跃用户或安全审核。

尚无已审核的包 / 镜像标识,暂不展示下载统计。

Related databases storage MCP Servers

Alternative and complementary servers in the same category

View all in databases storage →
AIStor MCP server
mcp-server-aistor•minio

This is a Model Context Protocol (MCP) server for interacting with AIStor object stores.

Repository stats unavailable
Databases & Storage
InfluxDB v2 MCP Server
influxdb-mcp-server•idoru

A Model Context Protocol (MCP) server that exposes access to an InfluxDB v2 instance using the InfluxDB OSS API v2.

Repository stats unavailable
Databases & Storage