OpenCode MySQL Connector
Query, inspect, and manage a MySQL database through MCP tools.
Execute SQL queries (SELECT, INSERT, UPDATE, DELETE, DDL), with optional string parameters.
List tables, optionally filtered by pattern or scoped to a database.
Describe table structure, including columns, types, nullability, keys, and defaults.
Get EXPLAIN execution plans for SQL queries.
Retrieve CREATE TABLE DDL for all tables in a database.
Switch the active database for subsequent tools.
Verify connectivity to the MySQL server.
Allows interaction with MySQL databases, enabling AI agents to execute SQL queries (SELECT, INSERT, UPDATE, DELETE, DDL), list and describe tables, get table schemas, explain query execution plans, and verify database connectivity.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@OpenCode MySQL Connector list all tables with row counts"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
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 |
| Yes | — |
| No |
|
| Yes | — |
| Yes | — |
| Yes | — |
Related MCP server: MySQL MCP Server
Tools
Tool | Description |
| Execute a MySQL SQL query (SELECT, INSERT, UPDATE, DELETE, DDL). Supports parameterized queries. |
| List tables in a database with optional row counts and a |
| Get table structure: columns, types, nullability, keys, and defaults. |
| Get the EXPLAIN execution plan for a SQL query. |
| Get the DDL (CREATE TABLE) for all tables in a database. |
| Switch the active database used by subsequent tools that do not specify one. |
| Verify the connector can reach the MySQL server. |
Prompts
Prompt | Description |
| Get a ready-to-use table schema context for a given table name. |
Setup
npm install
npm run buildUsage
MYSQL_HOST=localhost \
MYSQL_USER=root \
MYSQL_PASSWORD=secret \
MYSQL_DATABASE=mysqldatabase \
MYSQL_PORT=3306 \
npm startClaude 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.jsEquivalent .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 toolscheck_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
Scored across 7 tools
Tool names are sufficiently distinct, but the absence of descriptions increases the risk of confusion between 'get_schema' and 'describe_table'.
All tools follow a consistent verb_noun pattern in snake_case, making them predictable and easy to understand.
7 tools is well-scoped for a MySQL connector, covering query execution, metadata retrieval, and schema management without being excessive.
The tool set covers core database operations, though missing explicit data manipulation tools (INSERT/UPDATE/DELETE) which are presumably handled by execute_query.
Maintenance
Related MCP Connectors
The official MCP Server for the Mux API
An MCP server that provides read access to your cloud storage providers, bank accounts and more.
Related MCP Servers
- AlicenseNot gradedqualityBmaintenanceA MySQL MCP server for local stdio clients, enabling database queries and management with read-only/write modes, audit logging, and configurable security.524 npmMIT
- AlicenseCqualityDmaintenanceConnects MCP-compatible clients like Claude to a MySQL database, enabling schema inspection and read/write queries via stdio transport.5896 npm1MIT
- FlicenseNot gradedqualityDmaintenanceA generic MCP server for MySQL operations, enabling listing databases/tables, describing schemas, running read-only SQL, and optionally executing write SQL with logging.1-
- AlicenseNot gradedqualityCmaintenanceMCP 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