### Development Setup and Testing Source: https://github.com/designcomputer/mysql_mcp_server/blob/main/README.md Steps to clone the repository, set up a virtual environment, install development dependencies, and run tests. ```bash # Clone the repository git clone https://github.com/designcomputer/mysql_mcp_server.git cd mysql_mcp_server # Create virtual environment python -m venv venv source venv/bin/activate # or `venv\Scripts\activate` on Windows # Install development dependencies pip install -r requirements-dev.txt # Run tests pytest ``` -------------------------------- ### Manual Installation Source: https://github.com/designcomputer/mysql_mcp_server/blob/main/README.md Installs the mysql-mcp-server package using pip. ```bash pip install mysql-mcp-server ``` -------------------------------- ### Installation via Smithery Source: https://github.com/designcomputer/mysql_mcp_server/blob/main/README.md Installs the mysql-mcp-server for Claude Desktop automatically using the Smithery CLI. ```bash npx -y @smithery/cli install mysql-mcp-server --client claude ``` -------------------------------- ### Debugging with MCP Inspector Source: https://github.com/designcomputer/mysql_mcp_server/blob/main/README.md Instructions for installing dependencies and using the MCP Inspector for debugging. Note: Do not run directly with Python. ```bash # Install dependencies pip install -r requirements.txt # Use the MCP Inspector for debugging (do not run directly with Python) ``` -------------------------------- ### MCP Server Environment Variables Source: https://github.com/designcomputer/mysql_mcp_server/blob/main/SECURITY.md Provides example environment variables for configuring the MCP server to connect to MySQL using the restricted user credentials. ```bash MYSQL_USER=mcp_user MYSQL_PASSWORD=your_secure_password MYSQL_DATABASE=your_database MYSQL_HOST=localhost ``` -------------------------------- ### Visual Studio Code Configuration Source: https://github.com/designcomputer/mysql_mcp_server/blob/main/README.md Configuration for integrating MySQL MCP Server with Visual Studio Code via mcp.json. ```json { "servers": { "mysql": { "type": "stdio", "command": "uvx", "args": [ "--from", "mysql-mcp-server", "mysql_mcp_server" ], "env": { "MYSQL_HOST": "localhost", "MYSQL_PORT": "3306", "MYSQL_USER": "your_username", "MYSQL_PASSWORD": "your_password", "MYSQL_DATABASE": "your_database" } } } } ``` -------------------------------- ### Environment Variables Configuration Source: https://github.com/designcomputer/mysql_mcp_server/blob/main/README.md Sets the necessary environment variables for connecting to the MySQL database. ```bash MYSQL_HOST=localhost MYSQL_PORT=3306 MYSQL_USER=your_username MYSQL_PASSWORD=your_password MYSQL_DATABASE=your_database ``` -------------------------------- ### Claude Desktop Configuration Source: https://github.com/designcomputer/mysql_mcp_server/blob/main/README.md Configuration for integrating MySQL MCP Server with Claude Desktop via mcpServers. ```json { "mcpServers": { "mysql": { "command": "uv", "args": [ "--directory", "path/to/mysql_mcp_server", "run", "mysql_mcp_server" ], "env": { "MYSQL_HOST": "localhost", "MYSQL_PORT": "3306", "MYSQL_USER": "your_username", "MYSQL_PASSWORD": "your_password", "MYSQL_DATABASE": "your_database" } } } } ``` -------------------------------- ### Set MySQL User Resource Limits Source: https://github.com/designcomputer/mysql_mcp_server/blob/main/SECURITY.md Illustrates how to configure resource limits for a MySQL user, such as maximum queries and updates per hour, to prevent abuse and manage server load. ```sql ALTER USER 'mcp_user'@'localhost' WITH MAX_QUERIES_PER_HOUR 1000 MAX_UPDATES_PER_HOUR 100; ``` -------------------------------- ### Create Restricted MySQL User Source: https://github.com/designcomputer/mysql_mcp_server/blob/main/SECURITY.md Demonstrates how to create a new MySQL user with a secure password, intended for limited access by the MCP server. It emphasizes using a dedicated user instead of root. ```sql -- Connect as root or administrator CREATE USER 'mcp_user'@'localhost' IDENTIFIED BY 'your_secure_password'; ``` -------------------------------- ### Apply MySQL Permissions Source: https://github.com/designcomputer/mysql_mcp_server/blob/main/SECURITY.md This command is essential after granting or revoking MySQL user privileges to ensure that the changes are immediately active and recognized by the server. ```sql FLUSH PRIVILEGES; ``` -------------------------------- ### Grant Column-Level MySQL Permissions Source: https://github.com/designcomputer/mysql_mcp_server/blob/main/SECURITY.md Shows how to implement granular data access control in MySQL by granting SELECT permissions only on specific columns of a sensitive table. ```sql GRANT SELECT (public_column1, public_column2) ON your_database.sensitive_table TO 'mcp_user'@'localhost'; ``` -------------------------------- ### Monitor MySQL User Activity Source: https://github.com/designcomputer/mysql_mcp_server/blob/main/SECURITY.md Includes SQL queries to monitor the activity of a specific MySQL user, such as checking current connections, viewing granted privileges, and inspecting resource limits. ```sql -- Check current connections SELECT * FROM information_schema.PROCESSLIST WHERE user = 'mcp_user'; ``` ```sql -- View user privileges SHOW GRANTS FOR 'mcp_user'@'localhost'; ``` ```sql -- Check resource limits SELECT * FROM mysql.user WHERE user = 'mcp_user' AND host = 'localhost'; ``` -------------------------------- ### Grant Minimal MySQL Permissions Source: https://github.com/designcomputer/mysql_mcp_server/blob/main/SECURITY.md Details different levels of permissions that can be granted to a MySQL user, ranging from read-only (SELECT) to data manipulation (INSERT, UPDATE, DELETE) and advanced operations (CREATE TEMPORARY TABLES). ```sql -- Grant SELECT permission only GRANT SELECT ON your_database.* TO 'mcp_user'@'localhost'; ``` ```sql -- Grant data manipulation permissions GRANT SELECT, INSERT, UPDATE, DELETE ON your_database.* TO 'mcp_user'@'localhost'; ``` ```sql -- Grant additional permissions for advanced operations GRANT SELECT, INSERT, UPDATE, DELETE, CREATE TEMPORARY TABLES ON your_database.* TO 'mcp_user'@'localhost'; ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.