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.3.0.tar.gz (55.4 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.3.0-py3-none-any.whl (55.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pymssql_mcp-0.3.0.tar.gz
  • Upload date:
  • Size: 55.4 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.3.0.tar.gz
Algorithm Hash digest
SHA256 abd8132a1513daa41a4c0af7a46927cdab050908e36856e975a1c8a55b22f199
MD5 30c33f5410555f573c607cd42e51c8e6
BLAKE2b-256 a627fb2a6388c91bafe3b0d25090ed69f54db60430f895315ffd1b0b6d78e54f

See more details on using hashes here.

Provenance

The following attestation bundles were made for pymssql_mcp-0.3.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.3.0-py3-none-any.whl.

File metadata

  • Download URL: pymssql_mcp-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 55.2 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.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0a5ffe04ddc6b4c62316cb384347d3ad5d1183fbdbf3789b348ef9751f9b37a0
MD5 f3ce76c4226559991f71fef274f23d07
BLAKE2b-256 4d8506a874d8e97273fcc2a8a75f640413d453e6d5471bb48db834e8df828299

See more details on using hashes here.

Provenance

The following attestation bundles were made for pymssql_mcp-0.3.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