Skip to main content
Glama
OpenCode MySQL Connector

OpenCode MySQL Connector

by siimleetberg

MySQL MCP Connector

A MySQL MCP (Model Context Protocol) server for OpenCode, Claude Code and Claude Desktop. Provides tools to query and explore MySQL databases via stdio transport.

Environment Variables

Variable

Required

Default

MYSQL_HOST

Yes

—

MYSQL_PORT

No

3306

MYSQL_USER

Yes

—

MYSQL_PASSWORD

Yes

—

MYSQL_DATABASE

Yes

—

Related MCP server: MySQL MCP Server

Tools

Tool

Description

execute_query

Execute a MySQL SQL query (SELECT, INSERT, UPDATE, DELETE, DDL). Supports parameterized queries.

list_tables

List tables in a database with optional row counts and a LIKE name filter.

describe_table

Get table structure: columns, types, nullability, keys, and defaults.

explain_query

Get the EXPLAIN execution plan for a SQL query.

get_schema

Get the DDL (CREATE TABLE) for all tables in a database.

switch_schema

Switch the active database used by subsequent tools that do not specify one.

check_connection

Verify the connector can reach the MySQL server.

Prompts

Prompt

Description

show_table_context

Get a ready-to-use table schema context for a given table name.

Setup

npm install
npm run build

Usage

MYSQL_HOST=localhost \
MYSQL_USER=root \
MYSQL_PASSWORD=secret \
MYSQL_DATABASE=mysqldatabase \
MYSQL_PORT=3306 \
npm start

Claude Code

Register the server (use -s user for all projects or -s project to write a shared .mcp.json):

claude mcp add mysql -s user \
  -e MYSQL_HOST=localhost \
  -e MYSQL_USER=root \
  -e MYSQL_PASSWORD=secret \
  -e MYSQL_DATABASE=mysqldatabase \
  -e MYSQL_PORT=3306 \
  -- node /absolute/path/to/opencode_mysql_connector/dist/index.js

Equivalent .mcp.json (project scope; ${VAR} is expanded from your shell environment):

{
  "mcpServers": {
    "mysql": {
      "command": "node",
      "args": ["/absolute/path/to/opencode_mysql_connector/dist/index.js"],
      "env": {
        "MYSQL_HOST": "${MYSQL_HOST}",
        "MYSQL_USER": "${MYSQL_USER}",
        "MYSQL_PASSWORD": "${MYSQL_PASSWORD}",
        "MYSQL_DATABASE": "${MYSQL_DATABASE}",
        "MYSQL_PORT": "${MYSQL_PORT:-3306}"
      }
    }
  }
}

Verify with claude mcp list or /mcp inside a session. Tools appear as mcp__mysql__<tool>; the prompt runs as /mcp__mysql__show_table_context <table>.

Claude Desktop

Add to claude_desktop_config.json (macOS: ~/Library/Application Support/Claude/, Windows: %APPDATA%\Claude\), then restart Claude Desktop:

{
  "mcpServers": {
    "mysql": {
      "command": "node",
      "args": ["/absolute/path/to/opencode_mysql_connector/dist/index.js"],
      "env": {
        "MYSQL_HOST": "localhost",
        "MYSQL_USER": "root",
        "MYSQL_PASSWORD": "secret",
        "MYSQL_DATABASE": "mysqldatabase",
        "MYSQL_PORT": "3306"
      }
    }
  }
}

Claude Desktop does not inherit your shell PATH; if node is not found, use its absolute path (which node).

License

ISC

Available Tools

7 tools
check_connectionD

Inputs: no named parameters.

describe_tableD

Inputs: table (required), database.

execute_queryD

Inputs: sql (required), params.

explain_queryD

Inputs: sql (required).

get_schemaD

Inputs: database.

list_tablesD

Inputs: pattern, database.

switch_schemaD

Inputs: database (required).

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    C2.1/5.0

    Scored across 7 tools

    Disambiguation4/5

    Tool names are sufficiently distinct, but the absence of descriptions increases the risk of confusion between 'get_schema' and 'describe_table'.

    Naming Consistency5/5

    All tools follow a consistent verb_noun pattern in snake_case, making them predictable and easy to understand.

    Tool Count5/5

    7 tools is well-scoped for a MySQL connector, covering query execution, metadata retrieval, and schema management without being excessive.

    Completeness4/5

    The tool set covers core database operations, though missing explicit data manipulation tools (INSERT/UPDATE/DELETE) which are presumably handled by execute_query.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      B
      maintenance
      A MySQL MCP server for local stdio clients, enabling database queries and management with read-only/write modes, audit logging, and configurable security.
      524 npm
      MIT
    • A
      license
      C
      quality
      D
      maintenance
      Connects MCP-compatible clients like Claude to a MySQL database, enabling schema inspection and read/write queries via stdio transport.
      5
      896 npm
      1
      MIT
    • F
      license
      Not graded
      quality
      D
      maintenance
      A generic MCP server for MySQL operations, enabling listing databases/tables, describing schemas, running read-only SQL, and optionally executing write SQL with logging.
      1
      -
    • A
      license
      Not graded
      quality
      C
      maintenance
      MCP server that connects to SQL databases (SQLite, PostgreSQL, MSSQL, MySQL) and provides tools to run read-only queries, list schemas/tables, and manage connections via stdio transport.
      Apache 2.0