MCP server for Microsoft SQL Server

MCP server for Microsoft SQL Server

mssql-mcp-bymcs•bybymcs

An MCP server that exposes tools for connecting to and working with a Microsoft SQL Server instance, including schema inspection, reading table rows, running SQL queries, and executing stored procedures.

License: MIT•Runtime: Awaiting documentation review•Category: databases storage

WHAT IT DOES

  • •Connects to a SQL Server instance using connection settings supplied through environment variables and reports connection status.
  • •Lists schema objects such as tables, views, procedures, and functions with pagination, and describes table columns.
  • •Reads paginated table rows and lists databases on the instance.
  • •Runs arbitrary SQL queries and stored procedures, labeled as non-read-only with risk notes advising least-privilege logins.

BEST FOR

  • •Letting an AI assistant inspect an existing SQL Server database schema before generating queries.
  • •Retrieving sample or filtered table data for analysis from within an MCP-enabled IDE.
  • •Executing stored procedures or ad-hoc SQL through an assistant on a SQL Server instance.

ABOUT MSSQL-MCP-BYMCS

MCP server for Microsoft SQL Server is cataloged as an MCP server attributed to bymcs. An MCP server that exposes tools for connecting to and working with a Microsoft SQL Server instance, including schema inspection, reading table rows, running SQL queries, and executing stored procedures. It is categorized under databases storage. See the capability inspector for recorded interfaces and their independent review status; consult upstream documentation for the current interface.

HOW TO INSTALL

Installation configuration is not reviewed. No executable setup is offered for this entry; inspect the source repository before proceeding.

LICENSE

Catalog license label: MIT. Check the source repository's current license and terms before using, modifying or distributing this software.

Capability inspector

Capability definitions are not reviewed. Unreviewed imports are not exposed as trusted interfaces.

Tools (0)

No reviewed records to display. This does not establish that upstream lacks this capability.

Resources (0)

No reviewed records to display. This does not establish that upstream lacks this capability.

Prompts (0)

No reviewed records to display. This does not establish that upstream lacks this capability.

NEWSLETTER - COMING LATER

Newsletter subscriptions are not open yet

Email delivery is not connected. This page does not collect email addresses or create subscriptions.

Browse the registry for current listings instead.

Community Reviews

Coming later

Reviews for MCP server for Microsoft SQL Server are not available yet

Review publishing and storage are not connected. This page does not collect or publish ratings or comments, including after sign-in.

FREQUENTLY ASKED QUESTIONS

How does the server receive database credentials?

Credentials come only from environment variables and cannot be passed as tool parameters.

Which transport modes does the server support?

It supports stdio for local IDE integration and HTTP for remote or hosted deployment.

Are query results paginated?

Yes; list tools return pagination metadata with a default page size of 20 and a maximum of 200 rows.

Upstream README

View this exact version on GitHub

README.md · 5d865a54c22c · Fetched 2026-11-13 10:13:35 UTC

Original upstream text, without AI rewriting. Scripts, forms and unsafe links are filtered for safety.

Showing the last retrieved documentation snapshot; check the source for current changes.

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

npm install -g mssql-mcp

2. Configure IDE

Claude Desktop (claude_desktop_config.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):

{
  "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):

{
  "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
# 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:

{
  "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

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

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

Install configuration

Are you the maintainer?

Claim this server with your GitHub account to request manual ownership verification.

README Embed Badge
Markdown

Link to the catalog listing for MCP server for Microsoft SQL Server from your README. This badge does not certify ownership, compatibility or security.

[![MCP catalog listing](https://img.shields.io/badge/MCP-awesome--mcp-orange?style=flat-square)](https://awesome-mcp.com/servers/mssql-mcp-bymcs)

REPOSITORY STATS

GitHub StarsUnavailable
ForksUnavailable

Public repository statistics could not be verified. Check the configured source address; unavailable counts are not zero.

Downloads and pulls

Separate sources, scopes and periods. Never combined or treated as installations, active users or security reviews.

No reviewed package or image identity; download statistics are not listed yet.

Related databases storage MCP Servers

Alternative and complementary servers in the same category

View all in databases storage →
AIStor MCP server
mcp-server-aistor•minio

This is a Model Context Protocol (MCP) server for interacting with AIStor object stores.

Repository stats unavailable
Databases & Storage
InfluxDB v2 MCP Server
influxdb-mcp-server•idoru

A Model Context Protocol (MCP) server that exposes access to an InfluxDB v2 instance using the InfluxDB OSS API v2.

Repository stats unavailable
Databases & Storage