mysql-mcp-server

mysql-mcp-server

Provides read-only access to MySQL database schema and sample data, offering tools to list tables, get schema, and fetch sample rows for safe backend development.

Category
Visit Server

README

MySQL MCP Server

A Model Context Protocol (MCP) server for MySQL databases that provides read-only access to database schema information and sample data.

Background

While existing MySQL MCP servers (such as designcomputer/mysql_mcp_server) allow LLMs to generate and execute arbitrary SQL queries—including INSERT, UPDATE, and DELETE operations—this approach poses risks when working on backend implementations.

This MCP server takes a different, safer approach:

  • Read-only operations: Retrieves table lists, schema information, and sample data
  • No write operations: Cannot modify, add, or delete data
  • 🎯 Backend development focused: Provides exactly what's needed for backend implementation without the risk of data corruption

When developing backend applications, you typically only need to understand the database structure. This server provides:

  1. Table List: Get all tables in the database
  2. Schema Information: Retrieve detailed schema for specific tables
  3. Sample Data: Fetch the first 5 rows from any table for validation

Features

  • 🔒 Safe by design: Read-only operations prevent accidental data modification
  • 🚀 Simple setup: Easy configuration via CLI arguments
  • 📊 Three essential tools:
    • list_tables: Get a list of all tables in the database
    • get_table_schema: Retrieve schema information for a specific table
    • get_table_data: Fetch up to 5 sample rows from a table

Installation

npm install @yukihito/mysql-mcp-server

or

pnpm add @yukihito/mysql-mcp-server

Usage

As an MCP Server

Configure your MCP client (e.g., Claude Desktop, Cline) to use this server:

{
  "mcpServers": {
    "mysql-mcp-server": {
      "command": "npx",
      "args": [
        "-y",
        "@yukihito/mysql-mcp-server@latest",
        "--host", "localhost",
        "--port", "3306",
        "--name", "your_username",
        "--password", "your_password",
        "--database", "your_database"
      ]
    }
  }
}

CLI Options

Option Description Default
--host MySQL host localhost
--port MySQL port 8080
--name Database username admin
--password Database password root
--database Database name database

Example Configuration for Claude Desktop

Edit your Claude Desktop configuration file:

macOS: ~/Library/Application Support/Claude/claude_desktop_config.json

Windows: %APPDATA%\Claude\claude_desktop_config.json

{
  "mcpServers": {
    "mysql-mcp-server": {
      "command": "npx",
      "args": [
        "-y",
        "@yukihito/mysql-mcp-server@latest",
        "--host", "localhost",
        "--port", "3306",
        "--name", "myuser",
        "--password", "mypassword",
        "--database", "mydb"
      ]
    }
  }
}

Available Tools

1. list_tables

Retrieves a list of all tables in the connected database.

Input: None

Output: JSON array of table names

Example:

["users", "products", "orders", "categories"]

2. get_table_schema

Gets detailed schema information for a specific table.

Input:

  • tableName (string): Name of the table

Output: JSON array containing column information (name, type, nullable, key, default, extra)

Example:

[
  {
    "Field": "id",
    "Type": "int",
    "Null": "NO",
    "Key": "PRI",
    "Default": null,
    "Extra": "auto_increment"
  },
  {
    "Field": "name",
    "Type": "varchar(255)",
    "Null": "NO",
    "Key": "",
    "Default": null,
    "Extra": ""
  }
]

3. get_table_data

Retrieves up to 5 rows from a specific table for validation purposes.

Input:

  • tableName (string): Name of the table

Output: JSON array of row objects (limited to 5 rows)

Example:

[
  {"id": 1, "name": "John Doe", "email": "john@example.com"},
  {"id": 2, "name": "Jane Smith", "email": "jane@example.com"}
]

Development

For development environment setup and contribution guidelines, see DEVELOPMENT.md.

License

MIT

Author

Yukihito

Related Projects

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
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
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
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Qdrant Server

Qdrant Server

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

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