Take work, leased so a dead worker cannot lose it
work_takeTake up to n items, LEASED not deleted — the same lease semantics as lease()/renew()/release(): a holder, a fence token, an expiry. Two workers can never be handed the same item, because one single-threaded Durable Object owns the queue. IF YOUR PROCESS DIES THE LEASE SIMPLY EXPIRES AND THE ITEMS RETURN TO THE QUEUE with attempts incremented; nothing had to stay alive to notice, and that recovery is the point. EACH ITEM CARRIES ITS OWN FENCE, drawn independently on every take: the token you are given for one item tells you nothing about the token another worker was given for another item, and it is not the previous holder's token plus one. The item's ORDER is generation (identical to attempts, the number of times it has been handed out) — that is the number to compare and the number to hand to an external store; the fence is the secret. $0.002 when at least one item is handed to you for the FIRST time; a re-take after your own lease expired is free, exactly like mailbox redelivery. An empty or cancelled queue returns nothing, says so, and costs nothing. Costs $0.002 USDC per call via x402 on Base, and ONLY when at least one item was handed to a worker for the FIRST time (a re-take after a lease expired is free); otherwise the same call returns the full answer and settles nothing. Authenticate with Authorization: Bearer , or pass agent_key as an argument if your host cannot set headers. Equivalent HTTP route: POST /v1/work/take.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| n | No | How many items to take. 1..25. Default 1. Example: '5'. | |
| holder | No | Who is taking — an instance id you choose, exactly as with lease(). Default 'worker'. Example: 'worker-3'. | |
| queue_id | Yes | The queue to take from. Alias: job_id — a job and its work queue are the same thing. Example: 'permit-batch-2026-08'. | |
| agent_key | No | Your agent_secret, if your MCP host cannot set the Authorization header. Prefer the header. | |
| lease_seconds | No | How long you hold them before they return to the queue. Default 300, min 5, max 86400. Example: '300'. |