MySQL connector
Run SQL, inspect schemas, and check the health of MySQL databases from AgentRuntime workflow steps.
En esta página
The mysql connector lets workflow steps run SQL against a MySQL database you own. It can read and write data, list tables with their columns and indexes, show query plans, and report on slow queries, fragmented tables, and tables without a primary key. Use it for scheduled reports, for moving data between systems, or for keeping an eye on database health. If you also run PostgreSQL, see the Postgres connector.
Prerequisites
- A MySQL server that AgentRuntime can reach over the network. Allow inbound connections to its host and port in your firewall or security group as your setup requires.
- The server host, port (3306 unless you changed it), database name, and a user and password for that database. Create a dedicated database user instead of using an administrator account.
- Privileges that match what your workflows do:
SELECTfor reporting, plusINSERT,UPDATE, orDELETEonly if a step must write.mysql_execute_sqlruns whatever statement you give it, so a read-only user is the safest way to keep a workflow read-only. - For
mysql_list_table_stats, access toperformance_schemaon the server. - Permission in your workspace to create connections and MCP instances (MCP write permission).
Connect in AgentRuntime
- Create a connection
Open Connections in the Console and click New custom connection. Optionally set a Display name, then under Credentials add one row per setting (Key and Value):
mysql_host: server hostname or IP, for exampledb.example.commysql_port: optional, defaults to3306mysql_database: the database to querymysql_userandmysql_password: the database login
Click Save. The dialog also asks who can use the connection; choose the sharing option that fits your team.
- Add the mysql MCP instance
Open MCP, click Add connectors, click the mysql connector, then Add to workspace. Open Instance config, select your connection in the Connection picker, make sure the profile is active, and save.
- Smoke test with an MCP step
In Workflow Studio, create a workflow with a single
mcpstep usingtool_namemysql_list_tablesandtool_args{"output_format": "simple"}, then run it. You should see the table names in your database.
See Authentication for how connections are bound to MCP instances.
What you can build
- Scheduled report. Run a
SELECTwithmysql_execute_sqlevery morning, let an LLM step summarize the rows, and email the summary. - Database health check. Combine
mysql_list_active_queriesandmysql_list_table_fragmentationto flag long-running queries and tables that need optimizing. - Missing primary key audit. Use
mysql_list_tables_missing_unique_indexesto find tables without a primary or unique key and create a task for each. - Approval before changes. Put a
humanapproval step before amysql_execute_sqlcall that updates or deletes production rows.
Tools
| Tool | What it does |
|---|---|
mysql_execute_sql | Run one SQL statement. Statements starting with SELECT, WITH, SHOW, DESCRIBE, DESC, or EXPLAIN return rows; anything else (INSERT, UPDATE, DELETE, DDL) changes data and returns rows_affected. Writes data. |
mysql_list_tables | List tables with columns and indexes, or just names. |
mysql_get_query_plan | Return the JSON execution plan (EXPLAIN FORMAT=JSON) for a statement. |
mysql_list_active_queries | List running (non-sleeping) queries, longest first, with transaction details. |
mysql_list_tables_missing_unique_indexes | List tables that have no primary key or unique key. |
mysql_list_table_fragmentation | List the tables with the most free space inside their data files. |
mysql_list_table_stats | List table I/O statistics from performance_schema. |
Parameters (all are optional unless marked required):
mysql_execute_sql:sql(required). A semicolon anywhere in the text is rejected, so send one statement and avoid semicolons inside string values. Returnsrowsorrows_affected.mysql_list_tables:table_names(comma-separated filter; empty means all tables) andoutput_format(simpleordetailed, defaultdetailed).mysql_get_query_plan:sql_statement(required).mysql_list_active_queries:min_duration_secs(default 0) andlimit(default 10).mysql_list_tables_missing_unique_indexes:table_schema(defaults to your configured database) andlimit(default 50).mysql_list_table_fragmentation:table_schema,table_name,data_free_threshold_bytes(default 1), andlimit(default 10).mysql_list_table_stats:table_schema,table_name,sort_by(row_count,rows_fetched,rows_inserted,rows_updated,rows_deleted, ortotal_latency_secs; defaulttotal_latency_secs), andlimit(default 10).
For list tools, limit is capped at 1000.
Example
List the 20 longest-running queries that have been running for at least 5 seconds:
{
"id": "slow-queries",
"type": "mcp",
"name": "Find slow queries",
"instance_id": "REPLACE_MYSQL_INSTANCE",
"tool_name": "mysql_list_active_queries",
"tool_args": {
"min_duration_secs": 5,
"limit": 20
},
"timeout_s": 30
}Use the results in a later step with {{steps.slow-queries.result.queries}}.
To run your own query, use mysql_execute_sql with {"sql": "SELECT id, email, total FROM orders WHERE status = 'pending' LIMIT 100"} and read {{steps.<step id>.result.rows}}.
Configuration
Connection keys (the connection's Key names):
| Key | Required | Default | Description |
|---|---|---|---|
mysql_host | Yes | none | MySQL server hostname or IP address. |
mysql_port | No | 3306 | MySQL server TCP port. |
mysql_database | Yes | none | Default database (schema) for queries. |
mysql_user | Yes | none | MySQL username. |
mysql_password | Yes | none | MySQL password. |
mysql_query_timeout_seconds | No | 30 | Per-query timeout in seconds. |
Troubleshooting
| Issue | Fix |
|---|---|
mysql connection config is incomplete | One of mysql_host, mysql_database, mysql_user, or mysql_password is missing from the connection, or the instance profile is not wired to it. |
Error starting with mysql ping | AgentRuntime could not log in. Check host, port, user, password, and that your firewall allows the connection. |
only a single SQL statement is allowed | The sql contains a semicolon. Send one statement without semicolons. |
mysql_list_table_stats returns nothing or errors | Check that performance_schema is enabled and your user can read it. |
| Queries time out | Raise mysql_query_timeout_seconds on the connection, or use mysql_get_query_plan to find a missing index. |