Skip to main content
Glama

Check Before Spending

ledger_check_spend
Read-onlyIdempotent

Ask BEFORE you spend: may this agent spend this much right now?

Returns allowed (true/false), a stable reason code (within_budget, over_monthly_cap, over_daily_cap, over_monthly_token_cap, over_daily_token_cap, no_budget_set, unpriced_model), a one-line message, the cost estimate, the price used (with its source and as_of date) and every budget window with cap, spent and remaining.

Same decision the /proxy/{provider} gate enforces. Read-only: nothing is recorded or reserved, so record the spend with ledger_track afterwards.

Give exactly one spend shape: amount_cents (any rail, e.g. an x402 purchase), OR model with tokens_in/tokens_out.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
modelNomodel id to price from tokens (instead of amount_cents)
agent_idYesthe agent that would spend
tokens_inNoexpected input tokens (with model)
tokens_outNoexpected output tokens, e.g. your max_tokens (with model)
agent_secretNothe agent's own secret (either this or workspace_key)
amount_centsNothe spend in cents, if you already know it
workspace_keyNothe owning workspace's key (either this or agent_secret)

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. Added

TDQS

A5/5.0
Behavior5/5

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

Annotations already declare readOnlyHint=true and idempotentHint=true, and the description reinforces this with 'Read-only: nothing is recorded or reserved.' It adds useful behavioral context beyond the annotations: it is equivalent to the /proxy/{provider} gate, returns stable reason codes, and does not reserve funds.

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

Conciseness5/5

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

The description is front-loaded with the core purpose and then compactly delivers return details, gate equivalence, side-effect transparency, and input constraints. Each sentence adds distinct value; the parenthetical enum list is dense but directly useful for interpreting the response.

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?

Given the output schema exists, the description does not need to fully restate return values; it still names the key response elements. It covers when to call, what inputs to provide, side effects, and the relationship to sibling tools, making it complete for correct selection and invocation.

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

Parameters5/5

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

Although schema coverage is 100%, the description adds crucial semantics the schema alone does not convey: amount_cents and model+tokens_in/tokens_out are mutually exclusive spend shapes. It also gives concrete examples ('any rail, e.g. an x402 purchase') and clarifies tokens_out means 'e.g. your max_tokens', which helps an agent map values correctly.

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?

The description opens with an explicit imperative, 'Ask BEFORE you spend: may this agent spend this much right now?', which states the exact action and resource. It also distinguishes itself from ledger_track by noting that spending must be recorded separately, and from the proxy gate by clarifying it makes the same decision.

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

Usage Guidelines5/5

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

The description gives clear when-to-use guidance ('Ask BEFORE you spend'), what the tool does not do ('nothing is recorded or reserved'), and names the follow-up alternative ('record the spend with ledger_track afterwards'). It also specifies the required input shape ('Give exactly one spend shape'), leaving little to inference.

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.