npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

mysql-mcp-database-server

v1.0.0

Published

MySQL MCP Server for database operations with Claude and MCP

Downloads

15

Readme

MySQL MCP Server

A Model Context Protocol (MCP) server for MySQL database operations, enabling Claude and other MCP clients to interact with MySQL databases.

Features

  • Database Connection: Connect to MySQL databases with configurable credentials
  • Query Execution: Execute SQL queries with parameter binding
  • Schema Exploration: List tables, describe table structures, and show databases
  • Environment Variables: Auto-connect using environment variables
  • Query Validation: Built-in query validation with helpful tips

Installation

npm install -g mysql-mcp-server

Quick Start

1. Environment Variables

Set up your MySQL connection using environment variables:

export MYSQL_HOST=localhost
export MYSQL_PORT=3306
export MYSQL_USER=your_username
export MYSQL_PASSWORD=your_password
export MYSQL_DATABASE=your_database

2. Run the Server

mysql-mcp-server

3. Configure Claude Desktop

Add to your Claude Desktop configuration file:

MacOS: ~/Library/Application Support/Claude/claude_desktop_config.json Windows: %APPDATA%/Claude/claude_desktop_config.json

{
  "mcpServers": {
    "mysql": {
      "command": "mysql-mcp-server",
      "env": {
        "MYSQL_HOST": "localhost",
        "MYSQL_PORT": "3306",
        "MYSQL_USER": "your_username",
        "MYSQL_PASSWORD": "your_password",
        "MYSQL_DATABASE": "your_database"
      }
    }
  }
}

Available Tools

connect_mysql

Connect to a MySQL database with custom credentials.

Parameters:

  • host (string, optional): Database host (default: localhost)
  • port (number, optional): Database port (default: 3306)
  • user (string, required): Database username
  • password (string, required): Database password
  • database (string, required): Database name

execute_query

Execute a SQL query on the connected database.

Parameters:

  • query (string, required): SQL query to execute
  • params (array, optional): Query parameters for prepared statements

Example:

SELECT * FROM users WHERE id = ? AND status = ?

With params: ["123", "active"]

show_tables

List all tables in the current database.

describe_table

Show the structure of a specific table.

Parameters:

  • table_name (string, required): Name of the table to describe

show_databases

List all available databases.

Usage Examples

Basic Query

SELECT COUNT(*) FROM users WHERE active = 1;

Parameterized Query

SELECT * FROM orders WHERE user_id = ? AND created_at > ?;

Schema Exploration

DESCRIBE users;
SHOW TABLES;
SHOW DATABASES;

Environment Variables

| Variable | Description | Default | |----------|-------------|---------| | MYSQL_HOST | MySQL server host | localhost | | MYSQL_PORT | MySQL server port | 3306 | | MYSQL_USER | MySQL username | - | | MYSQL_PASSWORD | MySQL password | - | | MYSQL_DATABASE | Database name | - | | MYSQL_DB | Alternative for MYSQL_DATABASE | - |

Security

  • Always use environment variables for sensitive credentials
  • Use parameterized queries to prevent SQL injection
  • The server validates queries and provides security warnings
  • Connections use UTF8MB4 charset by default

Requirements

  • Node.js 18.0.0 or higher
  • MySQL 5.7 or higher (or compatible database like MariaDB)

Development

Local Development

  1. Clone the repository
  2. Install dependencies: npm install
  3. Run in development mode: npm run dev

Testing

Set up a test database and run:

export MYSQL_HOST=localhost
export MYSQL_USER=test_user
export MYSQL_PASSWORD=test_password
export MYSQL_DATABASE=test_db

npm test

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

License

MIT License - see LICENSE file for details.

Support

  • GitHub Issues: https://github.com/kaedim/mysql-mcp-server/issues
  • Documentation: https://github.com/kaedim/mysql-mcp-server

Related Projects