mssqlcl

MCP server và CLI SQL Server và Azure SQL (.NET 10) với khả năng tự động phát hiện kết nối không cần cấu hình từ VS Code và Antigravity IDE (ms-mssql.mssql / SecretStorage), bộ bảo vệ T-SQL từ vựng chỉ đọc được bật theo mặc định và đầu ra CSV tiết kiệm token.

GitHubDùng thử MCP nàyĐược tài trợ

Tài liệu

mssqlcl logo

mssqlcl

SQL Server MCP Server & CLI with zero-config connection discovery for VS Code and Antigravity IDE.

Release .NET 10 Windows x64 MCP Protocol MIT License

Features • Prerequisites • Installation • MCP Setup • Tools (11) • CLI • Security


Configure your SQL Server connections once in VS Code, Antigravity IDE (ms-mssql.mssql), or via mssqlcl conn save, and expose them safely to any MCP-compatible AI client (Antigravity, Claude Desktop, Claude Code, Cursor, etc.) over stdio.

flowchart LR
    Client["AI Client<br/>(Antigravity / VS Code / Cursor / Claude)"] <-->|"stdio<br/>JSON-RPC 2.0"| Server["mssqlcl --mcp<br/>(Self-contained .NET 10)"]
    Server -->|"Zero-config discovery"| IDE["VS Code / Antigravity IDE<br/>(ms-mssql.mssql + SecretStorage)"]
    Server -->|"Fallback / Override"| Vault["Local DPAPI Vault<br/>(%USERPROFILE%\.mssqlcl)"]
    Server -->|"Read-only guard<br/>&amp; T-SQL"| SQL[("SQL Server /<br/>Azure SQL")]

🎥 Quick Demo — End-to-End in Antigravity

mssqlcl Antigravity Demo

✨ Features

CapabilityWhat it gives you
Zero-Config IDE DiscoveryAutomatically reads mssql.connections and mssql.connectionGroups (JSONC) from Antigravity IDE, VS Code, and %USERPROFILE%\.mssqlcl\connections.json.
Automatic Credential ResolutionSupports Windows Auth (Integrated), SQL Login (SqlLogin) via Electron SecretStorage (Local State DPAPI + state.vscdb AES-256-GCM) or local DPAPI vault, and Microsoft Entra ID / MFA (AzureMFA).
20 Multi-Connection MCP ToolsFull server discovery, connection management, schema/object inspection, Query Store diagnostics, and query execution keyed by connectionId.
Token-Efficient OutputCompact CSV output by default (optional json) with --max-rows capping (default 500) to minimize LLM token usage.
Read-Only Lexical Guard--readonly enabled by default: skips comments, string literals, and quoted identifiers while blocking DML/DDL/execution keywords (INSERT, UPDATE, DELETE, MERGE, DROP, ALTER, CREATE, TRUNCATE, EXEC, SELECT ... INTO, etc.).
Clean stdio & Local AuditDiagnostics go exclusively to stderr. Queries are logged locally to JSONL at %USERPROFILE%\.mssqlcl\audit.log without touching target databases or logging secrets.

📋 Prerequisites

  • Operating System: Windows 10 / 11 (x64) — required for Windows DPAPI and Electron SecretStorage decryption.
  • Connection Source (choose one):
    • Recommended (Zero-Config): VS Code or Antigravity IDE with the SQL Server (ms-mssql.mssql) extension and your connections already saved.
    • Standalone (No IDE required): Manage profiles directly via mssqlcl conn save (stored in %USERPROFILE%\.mssqlcl\ encrypted with Windows DPAPI) or MSSQLCL_PWD_<PROFILE> environment variables.
  • Runtime:
    • End users (Release ZIP / Installer): No .NET installation required (self-contained binary).
    • Building from source: .NET 10 SDK.

[!TIP] If you already use the ms-mssql.mssql extension in VS Code or Antigravity IDE, you don't need to re-enter passwords or maintain separate connection strings—mssqlcl discovers them automatically.


📦 Installation

Option 1: One-Command Online Installer (PowerShell, no .NET SDK required)

irm https://raw.githubusercontent.com/codevswia/mssqlcl/main/scripts/install.ps1 | iex

Downloads the latest release ZIP to %LOCALAPPDATA%\Programs\mssqlcl and adds it to your User PATH (no Administrator privileges required).

