MySQL MCP Server

MySQL MCP Server

MCP Server for MySQL

kaulvimal

Developer Tools
Visit Server

README

MySQL MCP Server

Overview

This project provides a read-only Model Context Protocol (MCP) server for interacting with MySQL databases. It allows clients compatible with MCP to inspect database schemas, retrieve metadata, and execute read-only SQL queries through a set of defined tools. The server is built with extensibility in mind and enforces read-only operations for safety.

Features & Implemented Tools

The server exposes several tools via MCP for database interaction. All tools are designed for read-only operations.

Schema & Metadata Tools

  • get_table_columns: Retrieves column definitions for a specific table.
  • get_schema: Fetches detailed schema information including tables, columns, indexes, and constraints, with varying detail levels.
  • get_indexes: Retrieves index information for a specific table or all tables.
  • get_constraints: Fetches constraint information (Primary Key, Foreign Key, Unique, Check) for a specific table or all tables.
  • compare_schemas: Compares the structure (tables and columns) of two different database schemas.
  • explain_schema: Generates a textual or structured (JSON) description of the database schema.
  • detect_schema_changes: Returns a snapshot of the current schema. (Note: Does not compare against a specific past time).
  • find_relationships: Discovers explicit foreign key relationships. Can optionally attempt to find implicit relationships based on naming conventions (use with caution).
  • find_navigation_paths: Finds paths between two tables using explicit foreign key relationships (BFS algorithm).

Query Execution Tools

  • execute_query: Executes a given read-only SQL query (SELECT, SHOW, DESCRIBE, EXPLAIN).
  • execute_batch: Runs multiple read-only SQL queries sequentially. Can stop on the first error or attempt all.
  • prepare_statement: Prepares and executes a read-only SQL statement with parameters.
  • explain_query: Executes EXPLAIN on a given SQL statement to show the query execution plan (TEXT or JSON format).
  • get_query_history: Placeholder tool. Server-side query history is not currently implemented.

Visualization Tools

  • visualize_schema: Generates schema representations (tables, columns, relationships) in JSON, DOT (Graphviz), or Mermaid syntax suitable for creating ER diagrams.

Performance Tools

  • get_performance_metrics: Retrieves selected global status variables from MySQL (e.g., Uptime, Threads, Queries). Does not provide query-specific history.

Setup & Installation

  1. Prerequisites:

    • Node.js
    • npm
    • Access to a MySQL database
  2. Clone the Repository:

    git clone https://github.com/kaulvimal/mysql-mcp
    cd mysql-mcp-server
    
  3. Install Dependencies:

    npm install
    
  4. Build the Project:

    npm run build
    

    This will create a build directory with the compiled code.

  5. Using the server

  • Create a shell script (e.g., mysql-mcp.sh) in the project root or a convenient location:

    #!/bin/bash
    # Set environment variables (if not using .env or want to override)
    # export DB_HOST=localhost
    # export DB_USER=root
    # export DB_PASSWORD=""
    # export DB_PORT=3306
    node $(dirname "$0")/build/index.js
    
  • Make the script executable:

    chmod +x mysql-mcp.sh
    
  • Integration Example (Cursor)

    To integrate this server with an Cursor, you can configure the client to run the server's execution script:

    {
    "mcpServers": {
    	"mysql-mcp": {
    	"command": "/path/to/your/mysql-mcp.sh" // Replace with the actual path to your script
    	}
    }
    }
    

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
MCP Package Docs Server

MCP Package Docs Server

Facilitates LLMs to efficiently access and fetch structured documentation for packages in Go, Python, and NPM, enhancing software development with multi-language support and performance optimization.

Featured
Local
TypeScript
Claude Code MCP

Claude Code MCP

An implementation of Claude Code as a Model Context Protocol server that enables using Claude's software engineering capabilities (code generation, editing, reviewing, and file operations) through the standardized MCP interface.

Featured
Local
JavaScript
@kazuph/mcp-taskmanager

@kazuph/mcp-taskmanager

Model Context Protocol server for Task Management. This allows Claude Desktop (or any MCP client) to manage and execute tasks in a queue-based system.

Featured
Local
JavaScript
Linear MCP Server

Linear MCP Server

Enables interaction with Linear's API for managing issues, teams, and projects programmatically through the Model Context Protocol.

Featured
JavaScript
mermaid-mcp-server

mermaid-mcp-server

A Model Context Protocol (MCP) server that converts Mermaid diagrams to PNG images.

Featured
JavaScript
Jira-Context-MCP

Jira-Context-MCP

MCP server to provide Jira Tickets information to AI coding agents like Cursor

Featured
TypeScript
Linear MCP Server

Linear MCP Server

A Model Context Protocol server that integrates with Linear's issue tracking system, allowing LLMs to create, update, search, and comment on Linear issues through natural language interactions.

Featured
JavaScript
Sequential Thinking MCP Server

Sequential Thinking MCP Server

This server facilitates structured problem-solving by breaking down complex issues into sequential steps, supporting revisions, and enabling multiple solution paths through full MCP integration.

Featured
Python