Agent tools
Run server tools and return the outcome of actions performed by the host page.
Configure tools in document.tools. The server runs HTTP and MCP tools and
keeps their authorization credentials on the server. For published sessions,
Studio loads function declarations from
document.tools.functionDeclarations in the published revision. A function
name can contain up to 64 Latin letters, digits, underscores, or hyphens.
An experience can declare up to 128 tools.
Run an action on the host page
The player sends an action event with action, arguments, and
requestId. The action name comes from the declaration's clientMethod,
or from the function name if that field is unset.
Validate the action against your host's supported actions, execute it, and
respond with host.action-result. See the
host-page bridge for the message envelope.
| Field | Value |
|---|---|
action, requestId | Copy both values from the event |
status | executed or rejected |
message | Short explanation for the agent |
result | Data to return to the agent |
context | Snapshot of the host screen |
The agent receives the actual result. Without a response within eight
seconds, the player marks the action rejected. The request ID and visit
generation prevent late responses from reaching a later guest. The standalone
/s/{slug} player rejects host actions immediately because it has no host page.
Register a handler with the Embed SDK
registerTool(method, handler) sends host.action-result for you. The
handler's return value becomes result. An exception produces
rejected. The response limit is 12,000 characters.
const unregister = avatar.registerTool("show_place", async ({ placeId }) => {
await map.open(placeId);
return { opened: placeId };
});Call unregister() when the host removes the handler. For browser-rendered
2D and VRM characters, the player handles avatar_set_emotion and
avatar_gesture locally.