mcp-mysql-connector
Interface with relational MySQL data stores for inspection and read-only data retrieval. Facilitates database introspection, schema review, and the execution of non-mutating SQL operations, enforced by stringent internal validation protocols against harmful commands.
Author

aqaranewbiz
Quick Info
Actions
Tags
Python-Based MySQL Interface for Smithery Environment
This component serves as a dedicated bridge for Smithery users to interact securely with backend MySQL database systems, implemented using Python.
Core Capabilities
- Database Access: Establish secure connectivity parameters for MySQL instances.
- Inventory Listing: Catalog all visible databases on the connected server.
- Table Enumeration: List the constituent tables within a selected database context.
- Structure Definition Retrieval: Fetch detailed structural metadata (schema) for specified tables.
- Query Execution: Run SQL instructions restricted exclusively to data retrieval and inspection (e.g., SELECT, SHOW, DESCRIBE, EXPLAIN).
- Safety Assurance: Comprehensive validation logic strictly prohibits any write, update, or schema modification commands.
Integration within Smithery
Upon configuring this MCP server instance in your Smithery workflow, you will be prompted to supply the following parameters to establish the connection:
- Hostname: The network address of the database server (Default:
localhost) - Port Number: The communication endpoint (Default:
3306) - Credentials: The designated database access username
- Secret: The corresponding authentication credential
- Target DB: (Optional) A specific database name to use as the initial context
Local Deployment Guide
-
Obtain the source code: bash git clone https://github.com/aqaralife/mysql-mcp-python-server.git
-
Fulfill required software packages: bash cd mysql-mcp-python-server npm install pip install -r requirements.txt
-
Set execution permissions (for Unix-like OSes): bash chmod +x mcp_server.py run.js
Manual Initiation
Start the service layer via Node or directly with Python: bash node run.js
Or: bash python mcp_server.py
Available Sub-Routines (Tools)
connect_db
Initiates the network pathway to the target MySQL server.
Arguments Required: - host: Server location identifier - port: Service port number - user: Authentication username - password: Authentication secret - database: (Optional) Initial database namespace
list_databases
Retrieves a comprehensive inventory of accessible database namespaces.
Arguments Required: None
list_tables
Retrieves a list of all relations (tables) within the specified or default database context.
Arguments Required: - database: (Optional) Contextual database name override
describe_table
Fetches the structural definition/metadata for a designated table.
Arguments Required: - table: The name of the relation to inspect - database: (Optional) Contextual database name override
execute_query
Runs a predetermined SQL instruction, strictly limited to read operations.
Arguments Required: - query: The SQL string. Note: Only SELECT, SHOW, DESCRIBE, EXPLAIN are permitted. - database: (Optional) Contextual database name override
Security Posture
This server enforces a robust security model preventing data modification:
- Only observation commands (SELECT, SHOW, DESCRIBE, EXPLAIN) are authorized.
- Commands implying persistence changes (INSERT, UPDATE, DELETE, DROP, etc.) are universally denied.
- Batch execution via semicolon delimiters within a single instruction is disabled.
Common Resolution Steps
If operational anomalies arise:
-
Python Interpreter Issue: The startup script attempts detection of
python3orpython. Ensure Python is correctly installed and accessible in the system PATH. -
Dependency Failure: The system attempts to auto-install necessary libraries. Should this fail, execute manually: bash pip install mysql-connector-python>=8.0.0
-
Connectivity Problems: Double-check server address, port, and user credentials. Confirm the MySQL daemon is active and reachable.
-
Smithery Linkage Errors: Review the configuration parameters within the Smithery application interface against actual database settings.
-
Service Unresponsiveness: Examine the output stream in the Smithery console logs for specific error messages generated by the backend process.
Licensing Information
MIT License
Support Channel
For inquiries or bug reporting, please initiate a new issue in the repository.
