Skip to main content
Glama
myheisenberg

mysql-mcp-server

by myheisenberg

πŸ”§ MySQL MCP Server

A Model Context Protocol (MCP) server for MySQL database operations. Provides 4 powerful tools for database interaction through any MCP-compatible client.

✨ Features

  • πŸ” Execute SQL Queries - Run any SELECT, INSERT, UPDATE, DELETE commands

  • πŸ“Š List Databases - View all available databases

  • πŸ“‹ List Tables - Show tables in any database

  • πŸ—οΈ Describe Tables - Get detailed table structure information

  • πŸ”’ Secure - Environment-based configuration, no hardcoded credentials

  • ⚑ Fast - Built with TypeScript and connection pooling

Related MCP server: MariaDB-MCP

πŸš€ Quick Start

Installation

# Clone the repository
git clone https://github.com/myheisenberg/mysql-mcp-server.git
cd mysql-mcp-server

# Install dependencies
npm install

# Build the project
npm run build

Configuration

The server uses environment variables for database configuration:

DB_HOST=localhost        # MySQL host (default: localhost)
DB_USER=root            # MySQL username (default: root)
DB_PASSWORD=            # MySQL password (default: empty)
DB_PORT=3306           # MySQL port (default: 3306)

πŸ“– Usage

With Claude Desktop

Add to your claude_desktop_config.json:

{
  "mcpServers": {
    "mysql": {
      "command": "node",
      "args": ["path/to/mysql-mcp-server/dist/index.js"],
      "env": {
        "DB_HOST": "localhost",
        "DB_USER": "your_username",
        "DB_PASSWORD": "your_password",
        "DB_PORT": "3306"
      }
    }
  }
}

With Cursor IDE

Add to your MCP configuration:

{
  "mcpServers": {
    "mysql": {
      "command": "node",
      "args": ["path/to/mysql-mcp-server/dist/index.js"],
      "env": {
        "DB_HOST": "localhost",
        "DB_USER": "your_username", 
        "DB_PASSWORD": "your_password",
        "DB_PORT": "3306"
      }
    }
  }
}

πŸ› οΈ Available Tools

1. mysql_query

Execute any MySQL query and get formatted results.

Example: "Run a SELECT query on the users table"

2. mysql_databases

List all available databases on the MySQL server.

Example: "Show me all databases"

3. mysql_tables

List all tables in a specific database.

Example: "What tables are in the blog database?"

4. mysql_describe

Get detailed information about a table's structure.

Example: "Describe the structure of the users table"

πŸ”§ Development

# Install dependencies
npm install

# Development mode (watch for changes)
npm run dev

# Build for production
npm run build

# Start the server
npm start

πŸ“¦ Project Structure

mysql-mcp-server/
β”œβ”€β”€ src/
β”‚   └── index.ts          # Main MCP server implementation
β”œβ”€β”€ dist/                 # Compiled JavaScript (auto-generated)
β”œβ”€β”€ package.json          # Project dependencies and scripts
β”œβ”€β”€ tsconfig.json         # TypeScript configuration
β”œβ”€β”€ .gitignore           # Git ignore rules
└── README.md            # This file

πŸ”’ Security

  • No hardcoded credentials - All database connection details come from environment variables

  • Connection pooling - Efficient and secure database connections

  • Error handling - Proper error messages without exposing sensitive information

🀝 Contributing

  1. Fork the repository

  2. Create your feature branch (git checkout -b feature/amazing-feature)

  3. Commit your changes (git commit -m 'Add some amazing feature')

  4. Push to the branch (git push origin feature/amazing-feature)

  5. Open a Pull Request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

πŸ“ž Support

If you encounter any issues or have questions:

  1. Check the Issues page

  2. Create a new issue if your problem isn't already reported

  3. Provide as much detail as possible including error messages and configuration


Made with ❀️ for the MCP community

Related MCP Connectors

  • Guard AI agents' PostgreSQL/MySQL access via MCP: SQL audit, auth, masking, write approval

  • PostgreSQL, MySQL, and SQL Server in one session. 26 read-only MCP tools for AI agents.

  • The Instant MCP server is a wrapper around the Instant Platform SDK that enables creating, managing, and updating InstantDB applications directly within an editor. It provides tools for fetching rules files for LLMs, retrieving and pushing app schemas, managing permission rules, and executing database queries. Key capabilities include schema management (get-schema, push-schema), permission management (get-perms, push-perms), query execution, and listing recent query history.

  • Text-to-SQL MCP server: read-only queries on PostgreSQL, MySQL and SQL Server with your real schema

Related MCP Servers

  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables interaction with MySQL databases through MCP, supporting query execution, table operations (insert, update, delete), and schema inspection for natural language database management.
    202 npm
    MIT
  • F
    license
    A
    quality
    C
    maintenance
    Enables interaction with MariaDB/MySQL databases via MCP, supporting read-only mode, SQL execution, and schema inspection.
    6
    -
  • A
    license
    Not graded
    quality
    C
    maintenance
    Provides MySQL database operations through MCP, enabling users to execute SQL queries, retrieve table structures, and check database connectivity using natural language.
    202 npm
    Apache 2.0
  • -
    license
    Not graded
    quality
    C
    maintenance
    Enables interaction with a MySQL database through MCP tools, resources, and prompts, supporting both read-only queries and safe write operations.
    -