Esta página no está disponible en español. Se muestra la versión en inglés.

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: SELECT for reporting, plus INSERT, UPDATE, or DELETE only if a step must write. mysql_execute_sql runs 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 to performance_schema on the server.
  • Permission in your workspace to create connections and MCP instances (MCP write permission).

Connect in AgentRuntime

  1. 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 example db.example.com
    • mysql_port: optional, defaults to 3306
    • mysql_database: the database to query
    • mysql_user and mysql_password: the database login

    Click Save. The dialog also asks who can use the connection; choose the sharing option that fits your team.

  2. 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.

  3. Smoke test with an MCP step

    In Workflow Studio, create a workflow with a single mcp step using tool_name mysql_list_tables and tool_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 SELECT with mysql_execute_sql every morning, let an LLM step summarize the rows, and email the summary.
  • Database health check. Combine mysql_list_active_queries and mysql_list_table_fragmentation to flag long-running queries and tables that need optimizing.
  • Missing primary key audit. Use mysql_list_tables_missing_unique_indexes to find tables without a primary or unique key and create a task for each.
  • Approval before changes. Put a human approval step before a mysql_execute_sql call that updates or deletes production rows.

Tools

ToolWhat it does
mysql_execute_sqlRun 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_tablesList tables with columns and indexes, or just names.
mysql_get_query_planReturn the JSON execution plan (EXPLAIN FORMAT=JSON) for a statement.
mysql_list_active_queriesList running (non-sleeping) queries, longest first, with transaction details.
mysql_list_tables_missing_unique_indexesList tables that have no primary key or unique key.
mysql_list_table_fragmentationList the tables with the most free space inside their data files.
mysql_list_table_statsList 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. Returns rows or rows_affected.
  • mysql_list_tables: table_names (comma-separated filter; empty means all tables) and output_format (simple or detailed, default detailed).
  • mysql_get_query_plan: sql_statement (required).
  • mysql_list_active_queries: min_duration_secs (default 0) and limit (default 10).
  • mysql_list_tables_missing_unique_indexes: table_schema (defaults to your configured database) and limit (default 50).
  • mysql_list_table_fragmentation: table_schema, table_name, data_free_threshold_bytes (default 1), and limit (default 10).
  • mysql_list_table_stats: table_schema, table_name, sort_by (row_count, rows_fetched, rows_inserted, rows_updated, rows_deleted, or total_latency_secs; default total_latency_secs), and limit (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):

KeyRequiredDefaultDescription
mysql_hostYesnoneMySQL server hostname or IP address.
mysql_portNo3306MySQL server TCP port.
mysql_databaseYesnoneDefault database (schema) for queries.
mysql_userYesnoneMySQL username.
mysql_passwordYesnoneMySQL password.
mysql_query_timeout_secondsNo30Per-query timeout in seconds.

Troubleshooting

IssueFix
mysql connection config is incompleteOne 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 pingAgentRuntime could not log in. Check host, port, user, password, and that your firewall allows the connection.
only a single SQL statement is allowedThe sql contains a semicolon. Send one statement without semicolons.
mysql_list_table_stats returns nothing or errorsCheck that performance_schema is enabled and your user can read it.
Queries time outRaise mysql_query_timeout_seconds on the connection, or use mysql_get_query_plan to find a missing index.
Editar esta páginaagentruntime-io/agentruntime-docs