Fire in da houseTop Tip:Paying $100+ per month for Perplexity, MidJourney, Runway, ChatGPT and other tools is crazy - get all your AI tools in one site starting at $15 per month with Galaxy AI Fire in da houseCheck it out free

mssql_mcp_server

MCP.Pizza Chef: JexinSam

The MSSQL MCP Server is a Model Context Protocol server designed to provide secure, structured, and controlled access to Microsoft SQL Server databases. It supports listing tables, reading table contents, and executing SQL queries with strict permission enforcement and comprehensive logging. This server ensures safe database exploration and interaction for AI assistants by managing credentials via environment variables and handling errors gracefully.

Use This MCP server To

List available tables in MSSQL databases for AI-driven data exploration Execute controlled SQL queries with permission enforcement Retrieve table data securely for AI analysis or reporting Log all database interactions for audit and monitoring Enable AI assistants to interact with MSSQL databases safely Facilitate integration of MSSQL data into AI workflows Support error-handled query execution to prevent failures

README

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.

mssql_mcp_server FAQ

How do I configure database access for the MSSQL MCP Server?
Configure access by setting environment variables like MSSQL_HOST, MSSQL_USER, and MSSQL_PASSWORD.
Does the MSSQL MCP Server support secure credential management?
Yes, it uses environment variables to securely manage database credentials.
Can the server handle query errors gracefully?
Yes, it includes error handling to manage and report query execution issues.
Is logging available for database operations?
Yes, comprehensive logging is implemented to monitor all queries and interactions.
How do I install the MSSQL MCP Server?
Install it easily via pip using 'pip install mssql-mcp-server'.
Can this server restrict the types of SQL queries executed?
Yes, it enforces controlled query execution to maintain security and permissions.
What kind of database operations can AI assistants perform?
AI assistants can list tables, read data, and execute queries within controlled limits.
Is this MCP server compatible with other LLM providers?
Yes, it is provider-agnostic and works with models like OpenAI, Claude, and Gemini.