README
¶
Errands: agents in a complete app
Errands is a web app where households share chores, bills, and errands. Each person has a role in each household: owner, adult, or kid. Households have invites, recurring tasks, an expense ledger, receipt attachments, an activity feed, and webhooks. The app has a versioned JSON API, server-rendered pages, a CLI in cmd/errands, and an MCP server.
A person can hand one household to an AI agent. The agent lists and completes tasks there, and asks its person before it marks a task paid.
The example shows how these parts of tensile-auth fit together in one application:
- Sign-in with passkeys or email and password, from
preset.Standard, with TOTP and recovery codes. - Route rules on every route, checked by
Mux.Check, and step-up on five risky actions, registered withauth.WithNeeds. - Agents that work in one household, with tokens delegated from the person's session.
- Approvals: the agent asks, and the person approves the exact action with one passkey tap.
- The OAuth provider, with device-flow sign-in for the CLI and authorization codes for MCP clients.
- Personal access tokens, and the session tree with revocation.
- A background job that acts with its own identity, which holds one scope.
- The audit log, its hash chain, and
UnsealedAudit. - An MCP server on the app's mux, protected by
mcpauth, withauthhttp.WithResource.
Errands prints its email to the console, and its webhooks post to any URL. Don't deploy it.
Run it
go run ./examples/agents
The server listens on localhost:8070. Open http://localhost:8070/signin in Chrome or Firefox. Both treat localhost as a secure context, so passkeys and the Secure session cookie work without TLS.
| Flag | Default | What it sets |
|---|---|---|
-addr |
localhost:8070 |
The address to listen on. |
-origin |
http://localhost:8070 |
The origin the browser uses. It's also the OAuth issuer and the passkey origin. |
-data |
tensile-auth-agents in the user cache directory |
The directory for the two SQLite databases, the TOTP and signing keys, and the uploads. |
The app keeps its own tables in errands.db and tensile-auth's tables in auth.db, both through the ncruces/go-sqlite3 driver. To start over, stop the server and delete the data directory.
A tour
The tour uses curl for the agent's requests and assumes the first household and task have ID 1. tour_test.go runs the same steps with a virtual passkey.
1. Sign up with a passkey
- Open http://localhost:8070/signup, or click Create an account on the sign-in page.
- Enter your email address and click Create a passkey.
- Create the passkey when your browser asks. The page opens your home page.
The sign-in page is two of the library's elements, <tensile-sign-in> and <tensile-sign-up>, from /auth/client/elements/. newUserByPasskey in auth.go creates your row in the app's persons table.
2. Create an agent for one household
-
On the home page, enter a household name and click Create household. Then click the household.
-
Under Tasks, enter a title, such as
Pay the plumber, and an amount in dollars, such as120. Click Add task. -
Under Agents, enter a name, keep It can ask you to mark tasks paid selected, and click Create agent.
-
Copy the agent token. The page shows it once.
export AGENT=<the agent token>
Creating an agent is a human-only action that needs a multi-factor proof from the last 10 minutes. A passkey sign-in is one. If your sign-in is older, sign in again first.
The agent works only in this household. To see that, create a second household and run:
curl -i -H "Authorization: Bearer $AGENT" http://localhost:8070/api/v1/households/2/tasks
The response is 403 with this agent works in a different household.
3. The agent asks to pay a task, and you approve it
When your agent tries something risky, it gets a link instead of a yes; you tap your passkey on that exact action, and the agent continues, once, with a signed receipt.
-
The agent completes the task:
curl -X POST -H "Authorization: Bearer $AGENT" http://localhost:8070/api/v1/tasks/1/complete -
The agent asks to pay it, with the CLI's
paycommand and the agent's token:go run ./examples/agents/cmd/errands -token "$AGENT" pay 1The CLI prints what the agent asks,
Mark the task "Pay the plumber" (ID 1) as paid, the link to approve it, such ashttp://localhost:8070/approve/apr_…, and the link as a QR code. It then waits.If you gave your account an email address, the server console also prints an email with the same link: that's
auth.WithApprovalNotifierinmail.go. -
Open the link, or scan the QR code with a phone that has your passkey. The page, a
<tensile-approval>element, shows the agent that asked and the payment, with the amount large: “$120.00 to Home for “Pay the plumber”.” The request also waits in your inbox at http://localhost:8070/account. If the browser is signed out, the link goes to the sign-in page first and comes back to the request after you sign in: that'sauthhttp.WithSignInPageinauth.go. -
Click Approve and use your passkey. The passkey signs the approval's challenge, which covers the action's digest: the task, the amount, the payee, and the summary.
-
The CLI prints
Approved. Task 1 is paid. -
On the household page, Recent activity names the agent, in violet, for the work it did, and you for the approval:
Claude Code completed “Pay the plumber”.andClaude Code marked “Pay the plumber” paid, $120.00, approved by you.Each entry records the agent and its name at that moment, so it reads the same after you revoke the agent.
How the CLI does it, step by step:
-
Agent asks.
POST /api/v1/tasks/1/paidanswers403with thehuman_requiredproblem. Itschallenge.approvalholds the approval'sid, its absoluteurl, itssummary,expires_in(300 seconds), andwait_hint(wait=60). Itsfixtells the agent to show the link and retry. Asking again returns the same approval, so you never see the request twice. -
You tap. The approval page runs the passkey ceremony over the approval's challenge.
-
It runs once. The CLI retries once with the headers
Tensile-Approval: <id>andPrefer: wait=60. The server holds that request for up to 60 seconds, until you approve or deny, and then runs the route. The same retry again is refused.curl -X POST -H "Authorization: Bearer $AGENT" -H "Tensile-Approval: <the approval id>" -H "Prefer: wait=60" \ http://localhost:8070/api/v1/tasks/1/paid
The same flow works over MCP with the task_mark_paid tool. An agent connects with its own token:
claude mcp add --transport http errands-agent http://localhost:8070/mcp --header "Authorization: Bearer $AGENT"
The first call, with task_id, returns the summary and the link as text. The second call, with task_id and the approval_id from the first, waits up to 60 seconds for your passkey tap and then pays the task.
4. Sign in with the CLI through the device flow
-
In a second terminal, run:
go run ./examples/agents/cmd/errands loginThe CLI prints
Open http://localhost:8070/login/device and enter the code XXXX-XXXX. -
Open that URL, enter the code, and click Continue. If the browser is signed out, the page asks you to sign in first and brings you back to enter the code.
-
The page asks
Connect Errands CLI?and lists what the scopeserrands:readanderrands:writelet it do. Click Connect Errands CLI. -
The CLI prints where it stored the token. List and complete tasks with it:
go run ./examples/agents/cmd/errands list -household 1 go run ./examples/agents/cmd/errands add -household 1 -title "Buy milk" go run ./examples/agents/cmd/errands done -task 2
Approving a device needs a sign-in from the last 10 minutes, because its token can outlive your session. If yours is older, the device page asks you to sign in again.
5. Connect an MCP client
These steps use Claude Code. Any MCP client that supports OAuth works the same way.
-
Sign in at http://localhost:8070/signin in your default browser.
-
Add the server:
claude mcp add --transport http errands http://localhost:8070/mcp -
In Claude Code, run
/mcp, chooseerrands, and choose to authenticate. Claude Code reads the protected resource metadata from the401challenge and finds the app's OAuth provider. It identifies itself with its client ID metadata document, which the provider's default allowlist accepts, so it needs no registration. -
Your browser opens the consent page,
Allow Claude Code to use Errands?. Click Allow. -
Ask Claude Code to list the tasks of household 1. It calls the
tasks_listtool with a token whose audience ishttp://localhost:8070/mcp. Thetask_completetool needserrands:write. Thetask_mark_paidtool is for agents: an MCP client that you connect this way acts as you, so it can't ask you for an approval.
Each tool call lands in the audit log as a tool_called event.
6. Revoke the agent and watch its token die
-
On the household page, click Revoke next to the agent.
-
Run the agent's request again:
curl -i -H "Authorization: Bearer $AGENT" http://localhost:8070/api/v1/households/1/tasksThe response is
401. Revoking the agent revokes every session it holds, at once.
Revoking the session an agent was delegated from kills the agent's token too. Your sessions, with the agents under each one, are at http://localhost:8070/account, where Revoke ends one.
7. Check the audit log
Open http://localhost:8070/account, or click Account in the nav. Its activity, a <tensile-activity> element, says whether every entry matches its seal. The JSON is at http://localhost:8070/api/v1/audit, which lists your latest 50 events, newest first, such as agent_created, approval_requested, approval_granted, approval_redeemed, device_approved, access_denied, and agent_revoked.
The chain object reports the hash chain. verified is true while every sealed event matches the chain. unsealed counts the events that svc.Run hasn't sealed yet, which it does once a minute. A change to an unsealed event is undetectable, so a number that keeps growing means nothing is sealing the log. audit_test.go changes a sealed event in SQLite and shows verified turn false.
Where each feature is
| File | What it shows |
|---|---|
main.go |
Wiring: the data directory, the keys, svc.Run, and Mux.Check |
auth.go |
preset.Standard, passkeys, passwords, TOTP, recovery codes, authroutes.Mount, auth.WithNeeds, and authhttp.WithResource |
routes.go |
A rule on every route, authhttp.Approvable, and resolving the principal to the app's person |
access.go |
Household roles, one household per agent, and RecordAccessDenied |
handlers_agent.go |
CreateAgent, Delegate, and RevokeOwnAgent |
handlers_approval.go |
Approval, passkey.BeginApproval, passkey.FinishApproval, and Approve |
handlers_tasks.go |
The approvable action and its describe function, with the payment's params |
handlers_sessions.go |
SessionTree, RevokeOwn, CreatePAT, Events, VerifyAudit, and UnsealedAudit |
provider.go |
The OAuth provider, its device page, and its consent page |
mcp.go |
The MCP server, mcpauth, and mcpauth.AuditTo |
mcppay.go |
The task_mark_paid tool: RequestApproval and RedeemApprovalWait from an MCP tool, for an agent that connects with its own token |
mail.go |
The console mailer, and auth.WithApprovalNotifier |
recurring.go |
A background job with its own principal |
handlers_households.go, handlers_money.go, handlers_files.go, webhooks.go |
The rest of the app: households, invites, the ledger, attachments, and webhooks |
db.go, migrations/ |
The app's own SQLite database and its schema |
pages.go, templates/ |
The server-rendered pages. Sign-in, approval, and the account page use the library's elements; http://localhost:8070/elements demonstrates their options |
cmd/errands |
The CLI, its device-flow sign-in, and pay, which waits for an approval and prints its link as a QR code |
The tests show the rules holding. break_test.go attacks the app across households and as an agent. routes_test.go runs authtest.Routes over every route and keeps an allowlist of Public routes with authtest.PublicRoutes.
Learn more
- The guide, in particular its sections on agents and approvals.
- Errors, for the problem codes the API returns.
examples/mcpserver, a smaller MCP server with the same provider.
Documentation
¶
Overview ¶
Command agents runs Errands, a web app where households share chores, bills, and errands, and where each person can hand a household to an AI agent. It shows tensile-auth in a complete application: passkeys and passwords, step-up on risky actions, agents limited to one household, approvals, an OAuth provider with device-flow sign-in for the CLI in cmd/errands, personal access tokens, a background job with its own identity, the audit log, and an MCP server.
To run it, run:
go run ./examples/agents
Then open http://localhost:8070/signin. The app keeps its data in the directory that -data names; see README.md for a tour.