home / mcp / mysql query server
A MySQL query server built on the MCP framework enabling real-time data access via SSE with security, logging, and isolation features.
Configuration
View docs{
"mcpServers": {
"mangooer-mysql-mcp-server-sse": {
"command": "python",
"args": [
"-m",
"src.server"
],
"env": {
"HOST": "0.0.0.0",
"PORT": "3000",
"ENV_TYPE": "development",
"LOG_LEVEL": "DEBUG",
"MYSQL_HOST": "localhost",
"MYSQL_PORT": "3306",
"MYSQL_USER": "root",
"DB_AUTH_PLUGIN": "mysql_native_password",
"MAX_SQL_LENGTH": "5000",
"MYSQL_DATABASE": "mydb",
"MYSQL_PASSWORD": "your_password",
"DB_POOL_ENABLED": "true",
"DB_POOL_RECYCLE": "300",
"BLOCKED_PATTERNS": "<BLOCKED_PATTERNS>",
"DB_POOL_MAX_SIZE": "20",
"DB_POOL_MIN_SIZE": "5",
"ENABLE_QUERY_CHECK": "true",
"ALLOWED_RISK_LEVELS": "LOW,MEDIUM",
"ALLOW_SENSITIVE_INFO": "false",
"DB_POOL_MAX_LIFETIME": "0",
"DATABASE_ACCESS_LEVEL": "permissive",
"DB_CONNECTION_TIMEOUT": "5",
"SENSITIVE_INFO_FIELDS": "password,token",
"DB_POOL_ACQUIRE_TIMEOUT": "10",
"ENABLE_DATABASE_ISOLATION": "false"
}
}
}
}You can run a secure MySQL query service based on the MCP framework that exposes real-time data operations via SSE. It handles high-concurrency access, protects sensitive information, and provides structured metadata and robust logging for development, testing, and production uses.
Connect to the server using an MCP client configured to the server’s runtime. You will access the SSE endpoint documented in the runtime you start, then issue supported MySQL metadata, schema, and query operations through the MCP API. The server enforces security policies, including database isolation, risk-level checks, and sensitive-info masking, so your client should request only the allowed operations for the current environment.
If you enable database isolation in production, expect cross-database access protections to block unsupported cross-database queries. Use the provided environment variables to tailor access levels and risk allowances for your environment.
Prerequisites: you need Python and a suitable environment to run the server entry point, along with access to a MySQL instance you will query.
pip install -r requirements.txtPrepare environment variables by copying the example and adjusting values for your setup.
cp .env.example .envStart the server in stdio mode using Python. The command assumes you are in the project root and the source entry point is located at src.server.
python -m src.serverConfiguration covers host, port, and MySQL connection details, plus a comprehensive set of security and logging options. The environment variables you configure control connection pooling, allowed risk levels, and database isolation behavior.
Key environment variables you will typically set include HOST, PORT, MYSQL_HOST, MYSQL_PORT, MYSQL_USER, MYSQL_PASSWORD, MYSQL_DATABASE, DB_POOL_MIN_SIZE, DB_POOL_MAX_SIZE, ENABLE_QUERY_CHECK, ENABLE_DATABASE_ISOLATION, DATABASE_ACCESS_LEVEL, and LOG_LEVEL. The defaults are described in the provided configuration section.
The server implements multiple security layers including SQL risk levels, injection protection, and optional database isolation with three access levels: strict, restricted, and permissive. Production environments enable database isolation by default to prevent cross-database access.
Sensitive information can be masked automatically, and you can customize which fields are redacted through configuration.
Logging is configurable via LOG_LEVEL and includes console and file outputs. The server logs operational status, errors, and detailed resource management events to help you diagnose issues.
Execute basic queries against the connected MySQL databases and return results.
Retrieve metadata information such as databases, schemas, tables, and columns.
Fetch auxiliary information about the database server and connections.
Query structural details of databases, including table and column definitions.
Base class for all tooling components providing common utilities and interfaces.