Skip to main content

MCP server for Microsoft SQL Server databases

Project description

mssql-mcp

An MCP (Model Context Protocol) server for Microsoft SQL Server databases. Enables AI assistants like Claude to interact with SQL Server through a standardized protocol.

Features

  • Query Execution: Run SELECT queries with safety limits
  • Schema Discovery: List tables, views, and column information
  • CRUD Operations: Read, insert, update, and delete rows
  • Stored Procedures: Execute stored procedures with parameters
  • Export: Export query results to JSON or CSV
  • Safety Controls: Command blocklist, read-only mode, row limits, query timeouts

Installation

pip install mssql-mcp

Or install from source:

git clone https://github.com/yourusername/mssql-mcp.git
cd mssql-mcp
pip install -e ".[dev]"

Configuration

Copy .env.sample to .env and configure your settings:

cp .env.sample .env

Required environment variables:

Variable Description
MSSQL_HOST SQL Server hostname
MSSQL_USER Database username
MSSQL_PASSWORD Database password
MSSQL_DATABASE Database name

Optional settings:

Variable Default Description
MSSQL_PORT 1433 Server port
MSSQL_READ_ONLY false Block write operations
MSSQL_MAX_ROWS 1000 Query row limit
MSSQL_QUERY_TIMEOUT 60 Query timeout (seconds)

Usage

With Claude Code

Add to your Claude Code MCP configuration:

{
  "mcpServers": {
    "mssql": {
      "command": "mssql-mcp",
      "env": {
        "MSSQL_HOST": "localhost",
        "MSSQL_USER": "sa",
        "MSSQL_PASSWORD": "your_password",
        "MSSQL_DATABASE": "your_database"
      }
    }
  }
}

Standalone

# Run with stdio transport (default)
mssql-mcp

# Run with HTTP transport
mssql-mcp --http

Available Tools

Tool Description
execute_query Run a SELECT query
validate_query Check if a query is safe to execute
list_tables List tables and views
describe_table Get column information for a table
read_rows Read rows by ID or filter
insert_row Insert a new row
update_row Update an existing row
delete_row Delete a row
call_stored_proc Execute a stored procedure
export_to_json Export query results to JSON
export_to_csv Export query results to CSV

Development

# Install dev dependencies
pip install -e ".[dev]"

# Run tests
pytest

# Lint and format
ruff check .
ruff format .

# Type check
mypy src/

License

Apache-2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pymssql_mcp-0.1.0.tar.gz (40.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pymssql_mcp-0.1.0-py3-none-any.whl (34.1 kB view details)

Uploaded Python 3

File details

Details for the file pymssql_mcp-0.1.0.tar.gz.

File metadata

  • Download URL: pymssql_mcp-0.1.0.tar.gz
  • Upload date:
  • Size: 40.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pymssql_mcp-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0f52619b7a2388e0d0155cef329b1227b2bd475b97975f0eae922b64bd29257a
MD5 187078c16f393d6d4b4e8377a386e1ff
BLAKE2b-256 82dd391e242481678c62df249642d17bd91e80893015faa230e5ed0f358ad657

See more details on using hashes here.

Provenance

The following attestation bundles were made for pymssql_mcp-0.1.0.tar.gz:

Publisher: publish.yml on bpamiri/pymssql-mcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pymssql_mcp-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pymssql_mcp-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 34.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pymssql_mcp-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7ba04deef79320c9227f8290011634115c014d10d951b1ed11649111173f35f6
MD5 f45fb4df307f4f3a138ae630d51178aa
BLAKE2b-256 523be1c278038934b130271af5fa45668fcd01590e1f430f419ea6e6d9439dd9

See more details on using hashes here.

Provenance

The following attestation bundles were made for pymssql_mcp-0.1.0-py3-none-any.whl:

Publisher: publish.yml on bpamiri/pymssql-mcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page