miniapp.json and handle it in
your background layer. Mentra AI reads your declarations and decides when to call
them.
Actions map 1:1 onto MCP tools (id to name,
description, parameters to inputSchema), so the same declarations can be
surfaced to external agents later.
Declare an action
List your actions inminiapp.json. The description is the contract Mentra AI
reads, so say when the action should be used.
miniapp.json
Handle it
Register a handler in your background layer withsession.actions.handle. Its
return value goes back to the caller.
background/index.ts
- One handler per
id. Registering the sameidtwice throws. - A thrown handler rejects the caller, and your error message comes back to them.
- The return value is serialized to the caller (max 256 KB).
handlereturns a function that deregisters the handler.
How a call reaches you
When Mentra AI invokes one of your actions, the host headless-wakes your miniapp if it isn’t already running: it spawns your background context (no UI, no foreground change, so whatever the user is doing is undisturbed), waits for your handlers to register, delivers the call, and returns your handler’s result. Your miniapp keeps running afterward until it’s stopped. Because an inbound call waits only briefly for a just-woken miniapp to register, callsession.actions.handle at the top of your
registerMiniapp
handler rather than after async setup.
Exposing actions with
handle is open to every miniapp, so your miniapp is
callable by Mentra AI today. The calling side (discovering, launching, and
invoking other miniapps) is restricted to system miniapps. See
System Miniapp APIs.
