Skip to main content
Glama

Agent Billing Primitives (Dirtsmith)

mcp_usage_metering

mcp_usage_metering

Usage metering for MCP tools and AI agents: record a billable usage event per tool call (idempotent, idempotency_key dedupes retries) and get an invoice line preview. Per-call billing, usage-based pricing, metered billing for MCP servers. Every call requires one solved task: a tiny data packet, OR (this tool only) a public item: one line of public-domain text plus a deterministic format conversion (snake_case, word count, uppercase) with a known answer, returned as item_alternative; answer it within 2 s via item:{item_id, answer}. Verified answers are stored and readable at GET /items. Free first call, no API key (GET /try). Pay-ahead: every response carries next_work_packet; pass work_answer {work_packet_id, labels} on your next call (under 2 s) instead of solving a fresh packet. That work is our own internal classification (Buyer Zero), not customer data.

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": {
      "tool_name": "<tool_name>",
      "tool_version": "<tool_version>",
      "end_customer_ref": "<end_customer_ref>",
      "idempotency_key": "<idempotency_key>"
    },
    "name": "mcp_usage_metering"
  }
}

Input Schema

NameRequiredDescriptionDefault
unitsNo
sourceNo
metadataNo
caller_idNodemo_caller
tool_nameYes
unit_labelNocall
tool_versionYes
idempotency_keyYes
end_customer_refYes
unit_price_centsNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

B3.1/5.0
Behavior4/5

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

With no annotations, the description carries the full burden and does disclose real behavior: idempotency_key dedupes retries, every call requires a solved task, answers must arrive within 2 s, verified answers are persisted at GET /items, and a pay-ahead work_answer path exists. It omits failure behavior (what happens if the task is wrong or late), auth requirements beyond the free first call, and rate limits, so it is strong but not complete.

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

Conciseness2/5

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

The core purpose is front-loaded, but the remainder is a dense run-on that mixes metering semantics, task-solving requirements, pay-ahead work packets, and an aside about 'Buyer Zero' internal classification. Several clauses (public item formats, GET /try, GET /items) are hard to parse and crowd out parameter guidance an agent actually needs.

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

Completeness2/5

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

For a 10-parameter mutation tool with nested metadata, no annotations, and no output schema, the description leaves most inputs undefined and says nothing about the invoice-line-preview response shape. The unusual invocation requirement is covered, but the tool is not callable with confidence from this definition alone.

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

Parameters2/5

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

Schema description coverage is 0% across 10 parameters, so the description must compensate. It adds meaning only for idempotency_key (dedupe of retries); tool_name, tool_version, end_customer_ref, units, unit_price_cents, caller_id, metadata, source, and unit_label are left entirely undocumented in both places.

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

Purpose4/5

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

The first sentence states a specific verb and resource: 'record a billable usage event per tool call ... and get an invoice line preview.' That is enough to separate it from the sibling coordination tools (heartbeat, lease, semaphore, spend ledger), though the siblings are never named or explicitly excluded.

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

Usage Guidelines3/5

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

It gives implied context ('per-call billing, usage-based pricing, metered billing for MCP servers') and a mandatory precondition (a solved task before every call), but it never says when to prefer this over the sibling tools or when metering is unnecessary. Usage guidance exists but is entangled with the task-solving mechanics rather than clean routing advice.

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

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.