ECA Tool bridges ECA and the Tool API in two directions:
- Every tool registered with the Tool API becomes an ECA action, so an ECA model can invoke it.
- Every ECA model event of type "Tool" becomes a tool, so an AI agent or any other Tool API consumer can invoke an ECA model.
Running a tool from an ECA model
Every tool plugin registered with the Tool API, except the tools that this module itself derives from ECA models (see below), is available in ECA's action list as Tool: . Configuring this action lets you set each tool input, name the ECA tokens that receive the tool's outputs, and name a token that receives the structured execution result.
Input modes
Each tool input is configured in one of up to three modes, selected per input:
| Mode | Available for | Behavior |
|---|---|---|
| Token or plain value (default) | every input | If the configured string is a bare ECA token holding data, the token's own value â including entities, arrays and nested structures â is handed to the tool unchanged. Otherwise the string is token-replaced and handed over as text. |
| YAML | inputs with data type map or list, or any input marked as accepting multiple values |
The configured text is token-replaced, then parsed as YAML. |
| Native widget | inputs whose typed-data adapter is string, text, email, number, boolean or select
|
The Tool API's own form element for that data type. The list, map and entity adapters are not offered here because they need a nested form structure that ECA's flat action configuration form cannot provide; use Token or YAML mode for those instead. |
Leaving an input empty lets the tool apply its own default. FALSE, 0 and '0' are valid configured values and are all handed to the tool.
Outputs and the result token
Each tool output can be named to an ECA token (default: the output's own name); leave the field empty to discard that output.
The result token (default name tool_result) receives a structured value with these properties:
| Property | Type | Meaning |
|---|---|---|
success |
boolean | Whether the tool executed successfully. |
message |
string | The tool's result message. |
failure_category |
string | One of Input, Access, Runtime, or an empty string on success. |
hints |
list of strings | Hints collected while formatting the result. |
Example
A model that sends an email through a hypothetical mail_send tool, reading the recipient from a token and branching on the outcome:
- Action
Tool: Send email- Input
to, mode "Token or plain value", value[node:author:mail] - Input
subject, mode "Native widget", valueYour content was published - Output
message_idnamed to tokensent_message_id - Result token name
mail_result
- Input
- Condition: token
mail_result:successequalstrue- On true: log
sent_message_id. - On false: log
mail_result:messageandmail_result:failure_category.
- On true: log
calculateDependencies() adds a module dependency on the tool's provider module, so exporting this model records that the site needs the module that supplies mail_send.
Exposing an ECA model as a tool
Add an event of type "Tool" to an ECA model. Each such event becomes one tool, identified internally as eca:::.
Event configuration keys
| Key | Type | Meaning |
|---|---|---|
description |
text, required | Summarizes what the tool is for. Consumed directly by an AI agent for context. |
arguments |
YAML | The inputs a caller passes into the tool. Each top-level key becomes the name of an ECA token available to successors of the event. |
outputs |
YAML | The values the tool returns. Each top-level key becomes a named output that the "Set tool output" action can target. Left empty, the event declares a single output named tool_output with data type any. |
operation |
select: explain, read, transform, trigger, write
|
The nature of what the tool does; callers use it to decide whether it modifies state. Default: write. |
destructive |
boolean | Whether running the tool has consequences that cannot be undone; callers use it to prompt for confirmation. Default: enabled. |
permission |
text | The permission a caller must hold to execute this tool. Empty means the execute eca tools permission is required (see Access control). |
The arguments/outputs YAML grammar
Both configuration values share one grammar, one entry per input or output:
plain:
data_type: string
label: 'Plain'
description: 'A plain input.'
account:
data_type: 'entity:user'
label: 'Account'
description: 'An account.'
items:
data_type: list
label: 'Items'
description: 'A list of items.'
item_definition:
data_type: string
label: 'Item'
description: 'A single item.'
settings:
data_type: map
label: 'Settings'
description: 'A map of settings.'
properties:
inner:
data_type: integer
label: 'Inner'
description: 'An inner property.'
annotated:
data_type: string
label: 'Annotated'
description: 'Carries every annotation.'
required: true
multiple: false
default_value: ~
locked: false
examples: ['alpha', 'beta']
constraints:
Length: { max: 255 }
Notes:
-
data_typeis required; every other key is optional. -
lockedandexamplesare read forargumentsonly;outputsignores them. -
item_definition(fordata_type: list) andproperties(fordata_type: map) recurse into the same grammar. -
data_type: entityor anyentity:value builds an entity-typed definition;listandmapbuild their respective container definitions; every other value builds a plain scalar definition. - An entry without a
data_typekey, or one whose value is a non-array, is silently dropped.
Writing an output: the "Set tool output" action
Inside the event's reaction chain, use the "Set tool output" action to provide a value for a declared output:
-
output_name: the name of the output to write, matching a top-level key inoutputs. Left empty, it targets the default outputtool_output. -
output: the value, either a token, a plain string, or YAML when "Interpret above config value as YAML format" is enabled.
Setting an output name that the event does not declare, when the event declares at least one named output, fails the action's access check rather than being silently dropped.
Access control
Executing an ECA tool requires the execute eca tools permission, unless the backing event's permission key names a different permission â in that case only the named permission is checked. The execute eca tools permission is declared with restrict access: true because an ECA model can run arbitrary business logic; grant it only to trusted roles.
In the other direction, the Tool action that wraps a Tool API tool for use inside an ECA model calls that tool's own access() check before executing it. A tool's access control is therefore always enforced, whether it is called directly through the Tool API or through an ECA model.
Requirements reporting
A tool's checkRequirements() is advisory: it is surfaced as a warning when configuring the Tool action, and in drush tool:info, but it never blocks configuration or execution. For a tool derived from an ECA model, unmet requirements mean the backing model is missing, disabled, or no longer contains the event that the tool was derived from.
Project information
- Ecosystem: ECA: Event - Condition - Action, Tool API
1 site reports using this module
- By jurgenhaas on , updated
Stable releases for this project are covered by the security advisory policy.
There are currently no supported stable releases.
Releases
Development version: 1.0.x-dev updated 22 Sep 2026 at 15:36 UTC
