Get the FREE Ultimate OpenClaw Setup Guide →

mssql

MCP server from c0h1b4/mssql-mcp-server

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio c0h1b4-mssql-mcp-server mssql-mcp-server \
  --env MSSQL_HOST="localhost" \
  --env MSSQL_PORT="1433" \
  --env MSSQL_USER="sa" \
  --env MSSQL_ENCRYPT="false" \
  --env MSSQL_DATABASE="master" \
  --env MSSQL_PASSWORD="yourpassword" \
  --env MSSQL_CONNECTION_STRING="Server=localhost;Database=master;User Id=sa;Password=yourpassword;" \
  --env MSSQL_TRUST_SERVER_CERTIFICATE="true"

How to use

This MSSQL MCP Server provides a toolset for connecting to Microsoft SQL Server databases and executing SQL queries through the MCP (Model Context Protocol) framework. The core tool exposed is query, which lets you run SQL statements against a MSSQL instance using either a full connection string or individual connection parameters. The server handles connection pooling, basic parameter validation, and safeguards against potentially dangerous operations. You can configure the server in your MCP settings file to point to either a local or remote MSSQL instance and then invoke the query tool from your MCP client or evals workflow. The server is designed to integrate with Claude Desktop via Smithery for easy installation and with MCP evals for automated testing and benchmarking.

Once running, you can use the query tool to submit SQL queries by providing either a connectionString or the host, username, and password along with the query. The tool supports optional encryption and trust settings, and defaults to a standard port of 1433 with the database set to master if not specified. You can also supply a full connection string for simplicity. Use the MCP client to call use_mcp_tool with server_name set to mssql, tool_name to query, and an arguments object containing the connection details and the query to execute.

How to install

Prerequisites:

  • Node.js and npm installed on your system
  • Access to a MSSQL Server (local or remote)
  • Optional: Docker for running local MSSQL and MCP server via docker-compose

Install manually via npm:

npm install mssql-mcp-server

Verify installation and run in development:

# Install dependencies (if you cloned a repo using this server)
npm install

# Start in development mode (if supported by the repo's scripts)
npm run dev

# Build the project (if applicable)
npm run build

# Run the built server (if applicable)
npm start

If you prefer Smithery automation for Claude Desktop:

npx -y @smithery/cli install @c0h1b4/mssql-mcp-server --client claude

Docker usage (optional):

# Build the Docker image
docker build -t mssql-mcp-server .

# Run with docker-compose (if a compose file exists in this project)
docker-compose up

Configuration in MCP settings:

  • Add an entry under mcpServers with the key mssql and set command to mssql-mcp-server. Include MSSQL_CONNECTION_STRING or individual MSSQL_HOST, MSSQL_PORT, MSSQL_DATABASE, MSSQL_USER, MSSQL_PASSWORD, MSSQL_ENCRYPT, and MSSQL_TRUST_SERVER_CERTIFICATE as needed.

Additional notes

Tips and notes:

  • Prefer using MSSQL_CONNECTION_STRING for simplicity, but you can also configure individual values (host, port, database, user, password).
  • The server implements safeguards against dangerous SQL operations and limits query length and timeouts to improve security.
  • If you encounter connection issues, verify network access to the MSSQL server and ensure the credentials are valid. Remember to set MSSQL_TRUST_SERVER_CERTIFICATE to true if using self-signed certificates in non-production environments.
  • When using evals, you can preload environment variables by prefixing the command, e.g., OPENAI_API_KEY=your-key npx mcp-eval src/evals/evals.ts examples/simple-server.ts.
  • For production deployments, consider securing environment variables and using encrypted secrets management.
  • The Tools section documents the query tool's parameters; ensure you provide either a complete connectionString or the host/username/password trio along with the query.

Related MCP Servers

Sponsor this space

Reach thousands of developers