Skip to main content

MCP Server custom para SQL Server

Project description

dreez-mssql-mcp

A Model Context Protocol (MCP) server for SQL Server — built with read-only safety, pyodbc, and full compatibility with uvx.

PyPI version Python License: MIT Author


✨ Features

  • 🔍 Execute read-only SQL queries (SELECT / WITH)
  • 🛡️ READ_ONLY mode — blocks any mutating SQL by default (INSERT, UPDATE, DELETE, DROP, TRUNCATE, ALTER, CREATE, EXEC, MERGE, GRANT, REVOKE)
  • 📋 List tables in any schema
  • 🔎 Describe table columns (types, nullability, defaults)
  • 🗂️ List schemas in the database
  • 📦 List stored procedures
  • ⚡ Compatible with uvx — no global install needed

📦 Installation

Using uvx (recommended — no install required)

uvx dreez-mssql-mcp

Using pip

pip install dreez-mssql-mcp

⚙️ Environment Variables

Variable Required Default Description
MSSQL_SERVER SQL Server hostname or IP
MSSQL_PORT SQL Server port (usually 1433)
MSSQL_DB Database name
MSSQL_USER SQL Server username
MSSQL_PWD SQL Server password
READ_ONLY true Set to false to allow write operations ⚠️

🔧 Client Configuration

Claude Desktop

Edit claude_desktop_config.json:

{
  "mcpServers": {
    "dreez-mssql": {
      "command": "uvx",
      "args": ["dreez-mssql-mcp"],
      "env": {
        "MSSQL_SERVER": "localhost",
        "MSSQL_PORT": "1433",
        "MSSQL_DB": "your_database",
        "MSSQL_USER": "your_user",
        "MSSQL_PWD": "your_password",
        "READ_ONLY": "true"
      }
    }
  }
}

Cursor / VS Code

Edit .cursor/mcp.json or .vscode/mcp.json:

{
  "servers": {
    "dreez-mssql": {
      "type": "stdio",
      "command": "uvx",
      "args": ["dreez-mssql-mcp"],
      "env": {
        "MSSQL_SERVER": "localhost",
        "MSSQL_PORT": "1433",
        "MSSQL_DB": "your_database",
        "MSSQL_USER": "your_user",
        "MSSQL_PWD": "your_password",
        "READ_ONLY": "true"
      }
    }
  }
}

🛠️ Available Tools

Tool Description
execute_query(sql, max_rows?) Run a SELECT or WITH (CTE) query. Returns JSON. Max 1000 rows.
list_tables(schema?) List all tables in a schema (default: dbo)
describe_table(table_name, schema?) Get columns, types, and nullability for a table
list_schemas() List all schemas in the current database
list_stored_procedures(schema?) List stored procedures in a schema

🛡️ READ_ONLY Mode

By default, READ_ONLY=true. Any query containing write keywords will be blocked immediately before reaching the database:

{
  "error": "Operación bloqueada: el servidor está en modo solo lectura (READ_ONLY=true).",
  "keywords_detectadas": ["DELETE"]
}

Blocked keywords: INSERT, UPDATE, DELETE, DROP, TRUNCATE, ALTER, CREATE, EXEC, EXECUTE, MERGE, REPLACE, GRANT, REVOKE

⚠️ Set READ_ONLY=false only in controlled environments. It is strongly recommended to also use a SQL Server user with read-only database permissions as an extra safety layer.


🚀 Development

# Clone the repo
git clone https://github.com/dreezdev/dreez-mssql-mcp.git
cd dreez-mssql-mcp

# Install with uv
uv sync

# Run locally
uv run dreez-mssql-mcp

📋 Requirements


📄 License

MIT © dreezdev


👤 Author

Made with ❤️ by dreezdev

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

dreez_mssql_mcp-1.0.0.tar.gz (52.0 kB view details)

Uploaded Source

Built Distribution

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

dreez_mssql_mcp-1.0.0-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

Details for the file dreez_mssql_mcp-1.0.0.tar.gz.

File metadata

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

File hashes

Hashes for dreez_mssql_mcp-1.0.0.tar.gz
Algorithm Hash digest
SHA256 abfd5b8e79b13dd97d6aeb1d1bda7e32976225080390c2d57f8fe01a4798065e
MD5 11c6ef6c59c5fe9bbe6bdbafdb246f33
BLAKE2b-256 700cf3b01f0f28ee4acf6d1718e8963f85a39736e729be21fd7aa79cd96b2ac9

See more details on using hashes here.

Provenance

The following attestation bundles were made for dreez_mssql_mcp-1.0.0.tar.gz:

Publisher: publish.yml on DreezDev/mssql-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 dreez_mssql_mcp-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for dreez_mssql_mcp-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 63f87a64bd4a1b005de1ed6fbdb797cca9fe2fc09afa57ad59f415f6f5db9c12
MD5 5febf789593521891da38ee37ec5ab3b
BLAKE2b-256 807f635e3c8bd774fbc649b1c232cbbd1a1f3eb39f8910f5ae9f387240ee9313

See more details on using hashes here.

Provenance

The following attestation bundles were made for dreez_mssql_mcp-1.0.0-py3-none-any.whl:

Publisher: publish.yml on DreezDev/mssql-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