MySQL MCP Server

MySQL MCP Server

Connects AI assistants like Claude Desktop directly to MySQL databases, enabling natural language interaction for schema inspection, data querying, CRUD operations, and database administration tasks.

Category
Visit Server

README

MySQL MCP Server

A powerful Model Context Protocol (MCP) server that connects your AI assistant (like Claude Desktop) directly to your MySQL database. This server enables safe, controlled access to inspect schemas, query data, and even perform administrative tasks, all through natural language.

🚀 Features

This server implements a wide range of MCP capabilities to give you full visibility and control over your MySQL database.

🛠️ Tools

Table Management

  • list-tables: List all tables in the database.
  • describe-table: Get the schema (columns, types, keys) of a specific table.
  • create-table: Create a new table using a SQL query.

Data Operations (CRUD)

  • insert-row: Insert a new row into a table using JSON data.
  • update-row: Update existing rows with a convenient JSON-based WHERE clause.
  • delete-row: Delete rows with a safety-first JSON-based WHERE clause.

Query Execution

  • execute-query: Execute read-only SQL queries (SELECT, SHOW, DESCRIBE). Safe for exploration.
  • execute-write-query: Execute write SQL queries (INSERT, UPDATE, DELETE, ALTER, etc.). Use with caution.

Database Administration

  • create-database: Create a new database.

Advanced Objects Inspection

  • Stored Procedures: list-procedures, show-procedure (view CREATE statement).
  • Functions: list-functions, show-function (view CREATE statement).
  • Triggers: list-triggers, show-trigger.
  • Views: list-views, show-view.

📦 Resources

Access database content directly as standard MCP resources:

  • mysql://<table_name>/schema: View the full JSON schema of a table.
  • mysql://<table_name>/data: View the first 100 rows of a table as JSON.

💬 Prompts

Pre-built templates to help the AI perform complex tasks:

  • analyze-table: "Analyze the structure and sample data for table 'Users'..."
    • Automatically fetches schema and sample data to provide insights.
  • optimize-query: "Analyze this query for performance..."
    • Helps you write faster, more efficient SQL.

📦 Installation

  1. Clone the repository:

    git clone <repository-url>
    cd mysql-mcp-server
    
  2. Install dependencies:

    npm install
    
  3. Build the server:

    npm run build
    

⚙️ Configuration

1. Environment Variables

The server uses mysql2 and requires connection details. You can pass these via environment variables.

Variable Description Default
DB_HOST Database hostname localhost
DB_USER Database username -
DB_PASSWORD Database password -
DB_NAME Database name -
DB_PORT Database port 3306

2. Claude Desktop Config

Add the following to your claude_desktop_config.json:

{
  "mcpServers": {
    "mysql": {
      "command": "node",
      "args": ["/ABSOLUTE/PATH/TO/mysql-mcp-server/dist/index.js"],
      "env": {
        "DB_HOST": "localhost",
        "DB_USER": "root",
        "DB_PASSWORD": "your_password",
        "DB_NAME": "your_database",
        "DB_PORT": "3306"
      }
    }
  }
}

Note: Make sure to replace /ABSOLUTE/PATH/TO/... with the actual path to your project.


💡 Usage Examples

Once connected, you can ask Claude questions like:

  • Exploration: "What tables are in my database?"
  • Schema: "Show me the schema for the orders table."
  • Data Analysis: "Select the top 5 customers who spent the most money."
  • Modification: "Insert a new user named 'Alice' into the users table."
  • Optimization: "Analyze this query and tell me why it's slow: SELECT * FROM logs"

🔒 Security Note

This server has powerful capabilities, including write access (execute-write-query, delete-row, etc.). Always ensure you are connecting to a database where you have appropriate permissions, and be careful when asking the AI to modify data.

📄 License

ISC

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
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
E2B

E2B

Using MCP to run code via e2b.

Official
Featured