MCP Directory

How to add MySQL MCP Server to Windsurf

Secure, structured access to MySQL databases for AI clients — query, sample, and inspect schemas via MCP. Paste the config into ~/.codeium/windsurf/mcp_config.json and restart Windsurf.

Last updated June 14, 2026 · 1.3k · stdio · no auth

Windsurf config for MySQL MCP Server

pip install mysql-mcp-server
{
  "mcpServers": {
    "mysql-mcp-server": {
      "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"
      }
    }
  }
}

Setup steps

  1. 1Open Windsurf → Cascade → the hammer/MCP icon → Configure (or edit ~/.codeium/windsurf/mcp_config.json).
  2. 2Paste the MySQL MCP Server config below.
  3. 3Fill in placeholder secrets, then save.
  4. 4Click Refresh in the MCP panel.
  5. 5MySQL MCP Server's tools become available to Cascade.

Before you start

  • Python with pip (or uv/uvx) to install and run the server
  • A running MySQL database with reachable host/port
  • MySQL credentials supplied via MYSQL_HOST, MYSQL_USER, MYSQL_PASSWORD (and optionally MYSQL_DATABASE) environment variables
  • uv installed when using the uv/uvx-based config

What MySQL MCP Server can do in Windsurf

execute_sql

Executes any standard SQL query. Argument: query (string). Supports SELECT, SHOW, DESCRIBE, and DML (INSERT, UPDATE, DELETE); DML operations are marked with a destructive hint. Single statements only — multi-statement queries are not supported. Use database.table notation to query any database regardless of the MYSQL_DATABASE setting.

get_schema_info

Provides detailed metadata about database structures. Argument: table_name (optional string). Outputs column names, types, nullability, default values, and comments. Pass database.table for cross-database lookups; bare names use the configured database. Identifiers must contain only alphanumeric characters, underscores, and $ (a dot is allowed as a database/table separator).

get_table_sample

Fetches a representative sample of data. Arguments: table_name (string), limit (optional integer, max 20). Useful for quickly understanding data formats and content without fetching large result sets. Pass database.table for cross-database sampling; bare names use the configured database. Same identifier validation rules as get_schema_info.

Security

Requires database access to function. Table/database identifiers passed to get_schema_info and get_table_sample are validated against a strict whitelist (alphanumeric, underscore, and $; a single dot allowed as database.table separator) to prevent SQL injection. Supports SSL/TLS and SSH tunneling for encrypted remote connections. Passwords and SSH private keys are masked in logs. Use a dedicated MySQL user with minimal permissions; never use root or administrative credentials. See SECURITY.md for hardening guidance.

MySQL MCP Server + Windsurf FAQ

Where is the Windsurf config file?

Windsurf reads MCP servers from ~/.codeium/windsurf/mcp_config.json. Paste the MySQL MCP Server config there under the "mcpServers" key and restart the client.

Is MySQL MCP Server safe to use with Windsurf?

Requires database access to function. Table/database identifiers passed to get_schema_info and get_table_sample are validated against a strict whitelist (alphanumeric, underscore, and $; a single dot allowed as database.table separator) to prevent SQL injection. Supports SSL/TLS and SSH tunneling for encrypted remote connections. Passwords and SSH private keys are masked in logs. Use a dedicated MySQL user with minimal permissions; never use root or administrative credentials. See SECURITY.md for hardening guidance.

Which transports are supported?

Both standard input/output (STDIO) and Streamable HTTP (SSE). SSE mode (MCP_TRANSPORT=sse) is recommended for remote/self-hosted deployments.

Why do I see 'Missing required database configuration' in Claude Desktop/Code?

Those hosts launch the server from their own working directory, so a project .env file is not found. Put your MYSQL_* values in the env block of the MCP config instead of relying on .env.

Can I query more than one database?

Yes. Omit MYSQL_DATABASE to enable multi-database mode; list_resources then returns all user databases and you use fully qualified database.table names in queries. Only single SQL statements are supported.

View repo Full MySQL MCP Server page