Back to MCP Catalog

MySQL Database Operations MCP Server

DatabasesTypeScript
Interact with MySQL databases through a standardized interface
Available Tools

connect_db

Establish connection to MySQL database using provided credentials.

hostuserpassworddatabase

query

Execute SELECT queries with optional prepared statement parameters.

sqlparams

execute

Execute INSERT, UPDATE, or DELETE queries with optional prepared statement parameters.

sqlparams

list_tables

List all tables in the connected database.

describe_table

Get the structure of a specific table.

table

A Model Context Protocol server that provides MySQL database operations. This server enables AI models to interact with MySQL databases through a standardized interface, allowing for secure connections, prepared statements, and comprehensive error handling. With this MCP, AI assistants can perform database queries, execute commands, and explore database structure without direct database access.

Overview

The MySQL Database Operations MCP provides a secure and standardized way for AI models to interact with MySQL databases. It handles connection management, query execution, and database structure exploration while maintaining security through prepared statements and proper validation.

Installation

Using Smithery (Recommended)

To install the MySQL Database Operations MCP automatically via Smithery:

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

Manual Installation

You can also install and run the MCP manually:

npx @f4ww4z/mcp-mysql-server

Configuration

The server requires database connection information to be provided. You can configure it in two ways:

Option 1: Connection String (Recommended)

{
  "mcpServers": {
    "mysql": {
      "command": "npx",
      "args": ["-y", "@f4ww4z/mcp-mysql-server", "mysql://user:password@localhost:port/database"]
    }
  }
}

Option 2: Environment Variables

{
  "mcpServers": {
    "mysql": {
      "command": "npx",
      "args": ["-y", "@f4ww4z/mcp-mysql-server"],
      "env": {
        "MYSQL_HOST": "your_host",
        "MYSQL_USER": "your_user",
        "MYSQL_PASSWORD": "your_password",
        "MYSQL_DATABASE": "your_database"
      }
    }
  }
}

Security Features

  • Uses prepared statements to prevent SQL injection
  • Supports secure password handling through environment variables
  • Validates queries before execution
  • Automatically closes connections when done

Error Handling

The server provides detailed error messages for common issues:

  • Connection failures
  • Invalid queries
  • Missing parameters
  • Database errors

Usage Examples

After configuring the MCP, you can use it to interact with your MySQL database. Here are some examples:

  1. List all tables in the database:
use_mcp_tool({
  server_name: "mysql",
  tool_name: "list_tables",
  arguments: {}
});
  1. Query data from a table:
use_mcp_tool({
  server_name: "mysql",
  tool_name: "query",
  arguments: {
    sql: "SELECT * FROM users WHERE id = ?",
    params: [1]
  }
});
  1. Insert data into a table:
use_mcp_tool({
  server_name: "mysql",
  tool_name: "execute",
  arguments: {
    sql: "INSERT INTO users (name, email) VALUES (?, ?)",
    params: ["John Doe", "john@example.com"]
  }
});

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.