MySQL Query Server
by MCP-Mirror
This is a MySQL query server based on the MCP framework, providing MySQL database operation capabilities through SSE (Server-Sent Events). It offers real-time data transmission and robust SQL security features.
Last updated: N/A
What is MySQL Query Server?
A MySQL query server built with the MCP framework that allows for database operations via Server-Sent Events (SSE). It provides real-time data transmission and a secure way to interact with a MySQL database.
How to use MySQL Query Server?
- Clone the repository. 2. Install dependencies using
pip install -r requirements.txt
. 3. Configure environment variables in the.env
file. 4. Start the server usingpython src/server.py
. Access the server at the configured address and port (default:http://127.0.0.1:3000/sse
).
Key features of MySQL Query Server
Based on FastMCP framework
Supports SSE (Server-Sent Events) for real-time data transmission
Provides MySQL database query interface
Complete logging system
Automatic transaction management (commit/rollback)
Environment variable configuration support
SQL security check mechanism
Use cases of MySQL Query Server
Real-time data dashboards
Monitoring database changes
Building interactive applications with live updates
Securely exposing database queries to clients
Providing a controlled interface for database modifications
FAQ from MySQL Query Server
DELETE operation not executing successfully?
DELETE operation not executing successfully?
Ensure the DELETE operation includes a WHERE clause. DELETE operations without a WHERE clause are marked as CRITICAL risk. Verify that ALLOWED_RISK_LEVELS includes CRITICAL (if needed). Check the affected rows return value to confirm the operation's impact.
Environment variables are not taking effect?
Environment variables are not taking effect?
Ensure load_dotenv() is called before importing other modules in server.py. Restart the application to ensure environment variables are loaded correctly. Check the logs for the "从环境变量读取到的风险等级设置" output.
Operation is rejected by the security mechanism?
Operation is rejected by the security mechanism?
Check if the operation's risk level is within the allowed range. Adjust ALLOWED_RISK_LEVELS accordingly if high-risk operations are required. For UPDATE or DELETE without WHERE, add a condition (even WHERE 1=1) to lower the risk level.
What are the system requirements?
What are the system requirements?
The server requires Python 3.6+ and a MySQL server.
What is the purpose of the SQL security mechanism?
What is the purpose of the SQL security mechanism?
The SQL security mechanism is designed to prevent SQL injection attacks, control the risk level of SQL operations, and ensure that database modifications are performed safely and intentionally.