Send Prompts
👨💼 Our users expect the "Summarize" button to instantly craft a short, insightful take on the entry they're viewing. To make that happen, the UI needs to send a natural-language prompt to the host via our MCP bridge, then show the result without a page reload. If we don't deliver, people lose trust and the feature feels broken.
Here's the pattern you'll use from components:
// Send a prompt message to the host
await sendMcpMessage(
'prompt',
{
prompt:
'Please ask CafeLedger get_balance for account espresso-ops and summarize the budget health.',
},
{ signal: unmountSignal },
)
What you need to build:
- Add a new
'prompt'
message type toapp/utils/mcp.ts
so the bridge can validate payloads. - Add a function overload for
sendMcpMessage('prompt', payload, options)
that mirrors the'link'
overload but accepts{ prompt: string }
. - In the summarize button component, get an
AbortSignal
viauseUnmountSignal()
and callsendMcpMessage('prompt', { prompt }, { signal })
.
👨💼 Let's wire up the prompt path so pressing "Summarize" works.