SQL Server MCP server for Claude

SQL Server MCP server for Claude

mcpserverformssql•byshakunvohradeltek

A local MCP server that connects Claude to a SQL Server database using pymssql and exposes a tool for executing SQL queries.

License: Not specified•Runtime: Awaiting documentation review•Category: databases storage

WHAT IT DOES

  • •Connects to SQL Server directly via pymssql without requiring ODBC.
  • •Exposes an execute_sql tool that runs SQL queries and returns results, row count, and success status.
  • •Implements MCP protocol version 2025-03-26 with JSON-RPC and Content-Length headers for Claude compatibility.
  • •Works cross-platform on macOS and Linux.

BEST FOR

  • •Asking Claude natural language questions against a SQL Server database.
  • •Exploring database schemas and running ad-hoc SQL queries through Claude.
  • •Teams sharing a read-only SQL analysis setup with Claude.

ABOUT MCPSERVERFORMSSQL

SQL Server MCP server for Claude is cataloged as an MCP server attributed to shakunvohradeltek. A local MCP server that connects Claude to a SQL Server database using pymssql and exposes a tool for executing SQL queries. 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: Not specified. 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 Claude 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

What security precautions should be taken when using this MCP server?

Use a database account with restricted permissions, such as a dedicated read-only user, and avoid accounts with DROP, DELETE, or table creation privileges or admin accounts in production.

What does the execute_sql tool accept as input?

It accepts a single required string parameter, query, containing the SQL query to execute.

上游原版 README

在 GitHub 查看同一版本原文

README.md · 607343c10b94 · 采集于 2026-11-13 11:36:06 UTC

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

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

SQL Server MCP for Claude

This repository contains the SQL Server MCP (Model Context Protocol) integration for Claude. This integration allows Claude to directly query and analyze data from your SQL Server database using natural language.

This MCP server is certified with MCP Review: https://mcpreview.com/mcp-servers/shakunvohradeltek/mcpserverformssql

Overview

The SQL MCP integration works by:

  1. Setting up a local server that Claude can communicate with via the Model Context Protocol
  2. Connecting to your SQL Server database using pymssql directly (no ODBC required)
  3. Translating Claude's natural language requests into SQL queries
  4. Returning the query results back to Claude for interpretation and presentation

Important Protocol Note: This integration uses Claude's required MCP protocol version "2025-03-26" for compatibility. The integration includes a fixed MCP implementation that handles the protocol correctly, including proper JSON-RPC format and Content-Length headers.

Key Features

  • No ODBC Required: Uses pymssql to connect directly to SQL Server
  • Simplified Architecture: Minimal dependencies and straightforward design
  • Protocol Support: Works with Claude's MCP system
  • Cross-Platform: Works on macOS and Linux consistently
  • Easy Installation: One-step installation process
  • Smart Configuration: Preserves existing MCP settings and Claude instructions when adding SQL support

Installation

Prerequisites

  • macOS or Ubuntu Linux
  • Python 3.7+
  • FreeTDS (installed automatically on macOS via Homebrew)
  • Claude CLI (install from claude.ai/docs/installation)
  • SQL Server credentials with appropriate permissions (preferably read-only, see Security Caution)

Installation Steps

  1. Run the installation script:
./install_sql_mcp.sh
  1. Follow the prompts to enter your SQL Server connection details:

    • SQL Server hostname
    • SQL Server port (default: 1433)
    • Database name
    • Username
    • Password
    • Trust server certificate (default: true)
  2. The installer will:

    • Install required dependencies
    • Configure FreeTDS for SQL Server connectivity
    • Set up a Python virtual environment
    • Install required Python packages
    • Create the necessary scripts
    • Configure Claude to recognize the SQL MCP server
  3. Verify the installation:

./run_simple_sql.sh "SELECT 1 AS TestQuery"

Usage

  1. Start Claude:
claude

You can also:

  • Check MCP status: claude /mcp
  • Debug MCP: claude --mcp-debug
  1. Ask Claude questions about your database:
