{"id":29244081,"url":"https://github.com/combiz/mssql-mcp-server","last_synced_at":"2026-05-08T15:35:10.969Z","repository":{"id":302484420,"uuid":"1012618777","full_name":"combiz/mssql-mcp-server","owner":"combiz","description":"A Model Context Protocol server for Microsoft SQL Server","archived":false,"fork":false,"pushed_at":"2025-07-02T16:16:49.000Z","size":19,"stargazers_count":1,"open_issues_count":1,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-11-06T12:09:46.423Z","etag":null,"topics":["ai-assistant","claude","cursor","mcp","model-context-protocol","mssql","sql-server"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/combiz.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-07-02T15:56:27.000Z","updated_at":"2025-09-23T01:01:17.000Z","dependencies_parsed_at":"2025-07-02T16:46:12.692Z","dependency_job_id":"e4b867e9-eac4-4654-9209-87b94dac215c","html_url":"https://github.com/combiz/mssql-mcp-server","commit_stats":null,"previous_names":["combiz/mssql-mcp-server"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/combiz/mssql-mcp-server","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/combiz%2Fmssql-mcp-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/combiz%2Fmssql-mcp-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/combiz%2Fmssql-mcp-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/combiz%2Fmssql-mcp-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/combiz","download_url":"https://codeload.github.com/combiz/mssql-mcp-server/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/combiz%2Fmssql-mcp-server/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32786073,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-08T08:22:46.396Z","status":"ssl_error","status_checked_at":"2026-05-08T08:22:45.650Z","response_time":54,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai-assistant","claude","cursor","mcp","model-context-protocol","mssql","sql-server"],"created_at":"2025-07-03T21:02:12.660Z","updated_at":"2026-05-08T15:35:10.935Z","avatar_url":"https://github.com/combiz.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MSSQL MCP Server\n\nA Model Context Protocol (MCP) server implementation for Microsoft SQL Server. This server enables AI assistants like Claude to interact with MSSQL databases through a standardized interface.\n\n## Features\n\n- 🚀 **Execute SQL Queries**: Run any SQL query with proper error handling and result formatting\n- 📊 **Browse Database Schema**: List tables, view table structures, and sample data\n- 🔧 **Multi-line Query Support**: Correctly handles queries with newlines, comments, and GO statements\n- 🔐 **Flexible Authentication**: Supports both Windows (trusted) and SQL authentication\n- ⚙️ **Environment Configuration**: Easy setup via environment variables\n- 🛡️ **Security**: Connection string encryption, certificate trust options, and secure credential handling\n\n## Installation\n\n### From PyPI\n```bash\npip install mssql-mcp-server-enhanced\n```\n\n### From Source\n```bash\ngit clone https://github.com/combiz/mssql-mcp-server.git\ncd mssql-mcp-server\npip install -e .\n```\n\n### Prerequisites\n\n1. **Python 3.8+**\n2. **ODBC Driver for SQL Server** - Install one of:\n   - [ODBC Driver 17 for SQL Server](https://docs.microsoft.com/en-us/sql/connect/odbc/download-odbc-driver-for-sql-server) (recommended)\n   - [ODBC Driver 18 for SQL Server](https://docs.microsoft.com/en-us/sql/connect/odbc/download-odbc-driver-for-sql-server)\n\n   Installation commands:\n   ```bash\n   # Ubuntu/Debian\n   curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -\n   curl https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/prod.list | sudo tee /etc/apt/sources.list.d/mssql-release.list\n   sudo apt-get update\n   sudo apt-get install -y msodbcsql17\n   \n   # macOS\n   brew tap microsoft/mssql-release https://github.com/Microsoft/homebrew-mssql-release\n   brew update\n   brew install msodbcsql17\n   \n   # Windows - Download installer from Microsoft\n   ```\n\n## Configuration\n\nConfigure the server using environment variables:\n\n### Required Variables\n\n- `MSSQL_DATABASE` - The database name to connect to\n\n### Connection Variables\n\n- `MSSQL_HOST` or `MSSQL_SERVER` - Server hostname (default: `localhost`)\n- `MSSQL_PORT` - Server port (default: `1433`)\n\n### Authentication Variables\n\nFor SQL Authentication:\n- `MSSQL_USER` - Username\n- `MSSQL_PASSWORD` - Password\n- `MSSQL_TRUSTED_CONNECTION` - Set to `no` (default: `no`)\n\nFor Windows Authentication:\n- `MSSQL_TRUSTED_CONNECTION` - Set to `yes`\n- No username/password needed\n\n### Optional Variables\n\n- `MSSQL_DRIVER` - ODBC driver name (default: `ODBC Driver 17 for SQL Server`)\n- `MSSQL_TRUST_SERVER_CERTIFICATE` - Trust server certificate (default: `yes`)\n- `MSSQL_ENCRYPT` - Encrypt connection (default: `yes`)\n- `MSSQL_CONNECTION_TIMEOUT` - Connection timeout in seconds (default: `30`)\n- `MSSQL_MULTI_SUBNET_FAILOVER` - Enable multi-subnet failover (default: `no`)\n\n## Usage\n\n### As a Standalone Server\n\n```bash\n# Set environment variables\nexport MSSQL_SERVER=your-server.database.windows.net\nexport MSSQL_DATABASE=your-database\nexport MSSQL_USER=your-username\nexport MSSQL_PASSWORD=your-password\n\n# Run the server\npython -m mssql_mcp_server.server\n```\n\n### With MCP-Compatible Clients\n\nAdd to your MCP configuration file:\n\n**Claude Desktop**:\n- macOS: `~/Library/Application Support/Claude/claude_desktop_config.json`\n- Windows: `%APPDATA%\\Claude\\claude_desktop_config.json`\n\n**Claude Code**: See Claude Code documentation for configuration location\n\n**Cursor**: Add to your Cursor MCP settings\n\n```json\n{\n  \"mcpServers\": {\n    \"mssql\": {\n      \"command\": \"python\",\n      \"args\": [\"-m\", \"mssql_mcp_server.server\"],\n      \"env\": {\n        \"MSSQL_SERVER\": \"your-server.database.windows.net\",\n        \"MSSQL_DATABASE\": \"your-database\",\n        \"MSSQL_USER\": \"your-username\",\n        \"MSSQL_PASSWORD\": \"your-password\"\n      }\n    }\n  }\n}\n```\n\n### Example Configurations\n\n#### Azure SQL Database\n```bash\nexport MSSQL_SERVER=myserver.database.windows.net\nexport MSSQL_DATABASE=mydatabase\nexport MSSQL_USER=myuser@myserver\nexport MSSQL_PASSWORD=mypassword\nexport MSSQL_ENCRYPT=yes\nexport MSSQL_TRUST_SERVER_CERTIFICATE=no\n```\n\n#### Local SQL Server with Windows Authentication\n```bash\nexport MSSQL_SERVER=localhost\nexport MSSQL_DATABASE=mydatabase\nexport MSSQL_TRUSTED_CONNECTION=yes\n```\n\n#### SQL Server on Non-Standard Port\n```bash\nexport MSSQL_SERVER=myserver.company.com\nexport MSSQL_PORT=1434\nexport MSSQL_DATABASE=mydatabase\nexport MSSQL_USER=sa\nexport MSSQL_PASSWORD=mypassword\n```\n\n#### MCP Configuration with Virtual Environment\nFor use with Claude Desktop, Claude Code, Cursor, or any MCP-compatible client. If you're using a Python virtual environment, specify the full path to the Python executable:\n\n```json\n{\n  \"mcpServers\": {\n    \"mssql\": {\n      \"command\": \"/path/to/your/venv/bin/python\",\n      \"args\": [\"-m\", \"mssql_mcp_server.server\"],\n      \"env\": {\n        \"MSSQL_SERVER\": \"your-server-name\",\n        \"MSSQL_DATABASE\": \"your-database\",\n        \"MSSQL_DRIVER\": \"ODBC Driver 17 for SQL Server\",\n        \"MSSQL_TRUST_SERVER_CERTIFICATE\": \"yes\",\n        \"MSSQL_TRUSTED_CONNECTION\": \"yes\",\n        \"MSSQL_ENCRYPT\": \"yes\",\n        \"MSSQL_CONNECTION_TIMEOUT\": \"60\",\n        \"MSSQL_PORT\": \"1433\"\n      }\n    }\n  }\n}\n```\n\n## Available Tools\n\n### execute_sql\n\nExecute any SQL query on the connected database.\n\n**Parameters:**\n- `query` (string, required): The SQL query to execute\n\n**Examples:**\n\n```sql\n-- Simple SELECT\nSELECT * FROM Users WHERE active = 1\n\n-- Multi-line query with JOIN\nSELECT \n    u.username,\n    u.email,\n    COUNT(o.id) as order_count\nFROM Users u\nLEFT JOIN Orders o ON u.id = o.user_id\nGROUP BY u.username, u.email\nHAVING COUNT(o.id) \u003e 5\n\n-- Create table\nCREATE TABLE Products (\n    id INT PRIMARY KEY IDENTITY(1,1),\n    name NVARCHAR(100) NOT NULL,\n    price DECIMAL(10,2),\n    created_at DATETIME DEFAULT GETDATE()\n)\n\n-- Insert data\nINSERT INTO Products (name, price)\nVALUES ('Widget', 19.99), ('Gadget', 29.99)\n```\n\n## Available Resources\n\nThe server exposes database tables as resources:\n\n- **Schema Resource**: `mssql://database/schema.table/schema`\n  - Shows table structure, column types, constraints\n  \n- **Data Resource**: `mssql://database/schema.table/data`\n  - Shows sample data from the table (limited to 100 rows)\n\n## Query Preprocessing\n\nThe server automatically handles:\n\n- ✅ Multi-line queries with proper newline handling\n- ✅ SQL comments (both `--` and `/* */` styles)\n- ✅ GO batch separators (executes first batch only with warning)\n- ✅ String literals with embedded newlines\n- ✅ Excessive whitespace cleanup\n\n## Error Handling\n\nThe server provides detailed error messages for:\n\n- Connection failures\n- Authentication errors\n- SQL syntax errors\n- Query execution errors\n- Invalid configurations\n\n## Security Considerations\n\n1. **Credentials**: Use environment variables or secure credential stores. Never hardcode credentials.\n2. **Permissions**: Use database users with minimal required permissions.\n3. **Connection Encryption**: Enable `MSSQL_ENCRYPT` for production environments.\n4. **Certificate Validation**: Set `MSSQL_TRUST_SERVER_CERTIFICATE=no` for production.\n5. **Query Validation**: The server executes queries as-is. Ensure proper access controls at the database level.\n\n## Development\n\n### Running Tests\n```bash\npip install -e \".[dev]\"\npytest\n```\n\n### Code Formatting\n```bash\nblack mssql_mcp_server\nflake8 mssql_mcp_server\nmypy mssql_mcp_server\n```\n\n## Troubleshooting\n\n### Connection Issues\n\n1. **\"ODBC Driver X for SQL Server not found\"**\n   - Install the ODBC driver (see Prerequisites)\n   - Update `MSSQL_DRIVER` to match your installed driver\n\n2. **\"Login failed for user\"**\n   - Verify credentials\n   - Check if SQL authentication is enabled on the server\n   - For Azure SQL, ensure username includes server name: `user@server`\n\n3. **\"Cannot open server requested by the login\"**\n   - Verify server name/address\n   - Check firewall rules\n   - Ensure SQL Server is accepting TCP/IP connections\n\n### Query Issues\n\n1. **\"Incorrect syntax near 'GO'\"**\n   - The server handles GO statements by executing only the first batch\n   - Split multi-batch scripts into separate queries\n\n2. **Hanging queries**\n   - Check for unclosed transactions\n   - Verify query doesn't have syntax errors related to newlines\n   - Monitor query execution time with `MSSQL_CONNECTION_TIMEOUT`\n\n## Contributing\n\nContributions are welcome! Please:\n\n1. Fork the repository\n2. Create a feature branch\n3. Add tests for new functionality\n4. Ensure all tests pass\n5. Submit a pull request\n\n## License\n\nMIT License - see LICENSE file for details\n\n## Acknowledgments\n\n- Built on the [Model Context Protocol](https://github.com/anthropics/mcp)\n- Uses [pyodbc](https://github.com/mkleehammer/pyodbc) for database connectivity","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcombiz%2Fmssql-mcp-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcombiz%2Fmssql-mcp-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcombiz%2Fmssql-mcp-server/lists"}