mysql_mcp_server icon indicating copy to clipboard operation
mysql_mcp_server copied to clipboard

doesn't work when mysql has empty password

Open aszenz opened this issue 8 months ago • 9 comments

{
    "servers": {
        "mysql": {
            "type": "stdio",
            "command": "uvx",
            "args": ["--from", "mysql-mcp-server", "mysql_mcp_server"],
            "env": {
                "MYSQL_HOST": "localhost",
                "MYSQL_PORT": "3306",
                "MYSQL_USER": "root",
                "MYSQL_PASSWORD": "",
                "MYSQL_DATABASE": "demo"
            }
        }
    }
}

throws this error:

2025-04-24 13:56:42.947 [info] Stopping server mysql
2025-04-24 13:56:42.972 [info] Starting server mysql
2025-04-24 13:56:42.973 [info] Connection state: Starting
2025-04-24 13:56:42.983 [info] Starting server from LocalProcess extension host
2025-04-24 13:56:42.997 [info] Connection state: Starting
2025-04-24 13:56:42.999 [info] Connection state: Running
2025-04-24 13:56:43.417 [warning] [server stderr] Starting MySQL MCP server with config:
2025-04-24 13:56:43.417 [warning] [server stderr] 2025-04-24 13:56:43,416 - mysql_mcp_server - ERROR - Missing required database configuration. Please check environment variables:
2025-04-24 13:56:43.417 [warning] [server stderr] 2025-04-24 13:56:43,416 - mysql_mcp_server - ERROR - MYSQL_USER, MYSQL_PASSWORD, and MYSQL_DATABASE are required
2025-04-24 13:56:43.418 [warning] [server stderr] Traceback (most recent call last):
2025-04-24 13:56:43.418 [warning] [server stderr]   File "/home/user/.cache/uv/archive-v0/MuFelgXXu_JOPxtihfv3s/bin/mysql_mcp_server", line 12, in <module>
2025-04-24 13:56:43.418 [warning] [server stderr]     sys.exit(main())
2025-04-24 13:56:43.418 [warning] [server stderr]              ^^^^^^
2025-04-24 13:56:43.418 [warning] [server stderr]   File "/home/user/.cache/uv/archive-v0/MuFelgXXu_JOPxtihfv3s/lib/python3.12/site-packages/mysql_mcp_server/__init__.py", line 6, in main
2025-04-24 13:56:43.418 [warning] [server stderr]     asyncio.run(server.main())
2025-04-24 13:56:43.418 [warning] [server stderr]   File "/nix/store/kjgslpdqchx1sm7a5h9xibi5rrqcqfnl-python3-3.12.8/lib/python3.12/asyncio/runners.py", line 194, in run
2025-04-24 13:56:43.419 [warning] [server stderr]     return runner.run(main)
2025-04-24 13:56:43.419 [warning] [server stderr]            ^^^^^^^^^^^^^^^^
2025-04-24 13:56:43.419 [warning] [server stderr]   File "/nix/store/kjgslpdqchx1sm7a5h9xibi5rrqcqfnl-python3-3.12.8/lib/python3.12/asyncio/runners.py", line 118, in run
2025-04-24 13:56:43.419 [warning] [server stderr]     return self._loop.run_until_complete(task)
2025-04-24 13:56:43.419 [warning] [server stderr]            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2025-04-24 13:56:43.419 [warning] [server stderr]   File "/nix/store/kjgslpdqchx1sm7a5h9xibi5rrqcqfnl-python3-3.12.8/lib/python3.12/asyncio/base_events.py", line 686, in run_until_complete
2025-04-24 13:56:43.419 [warning] [server stderr]     return future.result()
2025-04-24 13:56:43.420 [warning] [server stderr]            ^^^^^^^^^^^^^^^
2025-04-24 13:56:43.420 [warning] [server stderr]   File "/home/user/.cache/uv/archive-v0/MuFelgXXu_JOPxtihfv3s/lib/python3.12/site-packages/mysql_mcp_server/server.py", line 161, in main
2025-04-24 13:56:43.420 [warning] [server stderr]     config = get_db_config()
2025-04-24 13:56:43.420 [warning] [server stderr]              ^^^^^^^^^^^^^^^
2025-04-24 13:56:43.420 [warning] [server stderr]   File "/home/user/.cache/uv/archive-v0/MuFelgXXu_JOPxtihfv3s/lib/python3.12/site-packages/mysql_mcp_server/server.py", line 30, in get_db_config
2025-04-24 13:56:43.420 [warning] [server stderr]     raise ValueError("Missing required database configuration")
2025-04-24 13:56:43.420 [warning] [server stderr] ValueError: Missing required database configuration
2025-04-24 13:56:43.483 [info] Connection state: Error Process exited with code 1

aszenz avatar Apr 24 '25 11:04 aszenz

I have reproduced the issue.

arminzaugg avatar Apr 30 '25 14:04 arminzaugg

I have reproduced the issue.

I think it's a problem with the mysql python lib

aszenz avatar Apr 30 '25 14:04 aszenz

Hi @aszenz,

Thank you for pointing out this behavior and providing the detailed configuration.

We don't consider this a bug because having an empty password for a MySQL user is a deliberate configuration choice that can pose significant security risks. The mysql_mcp_server is designed to prioritize secure configurations by default, and an empty password does not align with this principle. While we understand that some users may choose to use empty passwords for testing or specific use cases, this is not a recommended practice for production environments, and we encourage users to configure strong authentication credentials.

We strongly recommend adding a password to your database for security purposes.

Best regards, @designcomputer

designcomputer avatar Apr 30 '25 15:04 designcomputer

@designcomputer I'm just testing the tool locally, there is no security issue in keeping the password as empty on a machine that cannot receive connections from outside

aszenz avatar Apr 30 '25 15:04 aszenz

@aszenz Are you logging on as root without a password by any chance?

designcomputer avatar Apr 30 '25 15:04 designcomputer

@aszenz Are you logging on as root without a password by any chance?

Yes indeed

aszenz avatar Apr 30 '25 16:04 aszenz

@aszenz The easiest thing to do, for now, is to create a separate user and password for MCP use.

designcomputer avatar Apr 30 '25 19:04 designcomputer

@aszenz The easiest thing to do, for now, is to create a separate user and password for MCP use.

Thanks I managed to work around it for now

aszenz avatar Apr 30 '25 19:04 aszenz

I believe the server should allow empty passwords for MySQL setups that don't require them.

Because MySQL allows empty passwords for a purpose.

For example, the project I'm involved in uses blank passwords in isolated safe environments, and that won't change to accommodate this particular MCP server implementation.

gorodulin avatar Jul 07 '25 12:07 gorodulin