Option 2: Portable ZIP (Offline — Zero system changes or User PATH)
  1. Download mssqlcl-vX.Y.Z-win-x64.zip from GitHub Releases.
  2. Extract it anywhere (for example C:\tools\mssqlcl\).
  3. Choose how you want to run it:
    • Portable (zero system changes): Point your MCP config directly to C:\tools\mssqlcl\mssqlcl.exe (no PATH changes).
    • Install to User PATH (no Admin required): Double-click install.cmd (or run powershell -ExecutionPolicy Bypass -File .\install-local.ps1) to copy mssqlcl.exe to %LOCALAPPDATA%\Programs\mssqlcl and add it to your User PATH. Restart your IDE afterwards if it was already open.
    • Offline via main installer: .\scripts\install.ps1 -LocalZip path\to\mssqlcl-vX.Y.Z-win-x64.zip
Option 3: Build & Install from Source (requires .NET 10 SDK)
# Build & run unit tests
dotnet test

# Build and install mssqlcl.exe to %LOCALAPPDATA%\Programs\mssqlcl and add to User PATH
.\scripts\install.ps1 -FromSource

# Or build a standalone self-contained binary from source
.\scripts\install.ps1 -FromSource -SelfContained

🔌 MCP Client Configuration

Different MCP clients use slightly different JSON schemas or CLI commands. Choose the configuration for your client:

Antigravity IDE, Cursor & Claude Desktop

  • Antigravity IDE: %USERPROFILE%\.gemini\antigravity\mcp_config.json
  • Cursor: %USERPROFILE%\.cursor\mcp.json (global) or .cursor\mcp.json (project)
  • Claude Desktop: %APPDATA%\Claude\claude_desktop_config.json
{
  "mcpServers": {
    "mssqlcl": {
      "command": "mssqlcl",
      "args": ["--mcp"]
    }
  }
}

VS Code

In current VS Code (Copilot harness), the recommended configuration uses "mcpServers" with "type": "stdio":

  • Global (recommended): %USERPROFILE%\.copilot\mcp-config.json (or $COPILOT_HOME/mcp-config.json, created via MCP: Add Server → Global > Copilot Global or Chat: Open Customizations → MCP Servers)
  • Workspace (shareable): .mcp.json at the root of your repository
{
  "mcpServers": {
    "mssqlcl": {
      "type": "stdio",
      "command": "mssqlcl",
      "args": ["--mcp"]
    }
  }
}
Legacy VS Code format (.vscode/mcp.json with "servers")

Older VS Code local setups use .vscode/mcp.json with "servers" as the root key (deprecated in newer guided flows, kept for compatibility):

{
  "servers": {
    "mssqlcl": {
      "type": "stdio",
      "command": "mssqlcl",
      "args": ["--mcp"]
    }
  }
}

Claude Code

Use the CLI (recommended):

claude mcp add --transport stdio mssqlcl -- mssqlcl --mcp

Or add to .mcp.json (project) / ~/.claude.json (user):

{
  "mcpServers": {
    "mssqlcl": {
      "type": "stdio",
      "command": "mssqlcl",
      "args": ["--mcp"]
    }
  }
}
Alternative: Run directly from NuGet via .NET 10 dnx (no PATH install required)

If you have the .NET 10 SDK and prefer running mssqlcl directly from NuGet without installing the binary:

  • Antigravity IDE / Cursor / Claude Desktop:
    {
      "mcpServers": {
        "mssqlcl": {
          "command": "dnx",
          "args": ["mssqlcl", "--", "--mcp"]
        }
      }
    }
    
  • VS Code (.copilot/mcp-config.json or .mcp.json):
    {
      "mcpServers": {
        "mssqlcl": {
          "type": "stdio",
          "command": "dnx",
          "args": ["mssqlcl", "--", "--mcp"]
        }
      }
    }
    

[!NOTE] If you installed mssqlcl in portable mode without adding it to PATH, replace "mssqlcl" in "command" with the full path (e.g. "C:\\tools\\mssqlcl\\mssqlcl.exe").

Optional MCP Flags

FlagDefaultDescription
--readonlyenabledBlocks DML/DDL/EXEC statements via lexical T-SQL inspection
--readwriteoffAllows write/DDL statements in mssql_run_query
--max-rows <N>500Caps returned rows per result set
--timeout <sec>30Default SQL command timeout in seconds
--source <mode>autoauto, antigravity, vscode, or local
--no-auditoffDisables writing to %USERPROFILE%\.mssqlcl\audit.log

