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 🙏

© 2025 – Pkg Stats / Ryan Hefner

mcp-mysql-inspector

v1.1.0

Published

MCP server for inspecting MySQL database schemas and structure

Readme

MCP MySQL Inspector

A powerful Model Context Protocol (MCP) server for inspecting MySQL database schemas, relationships, and structure. This tool provides AI assistants with comprehensive database introspection capabilities while maintaining strict read-only access for security.

🚀 Features

  • Read-Only Database Inspection: Secure schema exploration without modification risks
  • Multi-Database Support: Connect to multiple MySQL databases simultaneously
  • Comprehensive Schema Analysis: Detailed table, column, index, and relationship information
  • Foreign Key Relationship Mapping: Understand data relationships across tables
  • Index Performance Analysis: Identify optimization opportunities
  • Security-First Design: Query validation, input sanitization, and audit logging
  • Cross-Database Awareness: Analyze relationships across multiple database instances

📋 Requirements

  • Node.js 18 or higher
  • MySQL 5.7+ or compatible database (MariaDB, Aurora, etc.)
  • Network access to target database(s)
  • Valid database credentials with SELECT permissions

📦 Installation

Global Installation

npm install -g mcp-mysql-inspector

Local Development

git clone https://github.com/kokorolx/mcp-mysql-inspector.git
cd mcp-mysql-inspector
npm install
npm run build

MCP Client Integration

Roo Configuration

Create roo-config.json:

{
  "servers": {
    "mysql-inspector": {
      "command": "npx",
      "args": [
        "mcp-mysql-inspector",
        "mysql://dev:password@localhost:3306/ecommerce",
        "mysql://dev:password@localhost:3306/analytics"
      ]
    }
  }
}

Claude Desktop Configuration

Add to claude_desktop_config.json:

{
  "mcpServers": {
    "mysql-inspector": {
      "command": "node",
      "args": [
        "/path/to/mcp-mysql-inspector/dist/index.js",
        "mysql://username:password@localhost:3306/database1",
        "mysql://username:password@localhost:3306/database2"
      ]
    }
  }
}

🛠 Available Tools

1. list_databases

Lists all connected databases with connection status.

2. list_tables

Lists all tables in a specified database with metadata.

3. inspect_table

Get complete table schema including columns, types, constraints, and metadata. Supports both single-table and multi-table inspection via the table (string) or tables (string[]) parameter.

Parameters:

  • database (string, required): Name of the database.
  • table (string, optional): Name of a single table to inspect.
  • tables (string[], optional): Array of table names to inspect (multi-table mode). Provide either table or tables, not both.

Examples:

{ "database": "mydb", "table": "users" }
{ "database": "mydb", "tables": ["users", "orders", "products"] }

4. get_foreign_keys

Get foreign key relationships for one or more tables, or the entire database. Supports both single-table and multi-table inspection via the table (string) or tables (string[]) parameter.

Parameters:

  • database (string, required): Name of the database.
  • table (string, optional): Name of a single table to analyze.
  • tables (string[], optional): Array of table names to analyze (multi-table mode). Provide either table or tables, not both.

Examples:

{ "database": "mydb", "table": "orders" }
{ "database": "mydb", "tables": ["orders", "order_items"] }

5. get_indexes

Get detailed index information for one or more tables. Supports both single-table and multi-table inspection via the table (string) or tables (string[]) parameter.

Parameters:

  • database (string, required): Name of the database.
  • table (string, optional): Name of a single table to analyze.
  • tables (string[], optional): Array of table names to analyze (multi-table mode). Provide either table or tables, not both.

Examples:

{ "database": "mydb", "table": "products" }
{ "database": "mydb", "tables": ["products", "categories"] }

🔒 Security Features

Query Safety

  • Whitelist-Only Approach: Only SELECT, SHOW, DESCRIBE, EXPLAIN queries allowed
  • SQL Injection Prevention: Multi-layer validation and parameter binding
  • Row Limits: Automatic limits to prevent resource exhaustion
  • Timeout Protection: Internal query timeouts are enforced, but timeout is not a valid connection option.

Input Validation

  • URL Validation: Comprehensive connection string validation
  • Identifier Sanitization: MySQL identifier format validation
  • Parameter Sanitization: Input cleaning and null-byte removal

Audit & Logging

  • Comprehensive Logging: All operations logged with configurable levels
  • Sensitive Data Masking: Credentials automatically redacted from logs
  • Performance Monitoring: Query timing and resource usage tracking

⚙️ Configuration

Environment Variables

| Variable | Description | Default | Example | |----------|-------------|---------|----------| | LOG_LEVEL | Logging level (error, warn, info, debug, trace) | info | LOG_LEVEL=debug |

Database URL Format

mysql://username:password@hostname:port/database?options

Supported Options:

  • ssl=true/false - Enable/disable SSL connections

🚨 Troubleshooting

Common Issues

Connection Failures

# Test connection manually
mysql -h hostname -u username -p database_name

# Check network connectivity
telnet hostname 3306

# Verify credentials and permissions
SHOW GRANTS FOR 'username'@'hostname';

Permission Errors

Ensure the database user has at least:

GRANT SELECT ON database_name.* TO 'username'@'%';
GRANT SELECT ON INFORMATION_SCHEMA.* TO 'username'@'%';

Debug Mode

Enable detailed logging:

LOG_LEVEL=debug mcp-mysql-inspector "mysql://..."

📄 License

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