{"id":26714446,"url":"https://github.com/benborla/mcp-server-mysql","last_synced_at":"2026-01-27T16:08:26.581Z","repository":{"id":267300617,"uuid":"900806525","full_name":"benborla/mcp-server-mysql","owner":"benborla","description":"A Model Context Protocol server that provides read-only access to MySQL databases. This server enables LLMs to inspect database schemas and execute read-only queries.","archived":false,"fork":false,"pushed_at":"2025-11-18T09:42:25.000Z","size":29842,"stargazers_count":918,"open_issues_count":24,"forks_count":264,"subscribers_count":10,"default_branch":"main","last_synced_at":"2025-11-18T11:23:51.968Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/benborla.png","metadata":{"files":{"readme":"README-MULTI-DB.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-12-09T14:02:55.000Z","updated_at":"2025-11-18T09:40:52.000Z","dependencies_parsed_at":"2024-12-09T15:35:52.932Z","dependency_job_id":"d3c2136b-9e97-4677-9093-163fd4f01188","html_url":"https://github.com/benborla/mcp-server-mysql","commit_stats":null,"previous_names":["benborla/mcp-server-mysql"],"tags_count":24,"template":false,"template_full_name":null,"purl":"pkg:github/benborla/mcp-server-mysql","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benborla%2Fmcp-server-mysql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benborla%2Fmcp-server-mysql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benborla%2Fmcp-server-mysql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benborla%2Fmcp-server-mysql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/benborla","download_url":"https://codeload.github.com/benborla/mcp-server-mysql/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benborla%2Fmcp-server-mysql/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28816557,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-27T12:25:15.069Z","status":"ssl_error","status_checked_at":"2026-01-27T12:25:05.297Z","response_time":168,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-03-27T13:40:08.539Z","updated_at":"2026-01-27T16:08:26.576Z","avatar_url":"https://github.com/benborla.png","language":"JavaScript","funding_links":[],"categories":["Databases","📚 Projects (1974 total)","Community Servers","MCP 服务器精选列表","پیاده‌سازی‌های سرور","APIs and HTTP Requests","Servers","カテゴリ","Mcp Server Directories \u0026 Lists","Data \u0026 Databases","Containerised MCP Servers","🌐 Web Development","Table of Contents","Databases (4)","MCP Servers \u0026 Protocol","🌐 Web, Network \u0026 Protocol","MCP Servers","JavaScript"],"sub_categories":["SQL Databases","MCP Servers","🗄️ 数据库交互","🗄️ \u003ca name=\"databases\"\u003e\u003c/a\u003eپایگاه‌های داده","Data \u0026 Databases","How to Submit","🗄️ \u003ca name=\"database--sql\"\u003e\u003c/a\u003eデータベース・SQL","Database \u0026 Storage","Databases"],"readme":"# Multi-DB Mode and Schema-Specific Permissions\n\nThis document describes the new multi-database mode and schema-specific permissions features added to the MCP-Server-MySQL.\n\n## Multi-DB Mode\n\nMCP-Server-MySQL now supports working with multiple databases simultaneously when no specific database is set in the configuration.\n\n### How to Enable Multi-DB Mode\n\nTo enable multi-DB mode, simply leave the `MYSQL_DB` environment variable empty:\n\n```json\n{\n  \"mcpServers\": {\n    \"mcp_server_mysql\": {\n      \"env\": {\n        \"MYSQL_HOST\": \"127.0.0.1\",\n        \"MYSQL_PORT\": \"3306\",\n        \"MYSQL_USER\": \"root\",\n        \"MYSQL_PASS\": \"your_password\",\n        \"MYSQL_DB\": \"\", // Empty to enable multi-DB mode\n        ...\n      }\n    }\n  }\n}\n```\n\n### Features in Multi-DB Mode\n\n1. **List All Databases**: In multi-DB mode, the server will list resources from all available databases when the LLM requests database schemas.\n\n2. **Query Any Database**: You can execute queries against any database to which the MySQL user has access.\n\n3. **Schema Qualification Required**: When working in multi-DB mode, you should use fully qualified table names with schema/database prefixes:\n\n   ```sql\n   -- Use fully qualified table names\n   SELECT * FROM database_name.table_name;\n   \n   -- Or use USE statements to switch between databases\n   USE database_name;\n   SELECT * FROM table_name;\n   ```\n\n4. **Automatic Read-Only Mode**: For safety, multi-DB mode enforces read-only operations by default. This can be customized using schema-specific permissions (see below).\n\n5. **Database Exploration**: You can explore databases using commands like:\n\n   ```sql\n   -- List all databases\n   SHOW DATABASES;\n   \n   -- List tables in a specific database\n   SHOW TABLES FROM database_name;\n   \n   -- Describe a table's structure\n   DESCRIBE database_name.table_name;\n   ```\n\n## Schema-Specific Permissions\n\nThis new feature allows fine-grained control over which operations are allowed on specific database schemas.\n\n### Available Permission Types\n\n1. **INSERT Permissions**: Control which schemas can have new records inserted.\n2. **UPDATE Permissions**: Control which schemas can have records updated.\n3. **DELETE Permissions**: Control which schemas can have records deleted.\n4. **DDL Permissions**: Control which schemas can have their structure modified (CREATE, ALTER, DROP, TRUNCATE).\n\n### How to Configure Schema-Specific Permissions\n\nSet the following environment variables with a comma-separated list of schema:permission pairs:\n\n```txt\nSCHEMA_INSERT_PERMISSIONS=production:false,development:true,test:true\nSCHEMA_UPDATE_PERMISSIONS=production:false,development:true,test:true\nSCHEMA_DELETE_PERMISSIONS=production:false,development:false,test:true\nSCHEMA_DDL_PERMISSIONS=production:false,development:false,test:true\n```\n\nThis configuration:\n\n- Allows INSERT and UPDATE on development and test databases, but not production\n- Allows DELETE and DDL operations only on the test database\n- Blocks all write operations on the production database\n\n### Example Configuration\n\nHere's a complete example configuration with schema-specific permissions:\n\n```json\n{\n  \"mcpServers\": {\n    \"mcp_server_mysql\": {\n      \"command\": \"npx\",\n      \"args\": [\"-y\", \"@benborla29/mcp-server-mysql\"],\n      \"env\": {\n        \"MYSQL_HOST\": \"127.0.0.1\",\n        \"MYSQL_PORT\": \"3306\",\n        \"MYSQL_USER\": \"root\",\n        \"MYSQL_PASS\": \"your_password\",\n        \"MYSQL_DB\": \"\", // Empty for multi-DB mode\n        \n        // Global defaults (apply when no schema-specific permission is set)\n        \"ALLOW_INSERT_OPERATION\": \"false\",\n        \"ALLOW_UPDATE_OPERATION\": \"false\",\n        \"ALLOW_DELETE_OPERATION\": \"false\",\n        \"ALLOW_DDL_OPERATION\": \"false\",\n        \n        // Schema-specific permissions\n        \"SCHEMA_INSERT_PERMISSIONS\": \"dev_db:true,test_db:true,prod_db:false\",\n        \"SCHEMA_UPDATE_PERMISSIONS\": \"dev_db:true,test_db:true,prod_db:false\",\n        \"SCHEMA_DELETE_PERMISSIONS\": \"dev_db:false,test_db:true,prod_db:false\",\n        \"SCHEMA_DDL_PERMISSIONS\": \"dev_db:false,test_db:true,prod_db:false\"\n      }\n    }\n  }\n}\n```\n\n### Permission Resolution Logic\n\n1. If a schema-specific permission is set, it takes precedence over the global setting.\n2. If no schema-specific permission is found, the global setting (`ALLOW_X_OPERATION`) is used.\n3. In multi-DB mode, if a query doesn't specify a schema and one can't be determined from context, only read operations are allowed for safety.\n\n## Environment Variables Summary\n\n### Multi-DB Mode\n\n- `MYSQL_DB`: Leave empty to enable multi-DB mode\n- `MULTI_DB_WRITE_MODE`: Set to \"true\" to allow write operations in multi-DB mode without schema-specific permissions (not recommended for security)\n\n### Schema-Specific Permissions\n\n- `SCHEMA_INSERT_PERMISSIONS`: Control INSERT permissions per schema\n- `SCHEMA_UPDATE_PERMISSIONS`: Control UPDATE permissions per schema\n- `SCHEMA_DELETE_PERMISSIONS`: Control DELETE permissions per schema\n- `SCHEMA_DDL_PERMISSIONS`: Control DDL permissions per schema (CREATE, ALTER, DROP, TRUNCATE)\n\n### Global Permission Defaults\n\n- `ALLOW_INSERT_OPERATION`: Global default for INSERT permissions\n- `ALLOW_UPDATE_OPERATION`: Global default for UPDATE permissions\n- `ALLOW_DELETE_OPERATION`: Global default for DELETE permissions\n- `ALLOW_DDL_OPERATION`: Global default for DDL permissions\n\n## Security Considerations\n\n1. **Default to Principle of Least Privilege**: By default, all write operations are disabled globally and must be explicitly enabled.\n\n2. **Isolation in Multi-DB Mode**: Consider using a dedicated MySQL user with limited database grants when using multi-DB mode.\n\n3. **Careful with DDL Permissions**: DDL operations can modify database structure, so grant these permissions cautiously.\n\n4. **Production Databases**: Always set `schema:false` for production database schemas in all write permission settings.\n\n5. **User Least Privilege**: Ensure the MySQL user only has the required permissions on the specific databases needed.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenborla%2Fmcp-server-mysql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbenborla%2Fmcp-server-mysql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenborla%2Fmcp-server-mysql/lists"}