Get the FREE Ultimate OpenClaw Setup Guide →

mssql

MCP server for MS SQL 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 dperussina-mssql-mcp-server node server.js \
  --env HOST="0.0.0.0" \
  --env PORT="3333" \
  --env DEBUG="false" \
  --env DB_USER="your_username" \
  --env DB_SERVER="your_server_name_or_ip" \
  --env TRANSPORT="stdio" \
  --env SERVER_URL="http://localhost:3333" \
  --env DB_DATABASE="your_database_name" \
  --env DB_PASSWORD="your_password" \
  --env QUERY_RESULTS_PATH="/path/to/query_results"

How to use

This MS SQL MCP Server provides an AI-friendly interface to explore and query your Microsoft SQL Server databases without coding. It exposes tools to discover database structure, inspect table details, perform safe read-only queries, and generate SQL from natural language prompts. The server supports a bundled interactive client and optional HTTP/SSE transport for network access, allowing Claude or other AI assistants to navigate tables, view schemas, and run constrained queries. Typical usage involves discovering tables, selecting a target table for details, running a read-only query, and iterating with natural language prompts to generate appropriate SQL queries. The system is designed to keep credentials local and queries read-only by default for safety.

How to install

Prerequisites:

  • Node.js v14 or higher
  • Access to a Microsoft SQL Server instance (on-premises or Azure)

Installation steps:

  1. Clone the repository git clone https://github.com/dperussina/mssql-mcp-server.git
  2. Navigate to the project directory cd mssql-mcp-server
  3. Install dependencies npm install
  4. Copy the example environment file cp .env.example .env
  5. Configure your database connection in .env (example variables shown below) DB_USER=your_username DB_PASSWORD=your_password DB_SERVER=your_server_name_or_ip DB_DATABASE=your_database_name PORT=3333 HOST=0.0.0.0 TRANSPORT=stdio SERVER_URL=http://localhost:3333 DEBUG=false QUERY_RESULTS_PATH=/path/to/query_results
  6. Start the server npm start

    or with HTTP/SSE transport

    npm run start:sse
  7. (Optional) Run the interactive client npm run client

Additional notes

Notes and tips:

  • This server emphasizes security by defaulting to read-only queries. To allow data modification, you would need to adjust query handling and permissions accordingly (not recommended for production AI access).
  • Ensure your .env QUERY_RESULTS_PATH directory exists and is writable, as query results may be cached there.
  • If you run into connection issues, verify DB_SERVER, DB_USER, and DB_PASSWORD are correct, and check DEBUG logs for details.
  • The server can be exposed via HTTP/SSE transport for networked AI clients; adjust TRANSPORT and SERVER_URL accordingly.
  • The included tools include:
    • mcp_SQL_mcp_discover_database(): Discover database structure
    • mcp_SQL_mcp_table_details({ tableName }): Inspect table schema
    • mcp_SQL_mcp_execute_query({ sql, returnResults }): Run a read-only SQL query and get results
    • mcp_SQL_mcp_discover_tables({ namePattern }): Find tables by name pattern
    • mcp_SQL_mcp_get_query_results({ uuid }): Retrieve saved large results
  • For best results with AI prompting, combine discovery and table detail steps before crafting queries.

Related MCP Servers

Sponsor this space

Reach thousands of developers