MS SQL Server MCP Server logo

MS SQL Server MCP Server

Community
bymcs

MCP server for Microsoft SQL Server — query, schema, and stored-procedure access for Claude Desktop, Cursor, Windsurf, and VS Code.

Publisherbymcs
Repositorymssql-mcp
LanguageTypeScript
Forks
2
Stars
13
Available tools
14
Transport typestdio, streamable-http
Categories
LicenseMIT
Links
  • Connect tools to AI workflows

    MS SQL Server MCP Server exposes MCP capabilities that can be used by compatible AI clients and agents.

  • 14 available tools

    Browse the callable actions below, including names and descriptions when provided by the server.

  • Ready-to-copy setup

    Use the installation snippets to configure this server in your preferred MCP client.

  • Open source signals

    13 stars and 2 forks from the linked repository.

MS SQL Server MCP Server v3.0.0

🚀 Model Context Protocol (MCP) server for Microsoft SQL Server - compatible with Claude Desktop, Cursor, Windsurf and VS Code.

CI npm version License: MIT

Standards Alignment

🚀 Quick Start

1. Install

bash
npm install -g mssql-mcp

2. Configure IDE

Claude Desktop (claude_desktop_config.json):

json
{
  "mcpServers": {
    "mssql": {
      "command": "npx",
      "args": ["-y", "mssql-mcp@latest"],
      "env": {
        "DB_SERVER": "your-server.com",
        "DB_DATABASE": "your-database",
        "DB_USER": "your-username",
        "DB_PASSWORD": "your-password",
        "DB_ENCRYPT": "true",
        "DB_TRUST_SERVER_CERTIFICATE": "true"
      }
    }
  }
}

Cursor/Windsurf/VS Code (.vscode/mcp.json):

json
{
  "servers": {
    "mssql": {
      "command": "npx",
      "args": ["-y", "mssql-mcp@latest"],
      "env": {
        "DB_SERVER": "your-server.com",
        "DB_DATABASE": "your-database",
        "DB_USER": "your-username",
        "DB_PASSWORD": "your-password",
        "DB_ENCRYPT": "true",
        "DB_TRUST_SERVER_CERTIFICATE": "true"
      }
    }
  }
}

HTTP transport (remote/hosted scenarios):

json
{
  "servers": {
    "mssql": {
      "type": "http",
      "url": "http://127.0.0.1:3001",
      "env": {}
    }
  }
}

Replace with your actual database credentials. Credentials are read from the server environment only — never passed as tool parameters.

��️ Tool Catalog

Primary tools (use these)

ToolRead-onlyDescription
mssql_connect_databaseNoConnect using env variables. Idempotent.
mssql_disconnect_databaseNoClose connection. Idempotent.
mssql_connection_status✅Connection state and pool metrics
mssql_run_sql_query⚠️ NoExecute arbitrary SQL. May mutate data.
mssql_list_schema_objects✅List tables/views/procedures/functions with pagination
mssql_describe_table_columns✅Column definitions for a table
mssql_read_table_rows✅Paginated rows with projection and safe WHERE
mssql_execute_stored_procedure⚠️ NoExecute a stored procedure
mssql_list_databases✅List all databases on the instance

All data tools accept a response_format parameter ("json" | "markdown", default "json"). Use "markdown" to get human-readable table output.

Deprecated aliases (still registered for backward compatibility)

