Skip to main content
Glama

调用计量

metering.record

记录或查询跨 Agent 任务的用量计量,用于任务结算与分账。mode=record 写入计量,mode=query 按 actor 聚合查询累计用量。Example: {"mode":"record","actor":"agent-a","metric":"tokens","units":1200}

Example tool call

This call uses example arguments supplied in the tool’s input schema.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "mode": "record",
      "actor": "agent-a",
      "units": 1200,
      "metric": "tokens"
    },
    "name": "metering.record"
  }
}

Input Schema

NameRequiredDescriptionDefault
modeYesrecord=写入;query=查询
actorYes执行方标识
unitsNo用量数(record 用)
metricNo指标名,如 tokens(record 用)

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed4 schema fields changed
    • changedInput schema / properties / actor / description
      Previous value: -"执行方标识(Agent 名/ID/角色)"New value: +"执行方标识"
    • changedInput schema / properties / metric / description
      Previous value: -"计量指标名,如 tokens、calls、duration_ms(record 时用)"New value: +"指标名,如 tokens(record 用)"
    • changedInput schema / properties / mode / description
      Previous value: -"record=写入计量;query=查询聚合用量"New value: +"record=写入;query=查询"
    • changedInput schema / properties / units / description
      Previous value: -"用量数(record 时用,必须为数字)"New value: +"用量数(record 用)"
  2. Added

TDQS

B3.1/5.0
Behavior2/5

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

The annotations already say readOnly=false, destructive=false, and idempotent=false, so the description does not need to restate safety. The description does not disclose the important behavior that matters most for a non-idempotent billing write: whether repeated record calls with the same actor, metric, and units double-count usage, what time window query aggregates over, or whether query returns all-time totals. For a settlement tool, these are meaningful gaps.

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?

The content is compact: one front-loaded sentence covering purpose and both modes, followed by a concrete example. The example repeats what the schema already provides and could be cut, but the description is otherwise efficient and easy to scan.

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?

There is no output schema, so the description should explain what query returns (aggregate total per actor? per metric?) and how record behaves on retries. Neither is covered, and the aggregation semantics of a non-idempotent billing write are left unspecified. This is inadequate for a dual-mode write/aggregate tool that feeds settlement.

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 description coverage is 100%, so all four parameters (mode enum, actor, units, metric) are already documented in the schema. The description's example duplicates the schema example and adds no new meaning, such as units semantics or metric naming conventions. This is the baseline 3 case where the schema carries the weight.

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 description states a specific verb+resource: it records or queries usage metering across agent tasks for settlement/split-billing, and it separates mode=record (write) from mode=query (aggregate by actor). This is clearer than the generic name 'metering.record', but the settlement-billing purpose is only loosely tied to sibling tools like settlement.ledger and settlement.account, so the boundaries stay slightly fuzzy.

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?

The description explains the internal record-vs-query split: use record to write a usage entry, use query to read cumulative usage aggregated by actor. However, it never says when an agent should call this tool instead of the nearby settlement.* or audit.record tools, and it gives no prerequisites or when-not-to-use guidance.

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.