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

@arvoretech/mysql-mcp

v1.0.4

Published

MySQL MCP Server for read-only database operations

Downloads

22

Readme

MySQL MCP Server

Install MCP Server

A Model Context Protocol (MCP) server implementation for MySQL that enables read-only database operations through a standardized protocol for integration with LLMs and AI tools.

Features

  • Read-only: Executes only SELECT, SHOW, DESCRIBE and EXPLAIN queries
  • 🔒 Secure: Validates queries to prevent write operations
  • 🚀 Fast: Direct MySQL connection using mysql2
  • 📡 MCP Protocol: Communication via stdio transport
  • 🛠️ TypeScript: Fully typed with Zod validation
  • 🌍 Environment Configuration: Easy setup via environment variables

Installation

npm install -g @arvoretech/mysql-mcp --registry=https://npm.pkg.github.com

Or configure your .npmrc:

echo "@arvoretech:registry=https://npm.pkg.github.com" >> ~/.npmrc
npm install -g @arvoretech/mysql-mcp

Configuration

The server is configured via environment variables:

export MYSQL_HOST=localhost
export MYSQL_PORT=3306
export MYSQL_USER=root
export MYSQL_PASSWORD=secret
export MYSQL_DATABASE=mydb
export MYSQL_SSL=false
export MYSQL_CONNECTION_TIMEOUT=30000

Usage

# Development
pnpm dev

# Production
node dist/index.js

Available MCP Tools

read_query

Executes SELECT queries on the MySQL database.

Parameters:

  • query (string): SQL SELECT statement

Example:

{
  "query": "SELECT * FROM users LIMIT 10"
}

list_tables

Lists all tables in the current database.

Parameters: None

describe_table

Gets structure and schema information for a specific table.

Parameters:

  • tableName (string): Name of the table

show_databases

Lists all available databases on the MySQL server.

Parameters: None

Programmatic Usage

import { MySQLMCPServer } from "mysql-mcp-server";

const server = new MySQLMCPServer({
  host: "localhost",
  port: 3306,
  user: "root",
  password: "secret",
  database: "mydb",
  ssl: false,
  connectionTimeout: 30000,
});

// Setup graceful shutdown
server.setupGracefulShutdown();

// Start server
await server.start();

Claude Desktop Integration

Add to your Claude Desktop configuration file (~/Library/Application Support/Claude/claude_desktop_config.json on macOS):

{
  "mcpServers": {
    "mysql": {
      "command": "npx",
      "args": ["-y", "@arvoretech/mysql-mcp"],
      "env": {
        "MYSQL_HOST": "localhost",
        "MYSQL_PORT": "3306",
        "MYSQL_USER": "root",
        "MYSQL_PASSWORD": "secret",
        "MYSQL_DATABASE": "mydb",
        "MYSQL_SSL": "false",
        "MYSQL_CONNECTION_TIMEOUT": "30000"
      }
    }
  }
}

Security

  • Query validation: Only read operations are allowed
  • Parameter escaping: Uses prepared statements when possible
  • Connection timeout: Prevents hanging connections
  • Error handling: MySQL errors are caught and handled appropriately

Development

# Install dependencies
pnpm install

# Run in development mode
pnpm dev

# Build
pnpm build

# Linting
pnpm lint
pnpm lint:fix

Architecture

  • MySQLConnection: Manages MySQL connection
  • MySQLMCPTools: Implements MCP tools
  • MySQLMCPServer: Main MCP server with stdio transport
  • Validation: Uses Zod for type and parameter validation

Connection Management

The server uses a connection-per-query approach for optimal reliability:

  • Fresh connections: Each query opens and closes its own connection
  • No persistent connections: Prevents timeout and stale connection issues
  • Automatic cleanup: Connections are always properly closed after each operation
  • Improved stability: Eliminates bugs caused by long-running connections

Limitations

  • Read-only operations only (SELECT, SHOW, DESCRIBE, EXPLAIN)
  • Connection-per-query (no connection pooling)
  • MySQL only (not PostgreSQL, SQLite, etc.)
  • Stdio transport only (no HTTP/WebSocket)