These are the only alias tool names the server actually registers (in src/tools/*.ts). They behave the same as their replacement but are not documented in new integrations — use the primary tool names above instead.

Old nameUse instead
mssql_execute_querymssql_run_sql_query
mssql_get_schemamssql_list_schema_objects
mssql_describe_tablemssql_describe_table_columns
mssql_get_table_datamssql_read_table_rows
mssql_execute_proceduremssql_execute_stored_procedure

🚌 Transport Modes

ModeUse when
stdio (default)Local IDE integration (Claude Desktop, Cursor, VS Code)
httpRemote/hosted deployment, testing with MCP Inspector
bash
# stdio (default)
node dist/src/index.js

# HTTP on 127.0.0.1:3001
MCP_TRANSPORT=http node dist/src/index.js

# Custom HTTP host/port
MCP_TRANSPORT=http MCP_HOST=0.0.0.0 MCP_PORT=8080 node dist/src/index.js

🔧 Environment Variables

Database connection

VariableRequiredDefaultDescription
DB_SERVER✅—SQL Server hostname or IP
DB_DATABASE❌—Database name
DB_USER❌—Login username
DB_PASSWORD❌—Login password
DB_PORT❌1433TCP port
DB_ENCRYPT❌trueEnable TLS (required for Azure SQL)
DB_TRUST_SERVER_CERTIFICATE❌falseTrust self-signed certs
DB_CONNECTION_TIMEOUT❌30000Connection timeout ms
DB_REQUEST_TIMEOUT❌30000Query timeout ms

Transport

VariableDefaultDescription
MCP_TRANSPORTstdiostdio or http
MCP_HOST127.0.0.1HTTP bind address
MCP_PORT3001HTTP port

🔒 Security Model

  • No credential parameters: All connection settings come from environment variables only. Tool inputs cannot override connection config.
  • Identifier validation: Schema, table, and procedure names are validated against a safe identifier pattern before interpolation into SQL.
  • Parameterized queries: All user-supplied values (WHERE clause values, column values) must be passed as named parameters via @paramName — never embedded in query strings.
  • Origin and Host validation: HTTP transport validates both the Origin and Host headers against an allowlist (localhost, [::1], and the configured bind host by default), guarding against DNS rebinding.
  • SQL risk labeling: run_sql_query and execute_stored_procedure are explicitly labeled as non-read-only and open-world.

⚠️ SQL Risk Notes

run_sql_query accepts arbitrary SQL including DDL and DML. To minimize risk:

  • Use a least-privilege SQL login (SELECT-only where possible)
  • Never run the server with a sysadmin or sa account
  • Consider network firewall rules to limit what the server can reach

📄 Pagination

All list tools return a pagination object:

json
{
  "count": 20,
  "limit": 20,
  "offset": 0,
  "has_more": true,
  "next_offset": 20,
  "total_count": 150
}

Default page size: 20 rows. Maximum: 200 rows.

Results are also truncated if the serialized payload exceeds 100KB, with a truncation_message explaining how many rows were dropped.

🏗️ Architecture

src/
  index.ts          ← bootstrap (env, transport selection)
  server.ts         ← createServer() factory
  constants.ts      ← limits, defaults, protocol strings
  config.ts         ← env parsing
  types.ts          ← shared TypeScript interfaces
  db/
    connection.ts   ← connection pool singleton
    validators.ts   ← SQL identifier validation
    query-builders.ts ← safe parameterized query construction
  tools/            ← one file per tool group
  resources/        ← MCP resource handlers
  transports/       ← stdio and HTTP transports
  utils/
    errors.ts       ← error normalization helpers
    format.ts       ← JSON formatting, payload truncation
    markdown.ts     ← markdown table/list rendering helpers
    pagination.ts   ← pagination metadata helpers

🧪 Inspector Smoke Test

bash
npx @modelcontextprotocol/inspector

Expected:

  • stdio server connects
  • Tool list renders with all tools
  • mssql_connection_status returns JSON without a connection
  • mssql_connect_database works when env variables are set

🔨 Development

bash
npm install
cp .env.example .env  # fill in your test DB credentials
npm run typecheck     # type check only
npm run build         # compile TypeScript
npm test              # run unit tests
npm run ci            # typecheck + build + test

License

MIT © BYMCS

Installation

TypingMind
{
  "mcpServers": {
    "mssql-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "mssql-mcp@latest"
      ],
      "env": {
        "DB_SERVER": "<DB_SERVER>"
      }
    }
  }
}

Available Tools

  • mssql_connect_database

    Connects to MS SQL Server using environment variables (DB_SERVER, DB_DATABASE, DB_USER, DB_PASSWORD, DB_PORT, DB_ENCRYPT, DB_TRUST_SERVER_CERTIFICATE). No credentials accepted as parameters — all connection settings come from the server environment only. Idempotent: calling again reconnects.

  • mssql_disconnect_database

    Closes the current database connection and releases the connection pool. Safe to call even if not connected. Idempotent.

  • mssql_connection_status

    Returns the current connection status, server address, database name, and connection pool metrics. Read-only. Safe to call at any time.

  • mssql_run_sql_query

    Executes an arbitrary SQL statement against the connected database. ⚠️ WARNING: This tool can read AND modify data (INSERT, UPDATE, DELETE, DDL). Always prefer parameterized inputs via the 'parameters' field — never embed user-supplied values directly in the query string. Example: query='SELECT * FROM dbo.Users WHERE Id = @id', parameters={id: 42}

  • mssql_execute_query

    Deprecated alias for mssql_run_sql_query. Use mssql_run_sql_query instead. ⚠️ This tool can read AND modify data.

  • mssql_list_schema_objects

    Lists tables, views, stored procedures, or functions in the connected database. Read-only. Supports filtering by schema name and pagination. Example: objectType='tables', schemaName='dbo', limit=20

  • mssql_get_schema

    Deprecated alias for mssql_list_schema_objects. Use mssql_list_schema_objects instead.

  • mssql_describe_table_columns

    Returns column definitions for a table: name, data type, length, nullability, default, and ordinal position. Read-only. Uses parameterized queries to prevent injection.

  • mssql_describe_table

    Deprecated alias for mssql_describe_table_columns.

  • mssql_read_table_rows

    Returns rows from a table with optional column projection, WHERE filtering, ORDER BY, and pagination. Read-only. Table and schema names are validated as safe identifiers. WHERE clause values MUST be passed via 'parameters' using @paramName placeholders. Pagination: limit (1-200, default 20) and offset. Example: tableName='Orders', schemaName='dbo', columns=['OrderId','Total'], limit=50

  • mssql_get_table_data

    Deprecated alias for mssql_read_table_rows. Use mssql_read_table_rows instead. ⚠️ whereClause must use @paramName placeholders for all values.

  • mssql_execute_stored_procedure

    Executes a stored procedure by name. ⚠️ May modify data — use only when an action is intended. Schema and procedure names are validated as safe identifiers. Pass all value parameters via 'parameters'.

  • mssql_execute_procedure

    Deprecated alias for mssql_execute_stored_procedure.

  • mssql_list_databases

    Lists all databases visible on the connected SQL Server instance with state and recovery information. Read-only. Supports pagination.

Use MS SQL Server MCP Server MCP with multiple AI models

TypingMind connects MCP tools at the workspace level, so once MS SQL Server MCP Server is connected, you can use it with different AI models in TypingMind instead of setting it up separately for each model. You can run MCP locally on your device or connect to a remote MCP server URL.

Option 1: Use the local connector

Use this when the MCP server needs access to local files, apps, or private resources on your computer.

1

Open the MCP settings

In TypingMind, go to Settings, Advanced Settings, then Model Context Protocol and choose Setup Connector.

  1. Open TypingMind in your browser.
  2. Click the Settings icon.
  3. Go to Advanced Settings.
  4. Open the Model Context Protocol section.
  5. Click Setup Connector and choose This Device.
TypingMind MCP connector setup screen with This Device selected
2

Run the connector command

Choose This Device, copy the command from TypingMind, and run it in Terminal. Keep the process running while you use MCP.

  1. Copy the setup command shown by TypingMind.
  2. Open Terminal on macOS or Windows Terminal on Windows.
  3. Paste and run the command.
  4. Approve the package install if Terminal asks you to proceed.
  5. Keep the Terminal window running while using MCP tools.
3

Add MS SQL Server MCP Server as a server

When the connector status is Ready, click Edit Servers and paste the MCP server configuration.

  1. Wait until the connector status shows Ready.
  2. Click Edit Servers.
  3. Paste the MS SQL Server MCP Server MCP server configuration.
  4. Save the server list.
  5. Refresh if you want to confirm the connector is still ready.
TypingMind MCP settings showing active server and Edit Servers button
{
  "mcpServers": {
    "mssql-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "mssql-mcp"
      ]
    }
  }
}
4

Use it across models

Save the server list, open Plugins, enable the MS SQL Server MCP Server MCP tools, then select any supported AI model in TypingMind and use the tools in chat or assign them to an AI agent.

  1. Open the Plugins page in TypingMind.
  2. Enable the MS SQL Server MCP Server MCP tools.
  3. Start a chat and choose the AI model you want to use.
  4. Use the MCP tools in chat or assign them to an AI agent.
  5. Switch to another AI model whenever needed without reconnecting MCP.
TypingMind chat using enabled MCP tools with a selected AI model
Can you use MS SQL Server MCP Server to help me with this task?
MS SQL Server MCP Server
Sure. I read it.
Here is what I found using MS SQL Server MCP Server.

Option 2: Add an MCP server URL

Use this when MS SQL Server MCP Server is already hosted remotely or your team wants one shared connector that multiple users can access.

1

Open MCP connectors

In TypingMind, go to Plugins, open MCP connectors, then choose Add URL.

  1. Open TypingMind in your browser.
  2. Go to Plugins.
  3. Open MCP connectors.
  4. Click Add URL.
TypingMind Add Custom MCP Server URL form
2

Paste the server URL

Enter the MCP server URL from the provider in the Server URL field. Add a connection name, description, icon, custom HTTP headers, or OAuth client settings if the server requires them.

  1. Paste the MCP server URL from the provider into the Server URL field.
  2. Enter a connection name for MS SQL Server MCP Server.
  3. Add a description and icon if you want it to be easier to identify.
  4. Add custom HTTP headers or OAuth client details if the server requires authentication.
3

Create the connection

Click Create connection, then return to the Plugins list and confirm the new MCP connection is active.

  1. Click Create connection.
  2. Return to the MCP connectors list.
  3. Confirm the MS SQL Server MCP Server connection appears as active.
  4. Refresh the plugin list if the connection does not appear immediately.
4

Switch models without reconnecting

Start a chat with your preferred model, enable the MS SQL Server MCP Server tools from Plugins, and switch to another model whenever needed. The MCP connection stays available to the TypingMind workspace.

  1. Start a new chat in TypingMind.
  2. Select the AI model you want to use.
  3. Enable the MS SQL Server MCP Server tools from Plugins.
  4. Ask the model to use the tool when needed.
  5. Switch to another AI model and reuse the same MCP connection.
TypingMind chat using enabled MCP tools with a selected AI model
Can you use MS SQL Server MCP Server to help me with this task?
MS SQL Server MCP Server
Sure. I read it.
Here is what I found using MS SQL Server MCP Server.

Frequently asked questions

What is the MS SQL Server MCP Server MCP server used for?

MS SQL Server MCP Server is an MCP server that lets compatible AI clients connect to external tools and context. In TypingMind, you can add this MCP server once and make its tools available in your AI workspace.

Can I use MS SQL Server MCP Server MCP with multiple AI models in TypingMind?

Yes. TypingMind connects MCP tools at the workspace level, so you can use MS SQL Server MCP Server with different AI models such as Claude, ChatGPT, Gemini, or other models you have configured in TypingMind without setting up the MCP server separately for each model.

Why use MS SQL Server MCP Server MCP with TypingMind?

TypingMind is one of the best frontends for LLM chat because it brings multiple AI models, prompts, plugins, AI agents, API keys, and MCP tools into one workspace. With MS SQL Server MCP Server connected, you can use its MCP tools across your preferred models while keeping your chat workflow organized in TypingMind.

How do I connect MS SQL Server MCP Server MCP to TypingMind?

MS SQL Server MCP Server can be connected in TypingMind with the local MCP connector or by adding a remote MCP server URL. Use the local connector when the server needs access to files, apps, or private resources on your device, and use a server URL when the MCP server is hosted remotely.

What tools does MS SQL Server MCP Server MCP provide in TypingMind?

MS SQL Server MCP Server exposes 14 MCP tools that can be enabled from the TypingMind Plugins page and used in chat or assigned to AI agents.

Do I need to share my API keys with TypingMind to use MS SQL Server MCP Server MCP?

No. TypingMind is local-first and lets you keep your model providers, API keys, prompts, and MCP configuration under your control. If MS SQL Server MCP Server requires authentication, add the required headers, OAuth settings, or local configuration for that MCP server when you create the connection.

connection-info

Current MSSQL connection status and configuration (no credentials exposed).

databases

Snapshot list of all databases on the SQL Server instance.

schemas

Snapshot list of all schemas in the current database.

Related MCP Servers

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