Sponsored by Deepsite.site

MySQL MCP Server

Created By
kaulvimal10 months ago
MCP Server for MySQL
Content

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
    	}
    }
    }
    
Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
Playwright McpPlaywright MCP server
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
Y GuiA web-based graphical interface for AI chat interactions with support for multiple AI models and MCP (Model Context Protocol) servers.
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
TimeA Model Context Protocol server that provides time and timezone conversion capabilities. This server enables LLMs to get current time information and perform timezone conversions using IANA timezone names, with automatic system timezone detection.
CursorThe AI Code Editor
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题; Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
Amap Maps高德地图官方 MCP Server
DeepChatYour AI Partner on Desktop
Tavily Mcp
ChatWiseThe second fastest AI chatbot™
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.
WindsurfThe new purpose-built IDE to harness magic
Serper MCP ServerA Serper MCP Server