Skip to main content

A Model Context Protocol (MCP) server that enables secure interaction with MSSQL databases. This server allows AI assistants to list tables, read data, and execute SQL queries through a controlled interface, making database exploration and analysis safer and more structured.

Project description

Tests

MSSQL MCP Server

MSSQL MCP Server is a Model Context Protocol (MCP) server that enables secure and structured interaction with Microsoft SQL Server (MSSQL) databases. It allows AI assistants to:

  • List available tables
  • Read table contents
  • Execute SQL queries with controlled access

This ensures safer database exploration, strict permission enforcement, and logging of database interactions.

Features

  • Secure MSSQL Database Access through environment variables
  • Controlled Query Execution with error handling
  • Table Listing & Data Retrieval
  • Comprehensive Logging for monitoring queries and operations

Installation

pip install mssql-mcp-server

Configuration

Set the following environment variables to configure database access:

MSSQL_DRIVER=mssql_driver
MSSQL_HOST=localhost
MSSQL_USER=your_username
MSSQL_PASSWORD=your_password
MSSQL_DATABASE=your_database
#optional
TrustServerCertificate=yes
Trusted_Connection=no

Usage

With Claude Desktop

To integrate with Claude Desktop, add this configuration to claude_desktop_config.json:

{
  "mcpServers": {
    "mssql": {
      "command": "uv",
      "args": [
        "--directory",
        "path/to/mssql_mcp_server",
        "run",
        "mssql_mcp_server"
      ],
      "env": {
        "MSSQL_DRIVER": "mssql_driver",
        "MSSQL_HOST": "localhost",
        "MSSQL_USER": "your_username",
        "MSSQL_PASSWORD": "your_password",
        "MSSQL_DATABASE": "your_database"
      }
    }
  }
}

Running as a Standalone Server

# Install dependencies
pip install -r requirements.txt

# Run the server
python -m mssql_mcp_server

Development

# Clone the repository
git clone https://github.com/yourusername/mssql_mcp_server.git
cd mssql_mcp_server

# Set up a virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install development dependencies
pip install -r requirements-dev.txt

# Run tests
pytest

Security Considerations

  • Use a dedicated MSSQL user with minimal privileges.
  • Never use root credentials or full administrative accounts.
  • Restrict database access to only necessary operations.
  • Enable logging and auditing for security monitoring.
  • Regularly review permissions to ensure least privilege access.

Security Best Practices

For a secure setup:

  1. Create a dedicated MSSQL user with restricted permissions.
  2. Avoid hardcoding credentials—use environment variables instead.
  3. Restrict access to necessary tables and operations only.
  4. Enable SQL Server logging and monitoring for auditing.
  5. Review database access regularly to prevent unauthorized access.

For detailed instructions, refer to the MSSQL Security Configuration Guide.

⚠️ IMPORTANT: Always follow the Principle of Least Privilege when configuring database access.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Contributing

We welcome contributions! To contribute:

  1. Fork the repository.
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Commit your changes: git commit -m 'Add amazing feature'
  4. Push to the branch: git push origin feature/amazing-feature
  5. Open a Pull Request.

Need Help?

For any questions or issues, feel free to open a GitHub Issue or reach out to the maintainers.

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

mssql_mcp_server-0.1.2.tar.gz (8.7 kB view details)

Uploaded Source

Built Distribution

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

mssql_mcp_server-0.1.2-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file mssql_mcp_server-0.1.2.tar.gz.

File metadata

  • Download URL: mssql_mcp_server-0.1.2.tar.gz
  • Upload date:
  • Size: 8.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for mssql_mcp_server-0.1.2.tar.gz
Algorithm Hash digest
SHA256 53d12111d39a2eceb7c7102aa694807dda8c367b4ca7e3028ea02fde96e7b4fd
MD5 1744090986dbe075365c775359f8ee43
BLAKE2b-256 574df9c374d18304f37f41448cdf893ce3c6983921459d49e4d978635d7fcda9

See more details on using hashes here.

File details

Details for the file mssql_mcp_server-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for mssql_mcp_server-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 8d1f5606cc3faf0a9aaad34feef7c0fc3d7e9a50125627a2c5eea71b6ec7289b
MD5 266d20da6b4c769c060df53cb4155062
BLAKE2b-256 f8cc9e10af081fa3ebb1ff65d91971b4884411283efc2dda685ea7afdae2073c

See more details on using hashes here.

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