@sql execute_sql
SELECT TOP 5 * FROM YourTable
@sql execute_sql
SELECT COUNT(*) FROM Users WHERE IsActive = 1

⚠️ Security Caution

Important: For security reasons, use a database account with restricted permissions:

  • Create a dedicated read-only user for Claude's database access
  • Avoid using accounts with DROP, DELETE, or table creation privileges
  • Never use sa or admin accounts in production environments
  • Consider restricting access to only specific tables/views needed for analysis

Using overly privileged accounts could result in accidental data loss or database structure changes when Claude generates SQL queries based on natural language requests.

Best Practices for Prompting Claude

When working with Claude to query your SQL Server database, follow these best practices:

  1. Ask Claude to explore the database schema first: Before constructing queries, prompt Claude to examine the database structure to understand tables, columns, and relationships.

    @sql execute_sql
    SELECT TABLE_NAME, COLUMN_NAME, DATA_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = 'dbo' ORDER BY TABLE_NAME, ORDINAL_POSITION
    
  2. Provide context about your data model: Explain what kind of data your database contains and how the tables relate to each other.

  3. Start with schema exploration: Ask Claude to first explore table structures before writing complex queries.

  4. Verify query results: Have Claude explain what the query results mean and verify they match your expectations.

  5. Build complexity gradually: Start with simple queries and gradually add complexity as Claude demonstrates understanding of your schema.

Troubleshooting

If you encounter issues with the SQL MCP integration:

  1. Test direct connectivity:
./run_simple_sql.sh "SELECT 1 AS TestQuery"
  1. Ensure FreeTDS is configured correctly:
tsql -C
  1. Verify Claude can find the MCP server:
claude mcp list
  1. If you see "Connection failed" or "Connection closed" messages but queries still work, this is normal behavior and can be ignored.

  2. Protocol version compatibility: This installation uses protocol version "2025-03-26" which is required for Claude's MCP. If you encounter MCP transport closed errors, check that the protocol version hasn't changed.

  3. JSON-RPC format: Claude's MCP requires proper JSON-RPC format with non-null IDs and Content-Length headers. The installation script configures this correctly.

MCP Tools Exposed

The MCP server exposes the following tools to Claude:

execute_sql

  • Description: Execute SQL queries on the connected database
  • Input Schema:
    • query (string, required): The SQL query to execute
  • Usage: Use @sql execute_sql in Claude followed by your SQL query
  • Returns: JSON object with query results, row count, and success status

Files and Components

Created during installation:

  • simple_sql.py - Python script that handles SQL queries directly
  • run_simple_sql.sh - Wrapper script that invokes the Python script
  • mcp_fixed.py - MCP protocol implementation with proper tool exposure
  • run_mcp_fixed.sh - Wrapper script for the MCP server
  • .mcp.json - Configuration file for the MCP server
  • CLAUDE.md - Instructions for Claude on how to use the SQL integration

Team Distribution

To distribute this SQL MCP integration to your team:

  1. Share this repository with your team members

  2. Team members should:

    • Make the scripts executable: chmod +x *.sh
    • Run the installation script: ./install_sql_mcp.sh
    • Follow the prompts to enter their SQL Server details

Latest Updates (May 2024)

The installation script has been updated with these important fixes:

  1. Fixed MCP protocol version to "2025-03-26" (previously "2024-11-05") to match Claude's requirements
  2. Added improved MCP implementation that properly handles JSON-RPC format
  3. Properly handles Content-Length headers in MCP communication
  4. Fixed notification handling in the protocol
  5. Added continuous loop for persistent MCP connections
  6. Improved error handling and debugging logs
  7. NEW: Exposed SQL tools through MCP protocol - The MCP server now properly exposes the execute_sql tool through the tools/list and tools/call methods, making it compatible with Claude's tool discovery and execution system

Credits

This SQL MCP integration is based on the following open-source projects:

  • FreeTDS - TDS protocol library for communicating with SQL Server
  • pymssql - Python DB-API interface for SQL Server
  • Model Context Protocol - Anthropic's protocol for tool use with Claude

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 Claude 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/mcpserverformssql)

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