Skip to main content
Glama

@longlonga/mysql

A Model Context Protocol (MCP) server for interacting with MySQL databases. Provides tools for querying, inspecting, and modifying MySQL databases directly from Claude.

Installation

claude mcp add --scope user mysql \
  -e MYSQL_HOST=your-host \
  -e MYSQL_PORT=3306 \
  -e MYSQL_USER=your-user \
  -e MYSQL_PASSWORD=your-password \
  -e MYSQL_DATABASE=your-database \
  -- npx -y @longlonga/mysql

Via claude_desktop_config.json

{
  "mcpServers": {
    "mysql": {
      "command": "npx",
      "args": ["-y", "@longlonga/mysql"],
      "env": {
        "MYSQL_HOST": "your-host",
        "MYSQL_PORT": "3306",
        "MYSQL_USER": "your-user",
        "MYSQL_PASSWORD": "your-password",
        "MYSQL_DATABASE": "your-database"
      }
    }
  }
}

Related MCP server: MCP MySQL App

Configuration

Environment Variable

Required

Default

Description

MYSQL_HOST

Yes

—

MySQL server hostname or IP

MYSQL_PORT

No

3306

MySQL server port

MYSQL_USER

Yes

—

MySQL username

MYSQL_PASSWORD

Yes

—

MySQL password

MYSQL_DATABASE

No

—

Default database (can be overridden per tool call)

Tools

Tool

Description

mysql_list_databases

List all databases the user has access to

mysql_list_tables

List all tables in a database

mysql_describe_table

Get column definitions for a table

mysql_show_create_table

Get the full CREATE TABLE DDL statement

mysql_query

Execute a read-only SELECT/SHOW/EXPLAIN query

mysql_execute

Execute a write SQL statement (INSERT/UPDATE/DELETE/DDL)

mysql_table_stats

Get row count and size statistics for tables

Usage Examples

Once connected, you can ask Claude things like:

  • "List all tables in my database"

  • "Describe the structure of the users table"

  • "Query the last 10 orders"

  • "How many rows are in each table?"

License

MIT

Available Tools

7 tools
mysql_describe_tableDescribe Table StructureA
Read-onlyIdempotent

Get column definitions for a MySQL table (equivalent to DESCRIBE or SHOW COLUMNS).

Args:

  • table (string, required): Table name

  • database (string, optional): Database name. Uses MYSQL_DATABASE if omitted.

  • response_format ('markdown' | 'json'): Output format (default: 'markdown')

Returns column info: Field, Type, Null, Key, Default, Extra

Inputs: table (required), database, response_format.

mysql_executeExecute Write SQLA
Destructive

Execute a write SQL statement (INSERT, UPDATE, DELETE, DDL).

WARNING: This tool modifies data. Use with caution.

Args:

  • sql (string, required): SQL statement. Use ? placeholders for parameters.

  • params (array, optional): Bind parameters corresponding to ? placeholders.

  • database (string, optional): Database name. Uses MYSQL_DATABASE if omitted.

Returns: { affectedRows: number, insertId: number, changedRows: number }

Examples:

  • sql: "UPDATE biz_exhaust_hy SET DELETE_FLAG = 'DELETED' WHERE ID = ?", params: [123]

  • sql: "INSERT INTO my_table (name) VALUES (?)", params: ["test"]

Inputs: sql (required), params, database.

mysql_list_databasesList MySQL DatabasesA
Read-onlyIdempotent

List all databases on the MySQL server.

Returns database names the current user has access to.

Returns:

  • markdown: formatted list

  • json: { databases: string[] }

Inputs: response_format.

mysql_list_tablesList Tables in DatabaseA
Read-onlyIdempotent

List all tables in a MySQL database.

Args:

  • database (string, optional): Database name. Uses MYSQL_DATABASE if omitted.

  • response_format ('markdown' | 'json'): Output format (default: 'markdown')

Returns:

  • markdown: formatted table list

  • json: { database: string, tables: string[], count: number }

Inputs: database, response_format.

mysql_queryExecute SELECT QueryA
Read-only

Execute a read-only SELECT query against MySQL.

Only SELECT and SHOW/EXPLAIN statements are permitted. Use mysql_execute for write operations.

Args:

  • sql (string, required): SQL SELECT statement. Use ? placeholders for params.

  • params (array, optional): Bind parameters corresponding to ? placeholders.

  • database (string, optional): Database name. Uses MYSQL_DATABASE if omitted.

  • limit (number, optional): Max rows to return (default: 100, max: 1000).

  • response_format ('markdown' | 'json'): Output format (default: 'json')

Returns:

  • json: { rows: object[], count: number, has_more: boolean }

  • markdown: formatted table

Examples:

  • sql: "SELECT * FROM biz_exhaust_yg WHERE jcrq = ? LIMIT 10", params: ["2026-03"]

  • sql: "SELECT COUNT(*) as cnt FROM biz_exhaust_hy"

Inputs: sql (required), params, database, limit, +1 more.

mysql_show_create_tableShow CREATE TABLE StatementA
Read-onlyIdempotent

Get the full CREATE TABLE DDL statement for a table.

Args:

  • table (string, required): Table name

  • database (string, optional): Database name. Uses MYSQL_DATABASE if omitted.

Returns the complete CREATE TABLE SQL with all indexes, constraints, and engine settings.

Inputs: table (required), database.

mysql_table_statsGet Table StatisticsA
Read-onlyIdempotent

Get row count and size statistics for tables in a database.

Args:

  • database (string, optional): Database name. Uses MYSQL_DATABASE if omitted.

  • table (string, optional): Filter to a specific table. If omitted, returns all tables.

  • response_format ('markdown' | 'json'): Output format (default: 'markdown')

Returns per table: table_name, row_count, data_size_mb, index_size_mb, engine, create_time

Inputs: database, table, response_format.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.2/5.0

    Scored across 7 tools

    Disambiguation5/5

    Each tool targets a distinct operation: reading, writing, describing schema, listing databases/tables, showing DDL, and table statistics. No ambiguity between tools.

    Naming Consistency4/5

    All tools share the 'mysql_' prefix and mostly follow verb_noun pattern (e.g., describe_table, list_databases). However, 'mysql_execute' and 'mysql_query' are verb-only, which slightly deviates from the pattern.

    Tool Count5/5

    With 7 tools, the server covers essential MySQL interactions without being bloated. Each tool serves a clear purpose, making it easy for an agent to navigate.

    Completeness4/5

    The set covers core CRUD, schema inspection, and metadata retrieval. DDL operations are handled via mysql_execute, so no major gaps are present. Minor missing features like server version are not critical.

    Maintenance

    ActivityInactive
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      A Model Context Protocol (MCP) server that enables AI assistants to interact with MySQL databases by executing SQL queries and checking database connectivity.
      MIT
    • A
      license
      B
      quality
      D
      maintenance
      A Model Context Protocol server that enables AI models to interact with MySQL databases, providing tools for querying, executing statements, listing tables, and describing table structures.
      5
      290 npm
      MIT
    • A
      license
      B
      quality
      D
      maintenance
      A Model Context Protocol server that enables AI models to interact with MySQL databases through a standardized interface, providing tools for querying, executing commands, and managing database schemas.
      7
      MIT