SQL Server MCP server for querying and inspecting databases

SQL Server MCP server for querying and inspecting databases

mssql-mcp-server-popplywop•bypopplywop

An MCP server that lets LLMs execute SQL queries and stored procedures, inspect schemas, and access database metadata as resources.

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

WHAT IT DOES

  • •Executes SQL queries against the database and returns results, with optional command timeout and row limit.
  • •Runs stored procedures with optional JSON parameters, schema, timeout, and row limits.
  • •Offers token-optimized schema tools to list tables, get columns, row counts, primary keys, and sample data.
  • •Exposes schema information as lazy-loaded, cached resources via URIs.

BEST FOR

  • •Letting an LLM run ad-hoc SQL queries and read the returned data.
  • •Exploring a database's tables, views, and stored procedures before querying.
  • •Running the server in read-only mode to block data-modifying statements.

ABOUT MSSQL-MCP-SERVER-POPPLYWOP

SQL Server MCP server for querying and inspecting databases is cataloged as an MCP server attributed to popplywop. An MCP server that lets LLMs execute SQL queries and stored procedures, inspect schemas, and access database metadata as resources. 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 License. Check the source repository's current license and terms before using, modifying or distributing this software.

能力检查器

能力定义尚未审核。未核验的采集内容不会作为可信接口展示。

Tools (0)

暂无可展示的已审核记录。这不表示上游不支持此能力。

Resources (0)

暂无可展示的已审核记录。这不表示上游不支持此能力。

Prompts (0)

暂无可展示的已审核记录。这不表示上游不支持此能力。

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 SQL Server MCP server for querying and inspecting databases 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

Does the server have a read-only mode?

Yes, running with the read-only option blocks INSERT, UPDATE, DELETE and similar operations.

How does it avoid exposing full view and procedure definitions?

View and procedure definitions are excluded by default to reduce token usage, and are only returned through the definition endpoints.

Can the connection string come from an environment variable?

Yes, the env-var option specifies the name of an environment variable containing the connection string.

上游原版 README

在 GitHub 查看同一版本原文

README.md · a1a72a83b549 · 采集于 2026-11-13 12:40:27 UTC

保留上游原文,不做 AI 改写。为安全起见过滤脚本、表单和不安全链接。

当前显示最后一次成功采集的文档快照,请以来源页面为准。

SQL Server MCP Server

A Model Context Protocol (MCP) server that provides tools for interacting with SQL Server databases. This server allows Large Language Models (LLMs) to query and inspect SQL Server databases through a standardized protocol.

Features

  • Database Querying: Execute SQL queries and retrieve results
  • Schema Inspection: List tables, views, stored procedures, and examine table schemas
  • SQL Injection Prevention: Built-in validation to prevent SQL injection attacks
  • Resource Caching: Metadata caching for improved performance

Getting Started

Prerequisites

  • .NET 10.0 SDK or later (or Docker)
  • SQL Server instance (local or remote)

Installation

Run the server using Docker without installing .NET:

# Build the image
docker build -t tsql-mcp-server .

# Run with connection string
docker run -i tsql-mcp-server --dsn "Server=host.docker.internal;Database=mydb;User Id=sa;Password=mypassword;TrustServerCertificate=True;"

# Run in read-only mode
docker run -i tsql-mcp-server --dsn "..." --read-only

# Run with environment variable
docker run -i -e SQL_CONNECTION="Server=..." tsql-mcp-server --env-var SQL_CONNECTION

Notes:

  • The -i flag is required for stdio transport
  • Use host.docker.internal to connect to SQL Server on your host machine
  • For WSL2 users: if host.docker.internal doesn't resolve, use --network host and localhost instead

Option 2: Install as a .NET Tool

Install globally as a .NET tool:

dotnet tool install --global tsql-mcp-server

To update to the latest version:

dotnet tool update --global tsql-mcp-server

Option 2: Build from Source

# Clone the repository
git clone https://github.com/Popplywop/tsql-mcp-server
cd tsql-mcp-server

# Build the project
dotnet build

Running the Server

Using the .NET Tool

If installed as a .NET global tool:

# Using a direct connection string
tsql-mcp-server --dsn "Server=your-server;Database=your-database;User Id=your-username;Password=your-password;TrustServerCertificate=True;"

# Using an environment variable
tsql-mcp-server --env-var "SQL_CONNECTION_STRING"

Using Source Code

If building from source:

# Using a direct connection string
dotnet run --dsn "Server=your-server;Database=your-database;User Id=your-username;Password=your-password;TrustServerCertificate=True;"

# Using an environment variable
dotnet run --env-var "SQL_CONNECTION_STRING"

MCP Server Configuration

To use this server with Claude or other LLMs that support the Model Context Protocol, you'll need to configure it in your MCP configuration file.

If Installed as a .NET Tool

{
  "servers": [
    {
      "name": "SqlServerMcp",
      "command": "tsql-mcp-server",
      "args": [
        "--dsn",
        "Server=your-server;Database=your-database;User Id=your-username;Password=your-password;TrustServerCertificate=True;"
      ]
    }
  ]
}

If Built from Source

