# How the Help widget demo works

This demo shows connections and approvals: the agent reaches Ledgerly's own systems through an MCP connection, and a refund waits for a person to approve it. Watch the strip above the billing page. It lights when a Ledgerly operation such as `list_charges` runs, and says so when a refund is refused for approval.

Ledgerly is a made-up billing product. Its customer, Harbour & Finch Studio, has been charged $588.00 twice on the first of this month. You open the help bubble in the corner and ask why, and to refund the duplicate.

## The agent is configuration

`ledgerly-help` is a Mindset agent defined by five prompt fields, a model and a list of what it may use. There's no agent code in this page. The prompt makes it a calm billing specialist with one hard rule: it never says a refund happened unless the refund tool returned a refund id in this conversation. The whole definition lives in `demos/ledgerly-help/`, and the repo is applied to the org through the admin MCP.

## Ledgerly's own MCP server

The billing data doesn't live in Mindset. Ledgerly runs its own MCP server, and the agent reaches it through an MCP server connection. You don't write those operations. When the connection is published, Mindset runs the MCP handshake and discovers three tools: `get_account` and `list_charges` read, and `issue_refund` writes. Reads are enabled and given to the agent. The server checks a bearer token, which a person enters on a credential capture page, so it never passes through a chat or the repo.

Until that server is deployed, the agent has no billing tools. The help panel's header says "Billing tools coming soon", and the agent tells you it can't see the account rather than guessing.

## The governed write

`issue_refund` moves money, so it's a write, and a write needs consent before any agent can call it. Consent is given once per operation, by a person on the connection's Operations tab, and no agent can give it. In this demo it is never given. So when you say "yes, refund it", the agent isn't offered the tool, and it tells you the refund needs an operator's approval and that nothing has been refunded. If a model ever calls a tool it wasn't offered, the run refuses the call before it runs, and the trace marks it **Refused** in red.

The **How approval works** link in the page header opens the operator's view of the connection: two enabled reads and one write waiting for approval, which only a signed-in person can give in the Mindset console. Approving it here would make it live for every visitor, so the demo explains approval instead of performing it. If the agent's run ever refuses `issue_refund`, a red line under the page header says so.

## The page tools and what the agent sees

The bubble is Mindset's own `<mindset-agent>` element in a floating panel. The page gives it two page tools. `highlight_charge` outlines a row in the billing table, and `open_invoice` opens an invoice above the table, with a Download button. The table shows the six newest charges, with both halves of this month's duplicate. Both check their arguments before touching the page, because a model chose them. Situational awareness sends the page you're on, the account id and the highlighted charge with every turn.

The panel also sets `conversation-list`, so the element shows a Conversations button and you can reopen an earlier conversation. Each demo visitor is their own Mindset user, so the list holds only your conversations.

## Under the hood

The strip below the page shows each tool call as it happens: the MCP reads, the page tools with their arguments and results, and any refusal.

## Build the same thing

- [Put an agent on your page](https://docs.mindset.ai/docs/put-an-agent-on-your-page) and [the mindset-agent element](https://docs.mindset.ai/docs/the-mindset-agent-element) cover the bubble, page tools and the conversation list.
- [Connect a system](https://docs.mindset.ai/docs/connect-a-system) covers the MCP server connection.
- [Approve or withdraw a write](https://docs.mindset.ai/docs/approve-what-an-agent-can-do) covers write approval.
- [Test an agent's behavior](https://docs.mindset.ai/docs/test-an-agents-behavior) covers the behavior tests that check it never claims a refund it didn't make.
