home / mcp / mssqlmcp mcp server

MsSqlMCP MCP Server

Provides a read-only MCP server to inspect SQL Server schemas and safely run SELECT queries.

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "jdlemes-mssqlmcp": {
      "url": "http://localhost:5000/sse"
    }
  }
}

MsSqlMCP provides a read‑only MCP server for inspecting SQL Server schemas and safely executing read‑only queries. It exposes schema discovery, supports safe SQL execution, and can run over HTTP/SSE or via stdio for integration with MCP clients and editors.

How to use

You connect to the server using an MCP client that supports the MCP protocol. You can run in HTTP mode or use a local stdio transport. In HTTP mode, the server exposes an SSE endpoint for tool discovery and command invocation. In stdio mode, the server runs as a local process and communicates directly with your client. With either transport, you can request table and column information, view relationships, fetch stored procedure definitions, and execute safe read‑only SQL queries.

How to install

Prerequisites: ensure you have the .NET runtime installed and access to a SQL Server database.

# Run the server with both stdio and HTTP transports (development)
dotnet run

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

# If you need to start the server from Windows Service, use the published executable with the http-only flag

Configuration and usage notes

Configure the SQL Server connection in the application configuration. The server reads settings from a configuration file that defines the SQL Server data source and the listening URLs. For example, you can set the connection string to point to your database and choose the port for HTTP access.

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

Troubleshooting and tips

If the server won’t start, check the logs, ensure the connection string is correct, and verify that SQL Server is reachable from the host account. If port conflicts occur, adjust the Urls setting to a different port.

Available tools

GetTables

Retrieve all table names from the connected SQL Server database.

GetColumns

Retrieve the column definitions for a specified table.

GetRelationships

Retrieve foreign key relationships between tables.

GetStoreProcedure

Retrieve the definition of a stored procedure.

ExecuteSql

Execute a read-only SELECT query against the database.