Invoice Copilot
The smallest complete agent application: an agent with its own identity reads invoices through an MCP server, and asks a person before it refunds one.
ApplicationDraft
This page is a draft. The code exists, and not all of it has been run for this page yet. The page says what was checked. The code is in
server/examples today.Scenario
Northwind Labs, a fictional company, gives its finance team an agent. The agent may read every invoice. A refund is different: it moves money, so a person must approve each one. This is the real version of the simulated demo at app.lumoauth.dev/demo/agents, and the application to read first.
People and agents
| Who | Role in the application | Identity in LumoAuth |
|---|---|---|
| Invoice Copilot | Reads invoices and proposes refunds. | A registered agent with the capability invoices:read. |
| Finance lead | Approves or denies refunds. | A user with access to the approvals inbox. |
| Invoices MCP server | Holds the invoices and the two tools. | A registered MCP server with the scopes mcp:read and mcp:write. |
Flows
| Flow | What happens | What LumoAuth does |
|---|---|---|
| First call | The agent calls the server with no token. | The server answers 401 and points at the protected resource metadata. |
| Token | The agent asks for a token for this server. | Issues a token whose audience is the server. |
| Read | The agent calls list_invoices. | The server verifies the token. The tool runs. |
| Refund refused | The agent calls refund_invoice. | The Ask API says no: the capability is missing. |
| Approval | The agent asks for the permission, with the invoice and the amount. | Puts the request in the inbox. After approval, issues a token for this refund only. |
| Refund | The agent calls refund_invoice again. | The server accepts the approved token. The audit log links every step. |
Parts
| Part | Built with | Job |
|---|---|---|
| Agent | @lumoauth/agent, or the Python SDK | Runs the six flows and prints each request. |
| MCP server | @lumoauth/mcp on the MCP TypeScript SDK | Two tools, and the token checks. |
| Seed script | Admin API | Creates the agent and the server registration. |
What the seed script creates
- The agent "Invoice Copilot" with
invoices:read. - The MCP server "Invoices" with its resource URI.
- A role for the approver.
Walkthrough
- Run the seed script and copy its output into
.env. - Start the MCP server.
- Start the agent, and read the 401 and the token.
- Watch the refund wait.
- Approve it in the portal, and watch the agent continue.
- Open the audit log and filter by the agent.
Before you run it
- Check that your plan includes just-in-time permissions in the plans matrix.
Where the code is today
mcp-server.mjs, agent.mjs and agent.py in the examples folder of the server repository run this scenario with the standard library only. The catalog version replaces the hand-written token code with the SDKs.