Model, Audio, and MCP
$.model asks a model with the credentials of the session.
$.audio plays a sound or speaks text.
$.mcp calls a tool of a connected MCP server.
A model call bills to the plan or key of the person, so keep requests small.
A deny from a hook refuses a call. maxTokens is 1024 by default and goes up to 64000 or the output limit of the model.
Official pages: Use the Mods API, Mods Reference. Source: the Mod API type file of the 2.1.312 program (schemas/claude-code.d.ts).
"Run time" appears in a "Where it can be used" cell. It means in a hook, in a closure that a hook drew, or in a timer callback. It does not mean inside register.
Example
This hook answers /triage by asking a small model for a label.
on("command.run", { command: "triage" }, async ($, e) => {
const r = await $.model.complete({
model: "haiku",
system: "Reply with one word: bug, feature, or question.",
prompt: e.args,
maxTokens: 20,
});
return { text: `Label: ${r.isAnswered ? r.text.trim() : "unknown"}` };
});
Members
| Item | Status | What it does | How it works | Where it can be used |
|---|---|---|---|---|
$. | Documented: An official docs page names this item. | Runs one text completion through the session's own API client. Resolves the reply's text and cost, or why there is no text. | (request, options?) => Promise<Model. Asks the model once, with no tools and no history. Only a request that the engine refuses to send rejects. | Run time. |
$. | Documented: An official docs page names this item. | Runs one tool-less completion over the session's own transcript as the main thread last sent it. The API then serves that prefix from its cache. | (request:. Repeats the main thread's last request with your prompt added. The call denies every tool. Always resolves a result. | Run time. |
$. | Documented: An official docs page names this item. | Picks one of labels for text with one completion and a fixed classifier prompt. | (text, labels, options?) => Promise<string | undefined>. Needs 2 or more labels. Resolves undefined if the model names none. | Run time. |
$. | Documented: An official docs page names this item. | Plays one audio clip, starting now. Clips do not queue, so two calls play together (a bed under speech). | (clip, options?) => Promise<void>. afplay plays it on macOS. Linux and Windows terminals play nothing. | Run time. |
$. | Documented: An official docs page names this item. | Speaks text with the platform's own synthesizer (say on macOS). Plain text. | (text, options?) => Promise<Speak. Utterances queue. Rejects if there is no synthesizer. | Run time. |
$. | Documented: An official docs page names this item. | Calls tool on one of the engine's connected MCP servers, with the engine's own connection. | (server, tool, args?) => Promise<Mcp. No permission prompt appears, because the plugin's call is the grant. | Run time. |
$. | Documented: An official docs page names this item. | Connects one of the MCP servers that this plugin's own manifest lists, if the session has not already. | (server) => Promise<Mcp. Listing a server defers nothing, so refuse its calls at tool. to hold them back. | The server key must be listed in this plugin's manifest. |
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 |
|---|---|---|---|
model. | Documented: An official docs page names this item. | $.. The signal does not cross. It aborts the call. | Input Model. Value Model. |
model. | Documented: An official docs page names this item. | $. | Input { text:. Value string | undefined. |
model. | Documented: An official docs page names this item. | $. | Input Model. Value Model. |
audio. | Documented: An official docs page names this item. | The clip and how to play it (should, gain). | Input { clip:. Value void. |
audio. | Documented: An official docs page names this item. | $. | Input Speak. Value Speak. |
mcp. | Documented: An official docs page names this item. | $. | Input { server:. Value Mcp. |
mcp. | Documented: An official docs page names this item. | $. | Input { server:. Value Mcp. |
Related Pages
- Mod API Overview
- Tool, Command, and Config
- Model, Audio, and MCP Types (requests, answers, and MCP types)