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
jewei-mssql-mcp-server
Provides a Micro-Agent Protocol (MCP) server for querying Microsoft SQL Server databases and retrieving table structures.
MsSqlMCP
Provides an MCP Server for SQL Server database schema inspection and safe, read-only query execution to AI clients.
mssql-mcp-server
Provides an enterprise-grade Model Context Protocol server for Microsoft SQL Server, enabling schema discovery, data operations, profiling, and administration with strong governance controls.
mysql_mcp_server
This server provides a Model Context Protocol (MCP) interface to a MySQL database, enabling AI models to execute SQL queries and retrieve database schema information.