Skip to content

eamonboyle/mssql-mcp

MSSQL MCP Server

License: MIT npm version Node.js 18+

Add to Cursor Install in VS Code

⚠️ EXPERIMENTAL USE ONLY β€” This MCP Server is provided for educational and experimental purposes. It is NOT intended for production use. Use appropriate security measures and test thoroughly before any deployment.

What is this? πŸ€”

An MCP (Model Context Protocol) server that lets AI assistants like Claude, Cursor, and other LLM-powered tools query and manage your Microsoft SQL Server database using natural language.

Quick Example

You: "Show me all customers from New York"
AI: *queries your MSSQL database and returns the results in plain English*

Features πŸ“Š

  • Natural language to SQL β€” Ask questions in plain English
  • CRUD operations β€” Create, read, update, and delete data
  • Schema management β€” Create tables, indexes; describe and drop tables
  • Multi-database support β€” Connect to multiple databases on the same server
  • Read-only mode β€” Restrict to SELECT-only for safer environments
  • Secure by default β€” WHERE clauses required for reads/updates; SQL injection safeguards

Supported AI Clients

Quick Start πŸš€

One-Click Install (Cursor / VS Code)

Click Add to Cursor or Install in VS Code above to add the MCP server. Edit the config to add your database credentials (DB_USER, DB_PASSWORD, etc.). No cloning requiredβ€”runs via npx.

Prerequisites

  • Node.js 18 or higher
  • SQL Server (local, Azure SQL, or remote)
  • An MCP-compatible AI client (Claude Desktop, Cursor, etc.)

Installation

From npm (recommended):

npx -y @eamonboyle/mssql-mcp

Or install globally: npm install -g @eamonboyle/mssql-mcp

From source (for development):

git clone https://github.com/eamonboyle/mssql-mcp.git
cd mssql-mcp
npm install
npm run build

Configuration

Environment Variables

Variable Required Description
SERVER_NAME Yes SQL Server host (e.g., localhost, my-server.database.windows.net)
DATABASE_NAME Yes Default database name
DB_USER Yes* SQL Server username (for SQL authentication)
DB_PASSWORD Yes* SQL Server password (for SQL authentication)
READONLY No "true" for read-only mode, "false" for full access (default: "false")
DATABASES No Comma-separated list for multi-database access (e.g., ProdDB,StagingDB)
CONNECTION_TIMEOUT No Timeout in seconds (default: 30)
TRUST_SERVER_CERTIFICATE No "true" for self-signed certs (e.g., local dev) (default: "false")

* Required for SQL authentication. For Windows/Integrated authentication, consult the mssql package documentation.

Option 1: Cursor / VS Code Setup

  1. Create or edit .vscode/mcp.json in your workspace:
{
  "mcpServers": {
    "mssql": {
      "command": "npx",
      "args": ["-y", "@eamonboyle/mssql-mcp"],
      "env": {
        "SERVER_NAME": "localhost",
        "DATABASE_NAME": "YourDatabase",
        "DB_USER": "your_username",
        "DB_PASSWORD": "your_password",
        "READONLY": "false"
      }
    }
  }
}
  1. Restart Cursor/VS Code.

Option 2: Claude Desktop Setup

  1. Open File β†’ Settings β†’ Developer β†’ Edit Config
  2. Add the MCP server configuration:
{
  "mcpServers": {
    "mssql": {
      "command": "npx",
      "args": ["-y", "@eamonboyle/mssql-mcp"],
      "env": {
        "SERVER_NAME": "localhost",
        "DATABASE_NAME": "YourDatabase",
        "DB_USER": "your_username",
        "DB_PASSWORD": "your_password",
        "READONLY": "false"
      }
    }
  }
}
  1. Restart Claude Desktop.

Multi-Database Support

To allow queries across multiple databases:

"env": {
  "SERVER_NAME": "your-server.database.windows.net",
  "DATABASE_NAME": "ProdDB",
  "DATABASES": "ProdDB,StagingDB,AnalyticsDB",
  "DB_USER": "your_username",
  "DB_PASSWORD": "your_password",
  "READONLY": "false"
}

All tools accept an optional databaseName parameter. When omitted, DATABASE_NAME is used.

Sample Configurations

See src/samples/ for example configs:

  • claude_desktop_config.json β€” Claude Desktop
  • vscode_agent_config.json β€” VS Code Agent

Usage Examples

Once configured, you can ask things like:

  • "Show me all users from New York"
  • "Create a new table called products with columns for id, name, and price"
  • "Update all pending orders to completed status"
  • "List all tables in the database"
  • "Describe the schema of the customers table"

Available Tools

Tool Read-only Description
read_data βœ“ Execute SELECT queries
list_table βœ“ List tables in a database
describe_table βœ“ Get table schema
insert_data Insert rows
update_data Update rows (requires WHERE)
create_table Create tables
create_index Create indexes
drop_table Drop tables

Security Notes

  • Credentials β€” Never commit DB_USER/DB_PASSWORD or config files with secrets. Use environment variables or a secrets manager.
  • Read-only mode β€” Set READONLY: "true" when you only need queries.
  • WHERE clauses β€” Read and update operations require explicit WHERE clauses to reduce accidental full-table operations.
  • SQL injection β€” The server validates and restricts dangerous SQL patterns.

Contributing

Contributions are welcome! Please read CONTRIBUTING.md for guidelines. By participating, you agree to uphold our Code of Conduct.

License

MIT License β€” see LICENSE for details.

About

No description, website, or topics provided.

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors