Enterprise-grade Model Context Protocol server for Microsoft SQL Server.
A production-ready MCP server built for real-world database work: exploring unfamiliar schemas, profiling data shape, validating pipelines in UAT, and moving confidently to production. If you work with SQL Server and want AI tooling that understands enterprise database workflows, this is for you.
Enterprise MCP server for SQL Server with 20 tools for schema discovery, data operations, and administration.
Choose the tier that matches your security requirements. All tiers share the same governance controls, audit logging, and multi-environment support.
Why This Exists
Most SQL + AI demos stop at "generate a query." That's table stakes. Real database work means:
Navigating massive schemas you didn't design, often with cryptic naming conventions
Understanding data shape before writing anything
Working safely in regulated environments where one bad UPDATE can trigger an incident
Moving fast in UAT so you can validate changes before they hit production
This server is built around those realities. It's stable, secure by default, and designed to make AI assistants genuinely useful on enterprise SQL Server instances.
What's here today
Semantic schema discovery – search_schema finds tables/columns via wildcards with fuzzy matching and paginated results so large databases don’t blow up your context window.
Table profiling – profile_table summarizes column shape (null %, cardinality, min/max/avg/median/p90) and can return a capped sample of rows.
Relationship mapping – inspect_relationships enumerates inbound/outbound FKs with column mappings, so you can follow dependencies before touching data.
Flexible authentication – SQL auth, Windows auth, and Azure AD are supported; pick what matches your infra.
Safe data operations – read_data, describe_table, list_table, plus write tools (insert_data, update_data, delete_data, create_table, create_index, drop_table) when you need full agent-mode workflows.
Preview + Confirm for mutations – update_data and delete_data show affected rows before execution; require explicit confirmation to proceed.
Multi-environment support – Define named database environments (prod, staging, dev) in a JSON config; switch between them per request.
Audit logging – Every tool invocation logged to JSON Lines format with timestamps, arguments (auto-redacted), and results.
MCP-native – Works with Windsurf, Claude Desktop, and any MCP-compatible client.
Key tools at a glance
Discovery & Schema:
search_schema – Wildcard/fuzzy search across tables and columns with pagination.
create_table – Create tables with column definitions.
create_index – Create indexes on existing tables.
drop_table – Drop tables (requires confirmation).
Named Scripts:
list_scripts – Show available pre-approved SQL scripts.
run_script – Execute named scripts with parameters and governance controls.
Scripts directory – Point the server at a folder containing scripts.json + .sql files by setting SCRIPTS_PATH (env var) or "scriptsPath" inside your environment entry. list_scripts/run_script remain disabled until this location is configured.
Operations:
test_connection – Verify connectivity and latency.
validate_environment_config – Check environment configuration for errors.
Prerequisites
You’ll need a current Node.js runtime (minimum 18, recommended 20 LTS). The tooling now shims legacy APIs so it also works on the newest Node releases, but installing an LTS build avoids surprises on fresh machines.
Platform
Command (installs Node 20 LTS)
Windows
winget install --id OpenJS.NodeJS.LTS -e
macOS
brew install node@20 && brew link --overwrite --force node@20
Verify with node -v (should show v20.x). If you already have a newer Node version installed, the server will still run thanks to the built-in SlowBuffer shim.
git clone https://github.com/ConnorBritain/mssql-mcp-server.git
cd mssql-mcp-server/src/node
npm install
npm run build
Then point your MCP client to src/node/dist/index.js with your connection env vars.
Configuration
Environment variables
Variable
Required
Description
SERVER_NAME
SQL Server hostname or IP (e.g., localhost, 127.0.0.1, myserver.database.windows.net)
DATABASE_NAME
Target database name
SQL_AUTH_MODE
Authentication mode: sql, windows, or aad (default: aad)
SQL_USERNAME
Username for SQL or Windows auth
SQL_PASSWORD
Password for SQL or Windows auth
SQL_DOMAIN
Domain for Windows/NTLM auth (optional)
SQL_PORT
Custom port (default: 1433). Useful for named instances or Docker containers on non-standard ports.
TRUST_SERVER_CERTIFICATE
Set to true for self-signed certificates or dev environments
CONNECTION_TIMEOUT
Connection timeout in seconds (default: 30)
READONLY
Set to true to restrict to read-only tools (no INSERT, UPDATE, DELETE, DROP)
MAX_ROWS_DEFAULT
Auto-limit for SELECT queries without TOP/LIMIT (default: 1000, range: 1-100000)
REQUIRE_MUTATION_CONFIRMATION
Set to false to skip preview/confirm for mutations (default: true)
ENVIRONMENTS_CONFIG_PATH
Path to JSON file defining multiple named database environments
SCRIPTS_PATH
Path to named SQL scripts directory (must contain scripts.json)
AUDIT_LOG_PATH
Path for audit log file (default: logs/audit.jsonl)
AUDIT_LOGGING
Set to false to disable audit logging (default: true)
AUDIT_REDACT_SENSITIVE
Set to false to disable redaction of sensitive args (default: true)
PROFILE_SAMPLE_SIZE_DEFAULT
Default sample size for profile_table (defaults to 50, max 1000)
PROFILE_SAMPLE_RETURN_LIMIT
Max number of sample rows returned in responses (defaults to 10, max 100)
SEARCH_SCHEMA_DEFAULT_LIMIT
Default row limit per section for search_schema pagination (defaults to 50, max 200)
Authentication modes
SQL Server Authentication (SQL_AUTH_MODE=sql)
Standard username/password auth against SQL Server. Works with local instances, Docker containers, and Azure SQL with SQL auth enabled.
Windows Authentication (SQL_AUTH_MODE=windows)
NTLM-based auth using domain credentials. Ideal for on-prem SQL Server in Active Directory environments.
The server auto-parses DOMAIN\username format — you can provide the domain either as a separate SQL_DOMAIN field or embedded in SQL_USERNAME (e.g., CORP\svc_account). If both are present, the explicit SQL_DOMAIN takes precedence and the prefix is stripped from the username.
Azure AD Authentication (SQL_AUTH_MODE=aad or omit)
Interactive browser-based Azure AD authentication. Opens a browser window on first connection to authenticate. Best for Azure SQL Database with AAD-only auth.
Never hardcode credentials in config files that might be committed to version control. The server supports several approaches for secure credential management:
Secret placeholders (recommended)
Use ${secret:NAME} syntax in your environments.json to reference secrets:
Providers are tried in order — the first one to return a value wins.
Provider
Config
Description
env
(none)
Reads from process.env. Always available.
dotenv
path (absolute)
Parses a .env file (key=value lines). The server reads the file directly, bypassing shell env inheritance.
file
directory (absolute)
Reads a file named NAME from the directory. Useful for Docker secrets or mounted volumes.
If no secrets block is present, the server defaults to [{ "type": "env" }] (the original behavior).
Cross-platform .env setup (recommended for MCP clients):
MCP clients spawn the server as a child process, so shell profile variables (~/.bashrc, etc.) and Windows Credential Manager entries are often not available. The dotenv provider solves this:
Keep the .env file out of version control — add it to .gitignore.
Convenience fallback: If you don't want to add a secrets block, set the DOTENV_PATH environment variable to the absolute path of your .env file. The server will automatically create a dotenv provider from it.
Validating your setup
Use the validate_environment_config tool to verify your secrets configuration. It checks:
Provider configs are valid (correct types, paths exist and are readable)
All ${secret:NAME} references in your environments are resolvable
Platform-specific secret stores
For enhanced security, load credentials from your platform's native secret store before launching the MCP server. Example scripts are provided in the examples/ folder:
Platform
Script
Secret Store
Windows
load-from-credential-manager.ps1
Windows Credential Manager
Windows
load-from-keyvault.ps1
Azure Key Vault
macOS
load-env.sh
macOS Keychain (via security CLI)
Linux
load-env.sh
Environment variables / .env file
Windows Credential Manager example:
# Store credential (one-time setup)
cmdkey /generic:MSSQL_PROD /user:myuser /pass:mypassword
# Retrieve and set as env var before launching
$cred = cmdkey /list:MSSQL_PROD | Select-String "User:"
# ... (see examples/load-from-credential-manager.ps1 for full script)
Azure Key Vault example:
# Retrieve secret from Key Vault
$secret = az keyvault secret show --vault-name "my-vault" --name "sql-password" --query "value" -o tsv
$env:PROD_SQL_PASSWORD = $secret
Security tiers
Use Case
Recommended Approach
Local development
.env file (gitignored) with dotenv provider
Team/corporate
Windows Credential Manager, macOS Keychain, or 1Password/Bitwarden CLI
Tools accept an optional environment parameter to target a specific environment. The IntentRouter can also infer environments from natural language (e.g., "show tables in prod" → uses prod environment).
Domain for Windows auth (also auto-extracted from DOMAIN\user format)
trustServerCertificate
boolean
Trust self-signed certs
connectionTimeout
number
Connection timeout in seconds (default: 30)
requestTimeout
number
Per-query timeout in seconds (default: 120). Increase for slow remote servers.
readonly
boolean
Disable all write operations
tier
string
reader, writer, or admin
accessLevel
string
database (default) or server for multi-DB access
allowedDatabases / deniedDatabases
string[]
Filter databases for server-level access
allowedTools / deniedTools
string[]
Whitelist/blacklist specific tools
allowedSchemas / deniedSchemas
string[]
Schema/table patterns (supports wildcards like dbo.*)
allowedColumns / deniedColumns
object
Table-pattern keys mapped to column arrays; denied columns take precedence
maxRowsDefault
number
Cap query results (overrides user requests)
requireApproval
boolean
Force confirmation for all non-metadata operations
auditLevel
string
none, basic, or verbose
description
string
Human-readable description
Named SQL scripts
For repeatable operations, you can define pre-approved SQL scripts that agents can execute with parameters. This is safer than ad-hoc SQL since scripts are reviewed in advance.
Setup:
Create a scripts directory with a scripts.json manifest:
Or via environment variable: SCRIPTS_PATH=/path/to/scripts
Script governance fields:
Field
Description
tier
Minimum tier required (reader, writer, admin)
readonly
Mark as safe for readonly environments
requiresApproval
Require confirm: true to execute
allowedEnvironments
Restrict to specific environments
deniedEnvironments
Block from specific environments
Usage:
> Use list_scripts to see available scripts
> Run the find_user_by_email script with email "[email protected]"
> Preview the deactivate_user script with userId 123
⚠️ Safety & Prudence
With great power comes great responsibility.
This MCP server exposes powerful CRUD operations including drop_table, create_table, update_data, and insert_data. If you enable full autopilot mode in your AI assistant—or simply aren't inspecting each tool call—you could trigger destructive actions you don't intend.
Recommended Safeguards
Use READONLY=true by default. This globally disables all write operations, exposing only safe discovery tools. Enable write mode only when you explicitly need it.
Preview before mutations.update_data and delete_data show affected rows and require explicit confirmation (confirmUpdate: true / confirmDelete: true) before executing. Row counts are capped at 1000 by default.
Be a prudent human in the loop. Review tool calls before approval, especially for destructive operations. Don't blindly trust AI-generated queries against production data.
Use dedicated credentials. Connect with a database user that has only the permissions you intend to grant. Avoid sa or admin accounts in production.
Test in non-production first. Validate tool behavior against development or staging databases before pointing at production.
Monitor and audit. Audit logging is enabled by default—check logs/audit.jsonl for a record of all tool invocations. Sensitive parameters are auto-redacted.
The discovery tools (search_schema, profile_table, inspect_relationships) are designed to help you understand unfamiliar databases safely. Use them to build context before issuing any mutations.
Tool tuning
Schema discovery pagination – Use SEARCH_SCHEMA_DEFAULT_LIMIT to tune how many rows search_schema returns per page (default 50, max 200). Combine with tableOffset/columnOffset params for manual paging.
Profiling samples – Use PROFILE_SAMPLE_SIZE_DEFAULT to control how many rows are sampled internally (default 50). Control how many rows are actually returned with PROFILE_SAMPLE_RETURN_LIMIT (default 10). Both respect per-request overrides via sampleSize and includeSamples args.
Deployment
See DEPLOYMENT.md for enterprise deployment patterns including:
See ROADMAP.md for the full enterprise roadmap with status tracking.
Recently shipped (v0.3.x):
✅ Pluggable secret providers — dotenv and file providers join env; configure via secrets.providers in environments.json
✅ Per-environment connection pools — each environment gets its own isolated ConnectionPool (fixes cross-environment data leaks from the old global singleton)
✅ NTLM domain/username parsing — DOMAIN\user format auto-splits for tedious driver compatibility
✅ Configurable requestTimeout per environment (default 120s, up from the mssql package's 15s default)
✅ Version tracking — test_connection returns mcpServerVersion for debugging
✅ validate_environment_config now validates secrets providers and checks resolvability of all ${secret:NAME} references
Previously shipped:
✅ Multi-environment connection profiles with governance controls
Contributions welcome! See CONTRIBUTING.md for guidelines. If you're working with SQL Server in environments where stability and security matter, I'd love to hear what tools would help you most.
If this project is useful to you, consider giving it a ⭐ on GitHub and sharing it with others who work with SQL Server. The more eyes on it, the better it gets.
This project was originally forked from Microsoft's SQL-AI-samples and has since evolved into a standalone, production-focused MCP server. Thanks to the Microsoft Azure SQL team for the initial foundation, and to the MCP community for the protocol specs that make cross-agent tooling possible.
Versioning
This package follows semver. Note: version 1.0.1 is permanently reserved on npm due to a prior publish and cannot be used for future releases.
Ainda não há lista de ferramentas. Servidores remotos recebem uma após a primeira verificação de saúde.
Perguntas frequentes
Perguntas
Como instalo Mssql?
Copie nesta página a configuração stdio para Cursor, Claude Desktop, Claude Code ou VS Code. Ela usa a instalação do publicador, não um proxy do PlugMCP.
Mssql precisa de uma chave de API?
Este registro não lista nenhuma variável de ambiente obrigatória.
Qual transporte Mssql usa?
Mssql roda localmente via stdio.
Quando Mssql foi verificado pela última vez?
Última verificação: 2026-10-28. Enterprise MCP server for SQL Server with 20 tools for schema discovery, data operations, and administration.