MySQL
Connects to a MySQL or MariaDB database via the standard database/sql MySQL driver. An agent can run read-only SELECT queries, execute write/DDL statements, describe a table's columns, and list tables in the database.
Add to an agent node's tools array with _node_type: "tool-mysql". See Connector Reference — How connectors are used.
Authentication
| Field | Required | Description |
|---|---|---|
dsn | Yes* | Full MySQL DSN, e.g. user:pass@tcp(host:3306)/db?parseTime=true. If set, all other fields below are ignored. |
host | Yes* | Database host. Defaults to localhost if user and database are set but host is empty. |
port | No | Database port. Defaults to 3306. |
user | Yes* | Database user. |
password | No | Database password. |
database | Yes* | Database name. |
* Either dsn must be set, or user and database (with optional host, port, password) must all be set to build a DSN of the form user:password@tcp(host:port)/database?parseTime=true&multiStatements=true. If neither is satisfiable, the connector returns an error.
{
"name": "mysql",
"_node_type": "tool-mysql",
"host": "db.internal",
"port": "3306",
"user": "agent",
"password": "{{ secret.MYSQL_PASSWORD }}",
"database": "app_production"
}
Tools
mysql_query
Run a SELECT query against MySQL/MariaDB and return results.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
query | string | Yes | SELECT query to execute |
max_rows | number | No | Maximum rows to return (default 100, hard cap 500) |
Returns: A |-separated table: a header row of column names, a separator line, then up to max_rows data rows (NULL for null values, otherwise %v-formatted), followed by a final (N rows) count line.
mysql_execute
Execute an INSERT, UPDATE, DELETE, or DDL statement against MySQL/MariaDB.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
statement | string | Yes | INSERT UPDATE DELETE or DDL statement |
Returns: OK: N rows affected, last_insert_id=<id>.
mysql_describe_table
Describe the columns of a MySQL table.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
table | string | Yes | Table name to describe |
Returns: A |-separated table — a header row from DESCRIBE `<table>` (typically Field | Type | Null | Key | Default | Extra) followed by one row per column.
mysql_list_tables
List all tables in the MySQL database.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
database | string | No | Database to list tables for (default: current) |
Returns: A newline-separated list of table names, from SHOW TABLES (or SHOW TABLES FROM `<database>` if database is set).