mysql-mcp
MySQL MCP Server
A read-only MySQL MCP server for OpenCode. Exposes a single safe_query tool that executes SELECT and SHOW queries while blocking all write operations.
Install
git clone <this-repo>
cd mysql-mcp
npm installConfiguration
Add the following to your opencode.json (or opencode.jsonc):
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"local-safe-mysql": {
"type": "local",
"enabled": true,
"command": [
"node",
"/ABSOLUTE_PATH_TO_SCRIPT/mysql-mcp/server.js"
],
"environment": {
"DB_HOST": "HOST",
"DB_PORT": "3306",
"DB_USER": "USER",
"DB_PASSWORD": "PASSWORD",
"DB_NAME": "DBNAME"
}
}
}
}Replace the placeholder values:
Variable | Description |
| Absolute path to the |
| MySQL host (e.g. |
| MySQL port (default |
| MySQL username |
| MySQL password |
| Database name |
Tool
safe_query
Run a read-only SQL query. Write operations (INSERT, UPDATE, DELETE, DROP, ALTER, CREATE, REPLACE, TRUNCATE, GRANT, REVOKE, CALL, LOAD, HANDLER, RENAME) are blocked.
Input: { "sql": "SELECT * FROM users LIMIT 10" }