OpenCode MySQL Connector
by siimleetberg
README.md
# OpenCode MySQL Connector
A MySQL MCP (Model Context Protocol) server for OpenCode. 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 | — |
## 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
```bash
npm install
npm run build
```
## Usage
```bash
MYSQL_HOST=localhost \
MYSQL_USER=root \
MYSQL_PASSWORD=secret \
MYSQL_DATABASE=mysqldatabase \
MYSQL_PORT=3306 \
npm start
```
## License
ISC
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
ActivitySlowing
ResponsivenessNo issues