🎬 Video Walkthroughs

🚀 Antigravity (IDE + App) — Full Walkthroughs
▶️ Guide 1: SQL Login — Save connection, install mssqlcl MCP & query SQL Server (3m 41s)

https://github.com/user-attachments/assets/b5a99cef-7ed1-4fe2-acab-0bd34b7e16ae

▶️ Guide 2: Microsoft Entra ID / MFA — Save Azure SQL MFA connection, install MCP & query with AI (3m 38s)

https://github.com/user-attachments/assets/1ff4a37a-32d5-432e-9a07-061de0f1503d

💻 VS Code — Full Walkthroughs (Coming Soon)

Walkthroughs for VS Code (ms-mssql.mssql) coming soon.


🛠️ MCP Tools Reference

mssqlcl exposes 20 database tools to your AI assistant, supporting multiple simultaneous connections via connectionId:

CategoryToolDescription
Discoverymssql_list_serversLists discovered SQL Server profiles from Antigravity IDE, VS Code, and local vault
Connectionmssql_connectOpens a connection to a profile and returns a connectionId
Connectionmssql_disconnectCloses an active connectionId session
Connectionmssql_get_connection_detailsReturns active connection metadata (server, database, auth type, state)
Connectionmssql_change_databaseSwitches the active database context (USE <db>) for a connectionId
Schemamssql_list_databasesLists databases on the connected SQL Server instance
Schemamssql_list_schemasLists schemas in the current database
Schemamssql_list_tablesLists tables (with schema and metadata)
Schemamssql_list_viewsLists views in the current database
Schemamssql_list_functionsLists scalar/table-valued functions
Querymssql_run_queryExecutes T-SQL (protected by --readonly guard by default, CSV/JSON output)
Query Storemssql_query_store_statusChecks Query Store state, storage usage, retention, and capture mode
Query Storemssql_query_store_top_queriesTop N queries ranked by duration, CPU, logical reads, writes, memory, or executions
Query Storemssql_query_store_query_detailsSQL text, compile metadata, and aggregated runtime metrics for a queryId
Query Storemssql_query_store_historyTime-bucketed execution history for a queryId
Query Storemssql_query_store_wait_statsTop Query Store wait categories (SQL Server 2017+ / Azure SQL)
Query Storemssql_query_store_plansExecution plans, metrics, forced status, and force failures for a queryId
Query Storemssql_query_store_analyze_queryConsolidated diagnostic (details + plans + waits + multi-plan/failure flags)
Query Storemssql_query_store_verify_forced_planVerifies whether a forced plan is active and free of force failures
Query Storemssql_query_store_force_planForces or unforces a plan (--readwrite required)

💻 CLI Usage

Use the CLI directly to verify your environment, inspect discovered IDE profiles, or manage local DPAPI credentials:

# Verify environment, IDE discovery paths, and local vault health
mssqlcl doctor

# List discovered profiles and credential resolution status
mssqlcl conn list

# Test live connectivity for a profile (prefix with antigravity: or vscode: if duplicated)
mssqlcl conn test "MyServer\MyDatabase"
mssqlcl conn test "vscode:MyServer\MyDatabase"

# Create a local profile or store a DPAPI-protected password override
mssqlcl conn save --profile "LocalDev" --server "localhost\SQLEXPRESS" --database "AppDb" --user "sa" --savepwd
mssqlcl conn save --profile "ExistingIdeProfile" --savepwd

# Delete a local profile
mssqlcl conn delete "LocalDev"

🔒 Security

[!IMPORTANT] Only pass --readwrite against databases where write or DDL operations are explicitly intended.

  • Zero plaintext secret leaks: mssqlcl never writes decrypted passwords to disk, stdout, stderr, or audit.log.
  • Safe IDE vault reading: state.vscdb is copied to a temporary file in read-only mode before querying and deleted immediately afterwards, so it works safely even while VS Code or Antigravity IDE is running.
  • Zero target database footprint: Audit logs are stored strictly locally at %USERPROFILE%\.mssqlcl\audit.log.

👤 Author & Organization

📄 License

Distributed under the MIT License — see LICENSE for details.