MCP
by ajay-fitbit
Overview
Integrates Microsoft SQL Server databases with AI assistants (OpenAI, Claude Desktop) for natural language querying, automated database operations, and test suite generation.
Installation
python server.pyEnvironment Variables
- DB_SERVER
- DB_NAME
- DB_USER
- DB_PASSWORD
- OPENAI_API_KEY
Security Notes
CRITICAL VULNERABILITIES IDENTIFIED: 1. SQL Injection Vulnerabilities: - In `server.py:DatabaseService.execute_query`, parameter *keys* are directly substituted into the SQL query via `query.replace(f"@{key}", "?")`. If a malicious AI prompt or user input controls the `key` name, SQL injection is possible (e.g., `@{key}; DROP TABLE Users; --`). - Similarly, in `server.py:DatabaseService.execute_stored_procedure`, parameter *names* are concatenated into the `EXEC` statement (`@{key} = ?`). A malicious agent controlling `key` names could inject SQL. 2. Local File Inclusion (LFI): In `server.py:DatabaseService.generate_query_from_template`, arbitrary `template_file` names are used to read files from the file system. A malicious actor could specify paths to sensitive files (e.g., `/etc/passwd`, `.env` files, or other configuration) leading to information disclosure. 3. Insecure Communication: `httpx.Client(verify=False)` is explicitly used in `openai_client.py`, `server_client.py`, `direct_no_mcp.py`, `direct_database.py`, and `stored_proc_explorer.py` for OpenAI API communication. While intended as a workaround for corporate SSL environments, this bypasses critical SSL certificate verification, making communication vulnerable to Man-in-the-Middle (MITM) attacks and compromising the confidentiality and integrity of API keys and potentially sensitive query contexts. 4. Subprocess Execution: Multiple launcher scripts use `subprocess.run` to execute other Python scripts. While currently controlled within the repository, this pattern could introduce risks if arguments or script paths become controllable by untrusted input, especially in conjunction with the identified injection vulnerabilities. RECOMMENDATIONS: The identified vulnerabilities are critical. Running this code in a production environment or with untrusted input is NOT recommended without significant security hardening.
Similar Servers
mcp-mysql-server
Provides an MCP-compliant interface for AI models to securely interact with a MySQL database for CRUD operations, schema inspection, and performance analysis.
mssqlMCP
The SQL Server MCP (Model Context Protocol) Server enables AI assistants like GitHub Copilot within Visual Studio Code to interact with SQL Server databases, allowing for SQL query execution, detailed database metadata retrieval, and management of connections and security.
MsSqlMCP
Provides an MCP Server for SQL Server database schema inspection and safe, read-only query execution to AI clients.
mssql-mcp-server
Enterprise-grade Model Context Protocol server for Microsoft SQL Server, enabling AI tooling for schema discovery, data profiling, data operations, and administration in enterprise database workflows.