{
  "servers": [
    {
      "name": "SqlServerMcp",
      "command": "path/to/tsql-mcp-server.exe",
      "args": [
        "--dsn",
        "Server=your-server;Database=your-database;User Id=your-username;Password=your-password;TrustServerCertificate=True;"
      ]
    }
  ]
}

Replace the connection string with your actual values. This configuration can be used with Claude's MCP integration or other LLM platforms that support the Model Context Protocol.

Using Docker

{
  "mcpServers": {
    "sqlserver": {
      "command": "docker",
      "args": [
        "run", "-i", "--rm", "tsql-mcp-server",
        "--dsn", "Server=host.docker.internal;Database=your-database;User Id=your-username;Password=your-password;TrustServerCertificate=True;"
      ]
    }
  }
}

For read-only mode, add "--read-only" to the args array.

Using Environment Variables for Sensitive Information

For better security, you can use environment variables for your connection string:

{
  "servers": [
    {
      "name": "SqlServerMcp",
      "command": "tsql-mcp-server",
      "args": [
        "--env-var",
        "SQL_CONNECTION_STRING"
      ]
    }
  ]
}

Command Line Options

OptionShortDescription
--dsn-dSQL Server connection string
--env-var-eEnvironment variable name containing the connection string
--read-only-rRun in read-only mode (blocks INSERT, UPDATE, DELETE, etc.)

Available MCP Tools

Query Tools

  • ExecuteQuery: Executes a SQL query against the database and returns the results

    • Parameters:
      • query: The SQL query to execute
      • commandTimeout: Optional command timeout in seconds
      • maxRows: Optional maximum number of rows to return
  • ExecuteStoredProcedure: Executes a stored procedure with optional parameters

    • Parameters:
      • schema: The schema name (e.g., 'dbo')
      • procedureName: The stored procedure name
      • parametersJson: Optional JSON object of parameters (e.g., {"@param1": "value"})
      • commandTimeout: Optional command timeout in seconds
      • maxRows: Optional maximum number of rows to return

Schema Tools (Token-Optimized)

Lightweight tools for exploring database structure without fetching data:

  • GetTableColumns: Get column names and types for a table
  • GetTableRowCount: Get row count for a table
  • ListTables: List all tables in a schema (with optional row counts)
  • GetPrimaryKey: Get primary key columns for a table
  • GetSampleData: Get a small sample of data (max 20 rows)

Database Resources

The server provides database schema information through a resource-based approach. Resources are accessed via URIs and are lazy-loaded with caching for improved performance.

Resource URIDescriptionLoading Behavior
sqlserver://schemas/{schema_name}Information about a specific schemaLoaded on first request, cached for 10 minutes
sqlserver://schemas/{schema_name}/tablesList of tables in a schemaLoaded on first request, cached for 10 minutes
sqlserver://schemas/{schema_name}/viewsList of views in a schemaLoaded on first request, cached for 10 minutes
sqlserver://schemas/{schema_name}/proceduresList of stored procedures in a schemaLoaded on first request, cached for 10 minutes
sqlserver://schemas/{schema_name}/tables/{table_name}Detailed information about a specific tableLoaded on first request, cached for 10 minutes
sqlserver://schemas/{schema_name}/views/{view_name}View columns (definition excluded)Loaded on first request, cached for 10 minutes
sqlserver://schemas/{schema_name}/views/{view_name}/definitionView SQL definitionLoaded on request
sqlserver://schemas/{schema_name}/procedures/{procedure_name}Procedure parameters (definition excluded)Loaded on first request, cached for 10 minutes
sqlserver://schemas/{schema_name}/procedures/{procedure_name}/definitionProcedure SQL definitionLoaded on request

Note: View and procedure definitions are excluded by default to reduce token usage. Use the /definition endpoint when you need the SQL source code.

Resources are automatically discovered by the MCP client and can be accessed directly without requiring specific tool calls.

Security Considerations

  • Use a SQL Server account with appropriate permissions (principle of least privilege)
  • Store connection strings securely (not in source control)
  • Consider using environment variables for connection strings
  • Enable TLS/SSL for database connections
  • SQL injection validation prevents dangerous operations and protects against common attack vectors

Example Usage

Querying Data

ExecuteQuery:
  query: "SELECT TOP 10 * FROM MyTable"
  maxRows: 100

Accessing Database Resources

Resources can be accessed directly via their URIs:

# List all schemas
GET sqlserver://schemas

# Get information about a specific schema
GET sqlserver://schemas/dbo

# List all tables in a schema
GET sqlserver://schemas/dbo/tables

# Get detailed information about a specific table
GET sqlserver://schemas/dbo/tables/Customers

The resource-based approach provides a RESTful way to explore and interact with the database schema.

License

This project is licensed under the MIT License - see the LICENSE.md file for details.

The MIT License is a permissive license that allows for reuse with minimal restrictions. It permits anyone to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the software, subject to the condition that the original copyright notice and permission notice appear in all copies.

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 SQL Server MCP server for querying and inspecting databases 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-server-popplywop)

REPOSITORY STATS

GitHub StarsUnavailable
ForksUnavailable

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

下载与拉取统计

来源、范围和时段分别列出;不相加,不代表安装人数、活跃用户或安全审核。

尚无已审核的包 / 镜像标识,暂不展示下载统计。

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