Get the FREE Ultimate OpenClaw Setup Guide →

mssql

A Model Context Protocol (MCP) server for Microsoft SQL Server databases with read-only access, schema discovery, and business intelligence tools

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio harshad-webx-mssql-mcp-server npx @harshad-webx/mssql-mcp-server \
  --env DB_PORT="1433" \
  --env DB_SERVER="your-sql-server.com" \
  --env DB_ENCRYPT="true" \
  --env DB_DATABASE="YourDatabase" \
  --env DB_PASSWORD="your_secure_password" \
  --env DB_USERNAME="your_username" \
  --env DB_TRUST_SERVER_CERTIFICATE="false"

How to use

This MSSQL MCP Server provides a read-only interface to Microsoft SQL Server databases. It exposes tools for schema discovery, safe querying, and BI-oriented prompts through the MCP protocol so AI assistants can understand database structures, run constrained read-only queries, and generate insights. Use the available tools to explore table schemas, search for tables or views, execute safe SELECT queries with automatic safeguards, and analyze query performance. The server includes built-in security features such as read-only enforcement, query validation, and configurable limits to prevent expensive or unsafe operations. To integrate with an MCP client, reference the mssql server under the mcpServers configuration and invoke tools like execute_query, get_table_schema, search_tables, and analyze_query, or leverage the domain-specific BI prompts for sales, finance, operations, and customer analytics.

How to install

Prerequisites:\n- Node.js 18+ (https://nodejs.org/)\n- NPM (comes with Node.js)\n- Microsoft SQL Server with TCP/IP enabled and a user account with SELECT rights\n\nInstall from npm (recommended):\nbash\n# Global installation\nnpm install -g @harshad-webx/mssql-mcp-server\n\n# Or run without installation using npx (preferred for MCP servers)\nnpx @harshad-webx/mssql-mcp-server\n\n\nInstall from source (alternative):\nbash\n# Clone the repository\ngit clone https://github.com/harshad-webx/mssql-mcp-server.git\ncd mssql-mcp-server\n\n# Install dependencies\nnpm install\n\n# Build the project (if required by the repo)\nnpm run build\n\n\nConfiguration: Create a .env file in the project root and set the database connection details as shown in the example:\nbash\n# Copy the example environment file\ncp .env.example .env\n\n# Edit .env with your database details (values are placeholders)\nDB_SERVER=your-sql-server.com\nDB_DATABASE=YourDatabase\nDB_USERNAME=your_username\nDB_PASSWORD=your_secure_password\nDB_PORT=1433\nDB_ENCRYPT=true\nDB_TRUST_SERVER_CERTIFICATE=false\n

Additional notes

Tips and caveats:\n- Keep DB_PASSWORD secure; consider using environment vaults or secret management in production.\n- Adjust DB_PORT, ENCRYPT, and TRUST_SERVER_CERTIFICATE according to your SQL Server TLS configuration.\n- The server is read-only by design; attempt to run DML/DDL will be rejected.\n- If you encounter connection issues, verify network access from the host running the MCP server to the SQL Server and ensure SQL Server allows TCP connections on the configured port.\n- Use get_table_schema to understand table structures before forming queries, and enable maxRows limits in execute_query to prevent large payloads.\n- When integrating with clients (Claude Desktop, etc.), the environment variables in the MCP config provide credentials at runtime; avoid hard-coding credentials in client-side configurations.\n- For deployment, consider containerizing the MCP server and mapping environment variables securely.\n- The mssql-mcp-server supports additional prompts and tools; consult the README for BI prompts and performance analysis capabilities.

Related MCP Servers

Sponsor this space

Reach thousands of developers