Skip to main content
Glama

report_usage

DestructiveIdempotent

Records a retry-safe usage heartbeat for your thread claim, logging token counts and USD charges so Maidan can enforce budgets and stop the run when limits are exceeded.

Instructions

Record one retry-safe usage heartbeat for the claim you hold on a thread: token counts, the USD charge and the prices behind it. Maidan takes the reporter from your credential and the payer from the thread's workspace, and refuses the call unless you are the active holder of claim_lease_id. usd_micros must equal the charge computed from price_snapshot and tokens. Repeating an identical report returns the first outcome without charging twice; reusing the usage_report_id with different content is a conflict. If the thread's budget (tokens, USD, turns or wall time) is now exceeded, the run stops: the claim is released, a ClaimFailed event is appended and a dead-letter entry is recorded (see list_dlq). Returns the ledger entry with the updated budget, stopped and reason. Requires thread:transition.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "thread_id": "<thread_id>",
      "usage_report_id": "<usage_report_id>",
      "claim_lease_id": "<claim_lease_id>",
      "model": "<model>",
      "tokens": "<tokens>",
      "usd_micros": "<usd_micros>",
      "price_snapshot": "<price_snapshot>"
    },
    "name": "report_usage"
  }
}

Input Schema

NameRequiredDescriptionDefault
modelYesModel id the provider's response named, 1 to 255 characters after trimming.
turnsNoModel turns this report adds to the thread's turn count, a non-negative integer. Default 0.
tokensYesToken counts for this call as {input, output, cache_read, cache_write_5m, cache_write_1h}, all required non-negative integers. input is uncached input only. A token budget counts input, output and both cache-write tiers; cache reads are priced into the charge but do not count toward a token budget.
evidenceNoOptional context about the call: provider, service_tier, batch, harness, harness_version, effort, cache_key, cache_miss_reason, pack_sha256 (up to 32 SHA-256 hex digests of Maidan packs the call used) and standard_price. standard_price is allowed only for a cheaper-lane call (batch true, or service_tier batch or flex) and must price the same tokens at or above usd_micros.
thread_idYesUUID of the thread you hold a claim on.
usd_microsYesCharge for this call in micro-USD ($1 = 1000000), a non-negative integer. Must equal the sum over the five token kinds of count times rate per million, rounded up to a whole micro-dollar; a mismatch is refused.
claim_lease_idYesThe fencing token of your active claim, from the claim response's thread.claim_lease_id. A stale or foreign token is refused.
price_snapshotYesRates used for this call in micro-USD per million tokens: input_usd_micros_per_million, output_usd_micros_per_million, cache_read_usd_micros_per_million, cache_write_5m_usd_micros_per_million and cache_write_1h_usd_micros_per_million, all required non-negative integers. Maidan stores them as reporter-supplied evidence and keeps no rate card.
usage_report_idYesUUID you generate for this report, unique across all reports. Reuse it only to retry the exact same report.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed9 schema fields changedv479.0.2
    • changedInput schema / properties / claim_lease_id / description
      Previous value: -"active claim fencing token"New value: +"The fencing token of your active claim, from the claim response's thread.claim_lease_id. A stale or foreign token is refused."
    • addedInput schema / properties / evidence / description
      Added value: +"Optional context about the call: provider, service_tier, batch, harness, harness_version, effort, cache_key, cache_miss_reason, pack_sha256 (up to 32 SHA-256 hex digests of Maidan packs the call used) and standard_price. standard_price is allowed only for a cheaper-lane call (batch true, or service_tier batch or flex) and must price the same tokens at or above usd_micros."
    • addedInput schema / properties / model / description
      Added value: +"Model id the provider's response named, 1 to 255 characters after trimming."
    • addedInput schema / properties / price_snapshot / description
      Added value: +"Rates used for this call in micro-USD per million tokens: input_usd_micros_per_million, output_usd_micros_per_million, cache_read_usd_micros_per_million, cache_write_5m_usd_micros_per_million and cache_write_1h_usd_micros_per_million, all required non-negative integers. Maidan stores them as reporter-supplied evidence and keeps no rate card."
    • addedInput schema / properties / thread_id / description
      Added value: +"UUID of the thread you hold a claim on."
    • addedInput schema / properties / tokens / description
      Added value: +"Token counts for this call as {input, output, cache_read, cache_write_5m, cache_write_1h}, all required non-negative integers. input is uncached input only. A token budget counts input, output and both cache-write tiers; cache reads are priced into the charge but do not count toward a token budget."
    • addedInput schema / properties / turns / description
      Added value: +"Model turns this report adds to the thread's turn count, a non-negative integer. Default 0."
    • changedInput schema / properties / usage_report_id / description
      Previous value: -"globally unique idempotency key"New value: +"UUID you generate for this report, unique across all reports. Reuse it only to retry the exact same report."
    • changedInput schema / properties / usd_micros / description
      Previous value: -"validated USD charge in micros ($1 = 1000000)"New value: +"Charge for this call in micro-USD ($1 = 1000000), a non-negative integer. Must equal the sum over the five token kinds of count times rate per million, rounded up to a whole micro-dollar; a mismatch is refused."
  2. First observedv479.0.0

TDQS

A4.4/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare destructiveHint=true and idempotentHint=true, and the description goes well beyond them: it explains exactly what repetition does (returns the first outcome, no double charge), what a mismatched usage_report_id produces (conflict), and what the destructive path actually destroys (claim released, ClaimFailed event appended, dead-letter entry). It also describes the return payload (ledger entry with updated budget, stopped and reason) despite no output schema.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Dense and front-loaded: identity/validation first, idempotency semantics second, destructive consequences third, return shape last. Every sentence carries operational weight, though the usd_micros invariant is stated twice (description and schema) and the prose runs long relative to a nine-parameter tool.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a destructive, nested-object, budget-affecting mutation with no output schema, the description covers preconditions, cross-field validation, idempotency, failure side effects, and the return value. An agent has everything needed to call it correctly and to anticipate the consequences of an over-budget report.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the schema already documents every field including the usd_micros derivation and the price_snapshot rates. The description restates the usd_micros/price_snapshot/tokens invariant and adds the useful attribution rule (reporter from credential, payer from the thread's workspace), but adds little else about the nine parameters. Baseline 3 is appropriate when the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Opens with a specific verb and resource: 'Record one retry-safe usage heartbeat for the claim you hold on a thread', immediately scoped by what data it carries (tokens, USD charge, prices). It is clearly distinguishable from siblings like usage_rollup (aggregation) and list_dlq (which it explicitly cross-references for the side effect).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

States the precondition plainly: you must be the active holder of claim_lease_id, and the call requires thread:transition. It does not name a direct alternative for recording usage, but it does route the agent to list_dlq for the dead-letter consequence, and the retry conditions are spelled out rather than left implicit.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Deploy Server

Other Tools