Tool, Command, and Config
$.tool lists, checks, calls, and registers tools.
$.command does the same for slash commands.
$.config lists and sets the rows of the /config menu.
A tool or command that a mod registers is served by a hook on tool.call or command.run.
A deny from a tool.call, tool.check, or config.set hook stops the action. A registered tool is named mcp__<plugin>__<name>.
Official pages: Use the Mods API, Mods Reference. Source: the program (types-2.1.304.d.ts).
In a "Where it can be used" cell, "Run time" means in a hook, in a closure that a hook drew, or in a timer callback. It does not mean inside register.
Example
This mod adds a /standup command.
on('session.start', async ($, e, next) => {
await $.command.register({ name: 'standup', description: 'Summarize what changed today', argumentHint: '[days]' })
return next(e)
})
on('command.run', { command: 'standup' }, async ($, e) => ({ text: 'Summary for ' + (e.args || '1') + ' day(s)' }))
Members
| Item | Status | What it does | How it works | Where it can be used |
|---|---|---|---|---|
$. | Documented | Returns the tools the model can call now, built-in and MCP, in the order the model sees them. | () => Promise<Tool. | Run time. |
$. | Documented | Calls a tool. It is the event tool., the same call the engine makes for the model, under a tool_ of its own. | Runs a tool through the hooks, the permission check, and the tool. Rejects for an unknown name or an aborted call. Example: await $.. | Run time. |
$. | Documented | Asks for the permission decision for a tool call now. It is the event tool.. Resolves { decision, reason?, .... | (input:. Nothing runs and no dialog opens. | Run time. |
$. | Documented | Declares a tool the model can call from the next prompt on: the name, description, and input schema of mcp__. | (tool:. Serve it with a tool. hook. A name registered again is replaced. | After the session binds at session. (rejects before). |
$. | Documented | Returns the slash commands the person can run now, built-in, plugin, and MCP, in typeahead order. | () => Promise<Command. | Run time. |
$. | Documented | Runs a slash command as if the person typed /. It is the event command.. It queues and runs once the session is idle. | (input:. Rejects an unknown name. | Run time. |
$. | Documented | Declares the slash command / for this session, listed in the typeahead from the next keystroke on. | (command:. Serve it with a command. hook. A built-in's name is refused. | Run time. |
$. | Documented | Returns the rows the / menu would draw now, in its order, each with its value, kind, owner, and lock. | () => Promise<Config. Lists the rows after every config. hook. A hidden row is left out. | Run time. |
$. | Documented | Changes one row as if the person did in the menu. It is the event config. with origin { kind:. | (input:. Resolves { value } or { deny }. Rejects a key that no row has. | Run time. |
Engine Events
| Item | Status | What it does | How it works | Where it can be used |
|---|---|---|---|---|
tool. | Documented | Fires when the engine is about to run a tool. Each next(e) runs the hooks beneath, then core (the permission prompt, the tool). | Input Tool. Result { result, context? } or { deny }. { deny: refuses the call. A guard that fails is skipped and the tool runs. | on('tool.. Also $.. |
tool. | Documented | Fires when the engine decides whether a tool call may run, after the tool. and Pre hooks and before the mode settles an ask. | Input Tool, which carries is when the call is read-only (new in 2.1.304). Result { decision, reason?, .... An ask may carry decider: (new in 2.1.304): only the permission dialog or a host's callback can approve it, and where nobody can be asked (dont mode, avoid-prompts, headless) it is refused with the mod's reason. next(e) gives the engine's verdict. A guard that fails is skipped, so add a .. | on('tool.. Also $.. |
tool. | Documented | Fires when the engine first renders the tool's schema in a session. next(e) resolves to { description, is. | Input Tool. The answer is cached until $.. | on('tool.. In tests: $. on the test engine (not on a hook's $). |
command. | Documented | Fires when a slash command is about to run. next(e) resolves to { text }, its output. | Input Command. Rewrite args with next, or return { text } to answer in its place. | on('command.. Also $.. |
command. | Documented | Fires once for each command, when the engine lists it for the typeahead and /. next(e) resolves to { description, argument. | Input Command. Cached for the session until $.. | on('command.. In tests: $. on the test engine (not on a hook's $). |
config. | Documented | Fires when a / row is about to change, from the menu or a plugin's $.. next(e) resolves to { value } once written. | Input Config. Result { value } or { deny }. { deny: leaves the row as it is. A value of the wrong kind is refused. | on('config.. Also $.. |
config. | Documented | Fires once for each / row, when the menu lists it and for $.. next(e) resolves to { label, description, is. | Input Config. Cached until $.. | on('config.. In tests: $. on the test engine (not on a hook's $). |
Events Raised by These Calls
For each call, a hook above the caller returns next(e), { deny: reason }, or { value }.
| Item | Status | The argument | Input and value |
|---|---|---|---|
tool. | Documented | $. | Input No. Value Tool. |
tool. | Documented | $. | Input Registered. Value { tool:. |
command. | Documented | $. | Input No. Value Command. |
command. | Documented | $. | Input Command. Value { command:. |
config. | Documented | $. | Input No. Value Config. |
Related Pages
- Mod API Overview
- Turn and Prompt
- Tool, Command, and Config Types (tool call, check, command, and config types)