- ✅ Claude Code Integration - Optimized for use with Anthropic's Claude Code CLI - ✅ SSH Tunnel Support - Built-in support for SSH tunnels to remote databases - ✅ Auto-start/stop Hooks - Automatic tunnel management with Claude start/stop - ✅ DDL Operations - Added MYSQLDISABLEREADONLYTRANSACTIONS for CREATE TABLE support - ✅ Multi-Project Setup - Easy configuration for multiple projects with diffe
Add this skill
npx mdskills install benborla/mcp-server-mysqlComprehensive MySQL MCP server with SSH tunnel support and excellent multi-installation docs
1# MCP Server for MySQL - Claude Code Edition23> **🚀 This is a modified version optimized for Claude Code with SSH tunnel support**4> **Original Author:** [@benborla29](https://github.com/benborla)5> **Original Repository:** [https://github.com/benborla/mcp-server-mysql](https://github.com/benborla/mcp-server-mysql)6> **License:** MIT78## MCP Server for MySQL based on NodeJS910[](https://archestra.ai/mcp-catalog/benborla__mcp-server-mysql)1112### Key Features of This Fork1314- ✅ **Claude Code Integration** - Optimized for use with Anthropic's Claude Code CLI15- ✅ **SSH Tunnel Support** - Built-in support for SSH tunnels to remote databases16- ✅ **Auto-start/stop Hooks** - Automatic tunnel management with Claude start/stop17- ✅ **DDL Operations** - Added `MYSQL_DISABLE_READ_ONLY_TRANSACTIONS` for CREATE TABLE support18- ✅ **Multi-Project Setup** - Easy configuration for multiple projects with different databases1920### Quick Start for Claude Code Users21221. **Read the Setup Guide**: See [PROJECT_SETUP_GUIDE.md](PROJECT_SETUP_GUIDE.md) for detailed instructions232. **Configure SSH Tunnels**: Set up automatic SSH tunnels for remote databases243. **Use with Claude**: Integrated MCP server works seamlessly with Claude Code2526A Model Context Protocol server that provides access to MySQL databases through SSH tunnels. This server enables Claude and other LLMs to inspect database schemas and execute SQL queries securely.2728## Table of Contents2930- [Requirements](#requirements)31- [Installation](#installation)32 - [Smithery](#using-smithery)33 - [Clone to Local Repository](#running-from-local-repository)34 - [Remote mode](#run-in-remote-mode)35- [Components](#components)36- [Configuration](#configuration)37- [Environment Variables](#environment-variables)38- [Multi-DB Mode](#multi-db-mode)39- [Schema-Specific Permissions](#schema-specific-permissions)40- [Testing](#testing)41- [Troubleshooting](#troubleshooting)42- [Contributing](#contributing)43- [License](#license)4445## Requirements4647- Node.js v20 or higher48- MySQL 5.7 or higher (MySQL 8.0+ recommended)49- MySQL user with appropriate permissions for the operations you need50- For write operations: MySQL user with INSERT, UPDATE, and/or DELETE privileges5152## Installation5354### Using Smithery5556There are several ways to install and configure the MCP server but the most common would be checking this website [https://smithery.ai/server/@benborla29/mcp-server-mysql](https://smithery.ai/server/@benborla29/mcp-server-mysql)5758### Cursor5960For Cursor IDE, you can install this MCP server with the following command in your project:61621. Visit [https://smithery.ai/server/@benborla29/mcp-server-mysql](https://smithery.ai/server/@benborla29/mcp-server-mysql)632. Follow the instruction for Cursor6465MCP Get provides a centralized registry of MCP servers and simplifies the installation process.6667### Codex CLI6869Codex CLI installation is similar to Claude Code below7071```bash72codex mcp add mcp_server_mysql \73 --env MYSQL_HOST="127.0.0.1" \74 --env MYSQL_PORT="3306" \75 --env MYSQL_USER="root" \76 --env MYSQL_PASS="your_password" \77 --env MYSQL_DB="your_database" \78 --env ALLOW_INSERT_OPERATION="false" \79 --env ALLOW_UPDATE_OPERATION="false" \80 --env ALLOW_DELETE_OPERATION="false" \81 -- npx -y @benborla29/mcp-server-mysql82```8384### Claude Code8586#### Option 1: Import from Claude Desktop (Recommended if already configured)8788If you already have this MCP server configured in Claude Desktop, you can import it automatically:8990```bash91claude mcp add-from-claude-desktop92```9394This will show an interactive dialog where you can select your `mcp_server_mysql` server to import with all existing configuration.9596#### Option 2: Manual Configuration9798**Using NPM/PNPM Global Installation:**99100First, install the package globally:101102```bash103# Using npm104npm install -g @benborla29/mcp-server-mysql105106# Using pnpm107pnpm add -g @benborla29/mcp-server-mysql108```109110Then add the server to Claude Code:111112```bash113claude mcp add mcp_server_mysql \114 -e MYSQL_HOST="127.0.0.1" \115 -e MYSQL_PORT="3306" \116 -e MYSQL_USER="root" \117 -e MYSQL_PASS="your_password" \118 -e MYSQL_DB="your_database" \119 -e ALLOW_INSERT_OPERATION="false" \120 -e ALLOW_UPDATE_OPERATION="false" \121 -e ALLOW_DELETE_OPERATION="false" \122 -- npx @benborla29/mcp-server-mysql123```124125**Using Local Repository (for development):**126127If you're running from a cloned repository:128129```bash130claude mcp add mcp_server_mysql \131 -e MYSQL_HOST="127.0.0.1" \132 -e MYSQL_PORT="3306" \133 -e MYSQL_USER="root" \134 -e MYSQL_PASS="your_password" \135 -e MYSQL_DB="your_database" \136 -e ALLOW_INSERT_OPERATION="false" \137 -e ALLOW_UPDATE_OPERATION="false" \138 -e ALLOW_DELETE_OPERATION="false" \139 -e PATH="/path/to/node/bin:/usr/bin:/bin" \140 -e NODE_PATH="/path/to/node/lib/node_modules" \141 -- /path/to/node /full/path/to/mcp-server-mysql/dist/index.js142```143144Replace:145146- `/path/to/node` with your Node.js binary path (find with `which node`)147- `/full/path/to/mcp-server-mysql` with the full path to your cloned repository148- Update MySQL credentials to match your environment149150**Using Unix Socket Connection:**151152For local MySQL instances using Unix sockets:153154```bash155claude mcp add mcp_server_mysql \156 -e MYSQL_SOCKET_PATH="/tmp/mysql.sock" \157 -e MYSQL_USER="root" \158 -e MYSQL_PASS="your_password" \159 -e MYSQL_DB="your_database" \160 -e ALLOW_INSERT_OPERATION="false" \161 -e ALLOW_UPDATE_OPERATION="false" \162 -e ALLOW_DELETE_OPERATION="false" \163 -- npx @benborla29/mcp-server-mysql164```165166#### Choosing the Right Scope167168Consider which scope to use based on your needs:169170```bash171# Local scope (default) - only available in current project172claude mcp add mcp_server_mysql [options...]173174# User scope - available across all your projects175claude mcp add mcp_server_mysql -s user [options...]176177# Project scope - shared with team members via .mcp.json178claude mcp add mcp_server_mysql -s project [options...]179```180181For database servers with credentials, **local** or **user** scope is recommended to keep credentials private.182183#### Verification184185After adding the server, verify it's configured correctly:186187```bash188# List all configured servers189claude mcp list190191# Get details for your MySQL server192claude mcp get mcp_server_mysql193194# Check server status within Claude Code195/mcp196```197198#### Multi-Database Configuration199200For multi-database mode, omit the `MYSQL_DB` environment variable:201202```bash203claude mcp add mcp_server_mysql_multi \204 -e MYSQL_HOST="127.0.0.1" \205 -e MYSQL_PORT="3306" \206 -e MYSQL_USER="root" \207 -e MYSQL_PASS="your_password" \208 -e MULTI_DB_WRITE_MODE="false" \209 -- npx @benborla29/mcp-server-mysql210```211212#### Advanced Configuration213214For advanced features, add additional environment variables:215216```bash217claude mcp add mcp_server_mysql \218 -e MYSQL_HOST="127.0.0.1" \219 -e MYSQL_PORT="3306" \220 -e MYSQL_USER="root" \221 -e MYSQL_PASS="your_password" \222 -e MYSQL_DB="your_database" \223 -e MYSQL_POOL_SIZE="10" \224 -e MYSQL_QUERY_TIMEOUT="30000" \225 -e MYSQL_CACHE_TTL="60000" \226 -e MYSQL_RATE_LIMIT="100" \227 -e MYSQL_SSL="true" \228 -e ALLOW_INSERT_OPERATION="false" \229 -e ALLOW_UPDATE_OPERATION="false" \230 -e ALLOW_DELETE_OPERATION="false" \231 -e MYSQL_ENABLE_LOGGING="true" \232 -- npx @benborla29/mcp-server-mysql233```234235#### Troubleshooting Claude Code Setup2362371. **Server Connection Issues**: Use `/mcp` command in Claude Code to check server status and authenticate if needed.2382392. **Path Issues**: If using a local repository, ensure Node.js paths are correctly set:240241 ```bash242 # Find your Node.js path243 which node244245 # For PATH environment variable246 echo "$(which node)/../"247248 # For NODE_PATH environment variable249 echo "$(which node)/../../lib/node_modules"250 ```2512523. **Permission Errors**: Ensure your MySQL user has appropriate permissions for the operations you've enabled.2532544. **Server Not Starting**: Check Claude Code logs or run the server directly to debug:255256 ```bash257 # Test the server directly258 npx @benborla29/mcp-server-mysql259 ```260261### Using NPM/PNPM262263For manual installation:264265```bash266# Using npm267npm install -g @benborla29/mcp-server-mysql268269# Using pnpm270pnpm add -g @benborla29/mcp-server-mysql271```272273After manual installation, you'll need to configure your LLM application to use the MCP server (see Configuration section below).274275### Running from Local Repository276277If you want to clone and run this MCP server directly from the source code, follow these steps:2782791. **Clone the repository**280281 ```bash282 git clone https://github.com/benborla/mcp-server-mysql.git283 cd mcp-server-mysql284 ```2852862. **Install dependencies**287288 ```bash289 npm install290 # or291 pnpm install292 ```2932943. **Build the project**295296 ```bash297 npm run build298 # or299 pnpm run build300 ```3013024. **Configure Claude Desktop**303304 Add the following to your Claude Desktop configuration file (`claude_desktop_config.json`):305306 ```json307 {308 "mcpServers": {309 "mcp_server_mysql": {310 "command": "/path/to/node",311 "args": [312 "/full/path/to/mcp-server-mysql/dist/index.js"313 ],314 "env": {315 "MYSQL_HOST": "127.0.0.1",316 "MYSQL_PORT": "3306",317 "MYSQL_USER": "root",318 "MYSQL_PASS": "your_password",319 "MYSQL_DB": "your_database",320 "ALLOW_INSERT_OPERATION": "false",321 "ALLOW_UPDATE_OPERATION": "false",322 "ALLOW_DELETE_OPERATION": "false",323 "PATH": "/path/to/node/bin:/usr/bin:/bin", // <--- Important to add the following, run in your terminal `echo "$(which node)/../"` to get the path324 "NODE_PATH": "/path/to/node/lib/node_modules" // <--- Important to add the following, run in your terminal `echo "$(which node)/../../lib/node_modules"`325 }326 }327 }328 }329 ```330331 Replace:332 - `/path/to/node` with the full path to your Node.js binary (find it with `which node`)333 - `/full/path/to/mcp-server-mysql` with the full path to where you cloned the repository334 - Set the MySQL credentials to match your environment3353365. **Test the server**337338 ```bash339 # Run the server directly to test340 node dist/index.js341 ```342343 If it connects to MySQL successfully, you're ready to use it with Claude Desktop.344345### Run in remote mode346347To run in remote mode, you'll need to provide [environment variables](https://github.com/benborla/mcp-server-mysql?tab=readme-ov-file#environment-variables) to the npx script.3483491. Create env file in preferred directory350351 ```bash352 # create .env file353 touch .env354 ```3553562. Copy-paste [example file](https://github.com/benborla/mcp-server-mysql/blob/main/.env) from this repository3573. Set the MySQL credentials to match your environment3584. Set `IS_REMOTE_MCP=true`3595. Set `REMOTE_SECRET_KEY` to a secure string.3606. Provide custom `PORT` if needed. Default is 3000.3617. Load variables in current session:362363 ```bash364 source .env365 ```3663678. Run the server368369 ```bash370 npx @benborla29/mcp-server-mysql371 ```3723739. Configure your agent to connect to the MCP with the next configuration:374375 ```json376 {377 "mcpServers": {378 "mysql": {379 "url": "http://your-host:3000/mcp",380 "type": "streamableHttp",381 "headers": {382 "Authorization": "Bearer <REMOTE_SECRET_KEY>"383 }384 }385 }386 }387 ```388389## Components390391### Tools392393- **mysql_query**394 - Execute SQL queries against the connected database395 - Input: `sql` (string): The SQL query to execute396 - By default, limited to READ ONLY operations397 - Optional write operations (when enabled via configuration):398 - INSERT: Add new data to tables (requires `ALLOW_INSERT_OPERATION=true`)399 - UPDATE: Modify existing data (requires `ALLOW_UPDATE_OPERATION=true`)400 - DELETE: Remove data (requires `ALLOW_DELETE_OPERATION=true`)401 - All operations are executed within a transaction with proper commit/rollback handling402 - Supports prepared statements for secure parameter handling403 - Configurable query timeouts and result pagination404 - Built-in query execution statistics405406### Resources407408The server provides comprehensive database information:409410- **Table Schemas**411 - JSON schema information for each table412 - Column names and data types413 - Index information and constraints414 - Foreign key relationships415 - Table statistics and metrics416 - Automatically discovered from database metadata417418### Security Features419420- SQL injection prevention through prepared statements421- Query whitelisting/blacklisting capabilities422- Rate limiting for query execution423- Query complexity analysis424- Configurable connection encryption425- Read-only transaction enforcement426427### Performance Optimizations428429- Optimized connection pooling430- Query result caching431- Large result set streaming432- Query execution plan analysis433- Configurable query timeouts434435### Monitoring and Debugging436437- Comprehensive query logging438- Performance metrics collection439- Error tracking and reporting440- Health check endpoints441- Query execution statistics442443## Configuration444445### Automatic Configuration with Smithery446447If you installed using Smithery, your configuration is already set up. You can view or modify it with:448449```bash450smithery configure @benborla29/mcp-server-mysql451```452453When reconfiguring, you can update any of the MySQL connection details as well as the write operation settings:454455- **Basic connection settings**:456 - MySQL Host, Port, User, Password, Database457 - SSL/TLS configuration (if your database requires secure connections)458459- **Write operation permissions**:460 - Allow INSERT Operations: Set to true if you want to allow adding new data461 - Allow UPDATE Operations: Set to true if you want to allow updating existing data462 - Allow DELETE Operations: Set to true if you want to allow deleting data463464For security reasons, all write operations are disabled by default. Only enable these settings if you specifically need Claude to modify your database data.465466### Advanced Configuration Options467468For more control over the MCP server's behavior, you can use these advanced configuration options:469470```json471{472 "mcpServers": {473 "mcp_server_mysql": {474 "command": "/path/to/npx/binary/npx",475 "args": [476 "-y",477 "@benborla29/mcp-server-mysql"478 ],479 "env": {480 // Basic connection settings481 "MYSQL_HOST": "127.0.0.1",482 "MYSQL_PORT": "3306",483 "MYSQL_USER": "root",484 "MYSQL_PASS": "",485 "MYSQL_DB": "db_name",486 "PATH": "/path/to/node/bin:/usr/bin:/bin",487488 // Performance settings489 "MYSQL_POOL_SIZE": "10",490 "MYSQL_QUERY_TIMEOUT": "30000",491 "MYSQL_CACHE_TTL": "60000",492493 // Security settings494 "MYSQL_RATE_LIMIT": "100",495 "MYSQL_MAX_QUERY_COMPLEXITY": "1000",496 "MYSQL_SSL": "true",497498 // Monitoring settings499 "ENABLE_LOGGING": "true",500 "MYSQL_LOG_LEVEL": "info",501 "MYSQL_METRICS_ENABLED": "true",502503 // Write operation flags504 "ALLOW_INSERT_OPERATION": "false",505 "ALLOW_UPDATE_OPERATION": "false",506 "ALLOW_DELETE_OPERATION": "false"507 }508 }509 }510}511```512513## Environment Variables514515### Basic Connection516517- `MYSQL_SOCKET_PATH`: Unix socket path for local connections (e.g., "/tmp/mysql.sock")518- `MYSQL_HOST`: MySQL server host (default: "127.0.0.1") - ignored if MYSQL_SOCKET_PATH is set519- `MYSQL_PORT`: MySQL server port (default: "3306") - ignored if MYSQL_SOCKET_PATH is set520- `MYSQL_USER`: MySQL username (default: "root")521- `MYSQL_PASS`: MySQL password522- `MYSQL_DB`: Target database name (leave empty for multi-DB mode)523524#### Alternative: Connection String525526For scenarios requiring frequent credential rotation or temporary connections, you can use a MySQL connection string instead of individual environment variables:527528- `MYSQL_CONNECTION_STRING`: MySQL CLI-format connection string (e.g., `mysql --default-auth=mysql_native_password -A -hHOST -PPORT -uUSER -pPASS database_name`)529530When `MYSQL_CONNECTION_STRING` is provided, it takes precedence over individual connection settings. This is particularly useful for:531532- Rotating credentials that expire frequently533- Temporary database connections534- Quick testing with different database configurations535536**Note:** For security, this should only be set via environment variables, not stored in version-controlled configuration files. Consider using the `prompt` input type in Claude Code's MCP configuration for credentials that expire.537538### Performance Configuration539540- `MYSQL_POOL_SIZE`: Connection pool size (default: "10")541- `MYSQL_QUERY_TIMEOUT`: Query timeout in milliseconds (default: "30000")542- `MYSQL_CACHE_TTL`: Cache time-to-live in milliseconds (default: "60000")543- `MYSQL_QUEUE_LIMIT`: Maximum number of queued connection requests (default: "100")544- `MYSQL_CONNECT_TIMEOUT`: Connection timeout in milliseconds (default: "10000")545546### Security Configuration547548- `MYSQL_RATE_LIMIT`: Maximum queries per minute (default: "100")549- `MYSQL_MAX_QUERY_COMPLEXITY`: Maximum query complexity score (default: "1000")550- `MYSQL_SSL`: Enable SSL/TLS encryption (default: "false")551- `ALLOW_INSERT_OPERATION`: Enable INSERT operations (default: "false")552- `ALLOW_UPDATE_OPERATION`: Enable UPDATE operations (default: "false")553- `ALLOW_DELETE_OPERATION`: Enable DELETE operations (default: "false")554- `ALLOW_DDL_OPERATION`: Enable DDL operations (default: "false")555- `MYSQL_DISABLE_READ_ONLY_TRANSACTIONS`: **[NEW]** Disable read-only transaction enforcement (default: "false") ⚠️ **Security Warning:** Only enable this if you need full write capabilities and trust the LLM with your database556- `SCHEMA_INSERT_PERMISSIONS`: Schema-specific INSERT permissions557- `SCHEMA_UPDATE_PERMISSIONS`: Schema-specific UPDATE permissions558- `SCHEMA_DELETE_PERMISSIONS`: Schema-specific DELETE permissions559- `SCHEMA_DDL_PERMISSIONS`: Schema-specific DDL permissions560- `MULTI_DB_WRITE_MODE`: Enable write operations in multi-DB mode (default: "false")561562### Timezone and Date Configuration563564- `MYSQL_TIMEZONE`: Set the timezone for date/time values. Accepts formats like `+08:00` (UTC+8), `-05:00` (UTC-5), `Z` (UTC), or `local` (system timezone). Useful for ensuring consistent date/time handling across different server locations.565- `MYSQL_DATE_STRINGS`: When set to `"true"`, returns date/datetime values as strings instead of JavaScript Date objects. This preserves the exact database values without any timezone conversion, which is particularly useful for:566 - Applications that need precise control over date formatting567 - Cross-timezone database operations568 - Avoiding JavaScript Date timezone quirks569570### Monitoring Configuration571572- `MYSQL_ENABLE_LOGGING`: Enable query logging (default: "false")573- `MYSQL_LOG_LEVEL`: Logging level (default: "info")574- `MYSQL_METRICS_ENABLED`: Enable performance metrics (default: "false")575576### Remote MCP Configuration577578- `IS_REMOTE_MCP`: Enable remote MCP mode (default: "false")579- `REMOTE_SECRET_KEY`: Secret key for remote MCP authentication (default: ""). If not provided, remote MCP mode will be disabled.580- `PORT`: Port number for the remote MCP server (default: 3000)581582## Multi-DB Mode583584MCP-Server-MySQL supports connecting to multiple databases when no specific database is set. This allows the LLM to query any database the MySQL user has access to. For full details, see [README-MULTI-DB.md](./README-MULTI-DB.md).585586### Enabling Multi-DB Mode587588To enable multi-DB mode, simply leave the `MYSQL_DB` environment variable empty. In multi-DB mode, queries require schema qualification:589590```sql591-- Use fully qualified table names592SELECT * FROM database_name.table_name;593594-- Or use USE statements to switch between databases595USE database_name;596SELECT * FROM table_name;597```598599## Schema-Specific Permissions600601For fine-grained control over database operations, MCP-Server-MySQL now supports schema-specific permissions. This allows different databases to have different levels of access (read-only, read-write, etc.).602603### Configuration Example604605```txt606SCHEMA_INSERT_PERMISSIONS=development:true,test:true,production:false607SCHEMA_UPDATE_PERMISSIONS=development:true,test:true,production:false608SCHEMA_DELETE_PERMISSIONS=development:false,test:true,production:false609SCHEMA_DDL_PERMISSIONS=development:false,test:true,production:false610```611612For complete details and security recommendations, see [README-MULTI-DB.md](./README-MULTI-DB.md).613614## Testing615616### Database Setup617618Before running tests, you need to set up the test database and seed it with test data:6196201. **Create Test Database and User**621622 ```sql623 -- Connect as root and create test database624 CREATE DATABASE IF NOT EXISTS mcp_test;625626 -- Create test user with appropriate permissions627 CREATE USER IF NOT EXISTS 'mcp_test'@'localhost' IDENTIFIED BY 'mcp_test_password';628 GRANT ALL PRIVILEGES ON mcp_test.* TO 'mcp_test'@'localhost';629 FLUSH PRIVILEGES;630 ```6316322. **Run Database Setup Script**633634 ```bash635 # Run the database setup script636 pnpm run setup:test:db637 ```638639 This will create the necessary tables and seed data. The script is located in `scripts/setup-test-db.ts`6406413. **Configure Test Environment**642 Create a `.env.test` file in the project root (if not existing):643644 ```env645 MYSQL_HOST=127.0.0.1646 MYSQL_PORT=3306647 MYSQL_USER=mcp_test648 MYSQL_PASS=mcp_test_password649 MYSQL_DB=mcp_test650 ```6516524. **Update package.json Scripts**653 Add these scripts to your package.json:654655 ```json656 {657 "scripts": {658 "setup:test:db": "ts-node scripts/setup-test-db.ts",659 "pretest": "pnpm run setup:test:db",660 "test": "vitest run",661 "test:watch": "vitest",662 "test:coverage": "vitest run --coverage"663 }664 }665 ```666667### Running Tests668669The project includes a comprehensive test suite to ensure functionality and reliability:670671```bash672# First-time setup673pnpm run setup:test:db674675# Run all tests676pnpm test677```678679## Running evals680681The evals package loads an mcp client that then runs the index.ts file, so there is no need to rebuild between tests. You can load environment variables by prefixing the npx command. Full documentation can be found at [MCP Evals](https://www.mcpevals.io/docs).682683```bash684OPENAI_API_KEY=your-key npx mcp-eval evals.ts index.ts685```686687## Troubleshooting688689### Common Issues6906911. **Connection Issues**692 - Verify MySQL server is running and accessible693 - Check credentials and permissions694 - Ensure SSL/TLS configuration is correct if enabled695 - Try connecting with a MySQL client to confirm access6966972. **Performance Issues**698 - Adjust connection pool size699 - Configure query timeout values700 - Enable query caching if needed701 - Check query complexity settings702 - Monitor server resource usage7037043. **Security Restrictions**705 - Review rate limiting configuration706 - Check query whitelist/blacklist settings707 - Verify SSL/TLS settings708 - Ensure the user has appropriate MySQL permissions7097104. **Path Resolution**711 If you encounter an error "Could not connect to MCP server mcp-server-mysql", explicitly set the path of all required binaries:712713 ```json714 {715 "env": {716 "PATH": "/path/to/node/bin:/usr/bin:/bin"717 }718 }719 ```720721 *Where can I find my `node` bin path*722 Run the following command to get it:723724 For **PATH**725726 ```bash727 echo "$(which node)/../"728 ```729730 For **NODE_PATH**731732 ```bash733 echo "$(which node)/../../lib/node_modules"734 ```7357365. **Claude Desktop Specific Issues**737 - If you see "Server disconnected" logs in Claude Desktop, check the logs at `~/Library/Logs/Claude/mcp-server-mcp_server_mysql.log`738 - Ensure you're using the absolute path to both the Node binary and the server script739 - Check if your `.env` file is being properly loaded; use explicit environment variables in the configuration740 - Try running the server directly from the command line to see if there are connection issues741 - If you need write operations (INSERT, UPDATE, DELETE), set the appropriate flags to "true" in your configuration:742743 ```json744 "env": {745 "ALLOW_INSERT_OPERATION": "true", // Enable INSERT operations746 "ALLOW_UPDATE_OPERATION": "true", // Enable UPDATE operations747 "ALLOW_DELETE_OPERATION": "true" // Enable DELETE operations748 }749 ```750751 - Ensure your MySQL user has the appropriate permissions for the operations you're enabling752 - For direct execution configuration, use:753754 ```json755 {756 "mcpServers": {757 "mcp_server_mysql": {758 "command": "/full/path/to/node",759 "args": [760 "/full/path/to/mcp-server-mysql/dist/index.js"761 ],762 "env": {763 "MYSQL_HOST": "127.0.0.1",764 "MYSQL_PORT": "3306",765 "MYSQL_USER": "root",766 "MYSQL_PASS": "your_password",767 "MYSQL_DB": "your_database"768 }769 }770 }771 }772 ```7737746. **Authentication Issues**775 - For MySQL 8.0+, ensure the server supports the `caching_sha2_password` authentication plugin776 - Check if your MySQL user is configured with the correct authentication method777 - Try creating a user with legacy authentication if needed:778779 ```sql780 CREATE USER 'user'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';781 ```782783 @lizhuangs7847857. I am encountering `Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'dotenv' imported from` error786 try this workaround:787788 ```bash789 npx -y -p @benborla29/mcp-server-mysql -p dotenv mcp-server-mysql790 ```791792 Thanks to @lizhuangs793794## Contributing795796Contributions are welcome! Please feel free to submit a Pull Request to797[https://github.com/benborla/mcp-server-mysql](https://github.com/benborla/mcp-server-mysql)798799## Many Thanks to the following Contributors800801[](https://github.com/benborla/mcp-server-mysql/graphs/contributors)802803### Development Setup8048051. Clone the repository8062. Install dependencies: `pnpm install`8073. Build the project: `pnpm run build`8084. Run tests: `pnpm test`809810### Project Roadmap811812We're actively working on enhancing this MCP server. Check our [CHANGELOG.md](./CHANGELOG.md) for details on planned features, including:813814- Enhanced query capabilities with prepared statements815- Advanced security features816- Performance optimizations817- Comprehensive monitoring818- Expanded schema information819820If you'd like to contribute to any of these areas, please check the issues on GitHub or open a new one to discuss your ideas.821822### Submitting Changes8238241. Fork the repository8252. Create a feature branch: `git checkout -b feature/your-feature-name`8263. Commit your changes: `git commit -am 'Add some feature'`8274. Push to the branch: `git push origin feature/your-feature-name`8285. Submit a pull request829830## License831832This MCP server is licensed under the MIT License. See the LICENSE file for details.833
Full transparency — inspect the skill content before installing.