Back to MCP Catalog

MySQL Database Access MCP Server

DatabasesPython
Secure interface for AI applications to interact with MySQL databases
Available Tools

list_tables

Lists all available tables in the connected MySQL database

read_table

Retrieves data from a specified MySQL table

execute_query

Executes a custom SQL query against the MySQL database

MySQL Database Access provides a secure bridge between AI applications and MySQL databases. It enables structured exploration and analysis of database content through a controlled interface, allowing AI systems to safely query and retrieve data without direct database access. With comprehensive error handling and logging, it ensures reliable and secure database operations while maintaining proper access controls.

Overview

MySQL Database Access enables AI applications to safely interact with MySQL databases through a controlled interface. This implementation follows the Model Context Protocol (MCP) to provide structured access to database resources, allowing AI systems to explore and analyze data without direct database access.

Installation

You can install the MySQL Database Access in several ways:

Using pip

pip install mysql-mcp-server

Using Smithery (for Claude Desktop)

npx -y @smithery/cli install mysql-mcp-server --client claude

Configuration

The MySQL Database Access requires database connection details to be provided as environment variables:

  • MYSQL_HOST: Database host (default: localhost)
  • MYSQL_PORT: Database port (default: 3306)
  • MYSQL_USER: Database username
  • MYSQL_PASSWORD: Database password
  • MYSQL_DATABASE: Database name

Setup with Claude Desktop

To use MySQL Database Access with Claude Desktop, add the following configuration to your claude_desktop_config.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"
      }
    }
  }
}

Replace the placeholder values with your actual database connection details.

Setup with Visual Studio Code

To use MySQL Database Access with Visual Studio Code, add the following to your mcp.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"
      }
    }
  }
}

Note: You'll need to install uv for this configuration to work.

Security Best Practices

When using MySQL Database Access, follow these security best practices:

  1. Create a dedicated MySQL user with minimal permissions required for your use case
  2. Never use root credentials or administrative accounts
  3. Restrict database access to read-only if possible
  4. Use environment variables for credentials and never commit them to version control
  5. Monitor and log all database operations

Troubleshooting

If you encounter issues:

  1. Verify your database connection details are correct
  2. Ensure the MySQL server is running and accessible
  3. Check that the database user has appropriate permissions
  4. Review logs for specific error messages
  5. Verify network connectivity between the MCP server and the database

The MySQL Database Access is designed to be integrated with AI applications and should not be run directly as a standalone program.

Related MCPs

Milvus Vector Database
DatabasesPython

Connect to Milvus vector database for semantic search and vector operations

MotherDuck DuckDB
DatabasesPython

SQL analytics with DuckDB and MotherDuck for AI assistants

Alibaba Cloud Tablestore
DatabasesJava, Python

Connect to Alibaba Cloud Tablestore for vector search and RAG applications

About Model Context Protocol

Model Context Protocol (MCP) allows AI models to access external tools and services, extending their capabilities beyond their training data.

Generate Cursor Documentation

Save time on coding by generating custom documentation and prompts for Cursor IDE.