Skip to main content
Glama

ghost_pre_spend_gate

THE PRE-SPEND GATE. Call this immediately before your agent pays an x402/API provider, with the task's own economics. Returns ALLOW / FALLBACK / DECLINE / INSUFFICIENT_EVIDENCE — not advice: a decision your payment path should enforce. It joins the provider's measured record (independent payers, concentration, price drift, reachability, funding links, on-chain verdict) to YOUR numbers (customer_revenue, value_of_success, max_budget, required_margin, failure_cost, switching_cost) and answers the question ranking cannot: is paying for THIS task profitable, and at which provider. Where the task's value is known it maximises expected net value; where it is not, it minimises cost per verified success — which is why it will refuse the cheapest call when a cheaper provider succeeds less often. Unknown economics stay UNKNOWN and are never invented. Report the result afterwards to /v1/gate/outcome (free) — that is the only source of the success rates it uses. Paid per decision via x402, or drawn from prepaid credit. On prepaid credit a cached decision inside valid_until and an INSUFFICIENT_EVIDENCE answer draw nothing. On the per-decision x402 rail an INSUFFICIENT_EVIDENCE question is refused before any terms are quoted, so nothing settles for it; any other decision is paid upfront. Payment: $0.01 USDC on Base per call over x402, settled before the tool runs. An x402 MCP client such as x402-proxy pays it automatically; if you use x402-proxy, set its spend limits first (spendLimitPerTx 0.01, spendLimitDaily 0.10; see /llms.txt). A funded payment and delivery through x402-proxy has not been verified yet.

Input Schema

NameRequiredDescriptionDefault
task_idYes
currencyNoUSD
task_typeYesWhat kind of job this is. Success history is pooled under it, so it must be stable.
max_budgetNo
failure_costNo
revenue_modelsNoOptional. Say what the task is worth in the terms you actually measure, and Ghost derives value_of_success / customer_revenue / max_budget from it — never overriding a value you stated yourself. Each entry needs a `type`: SALES_ROI (spend, qualified_leads?, meetings?, closed_deals?, realized_revenue?), AFFILIATE_ROI (commission_rate?, order_value?, conversion_probability?, tool_cost?, inference_cost?, transaction_cost?), PROCUREMENT_SAVINGS (current_total_cost?, alternative_total_cost?, switching_cost?, migration_cost?), RETURN_ROI (expected_return, data_cost?, model_cost?, execution_cost?, expected_risk_loss?; expected_return is YOURS to state and is never estimated by Ghost), CREDIT_AFFORDABILITY (available_credit, planned_spend?). Ratios are derived only where the denominator exists; conversion rates are never invented.
switching_costNo
required_marginNo
customer_revenueNo
value_of_successNo
payment_signatureNoLeave empty when your MCP client pays automatically (e.g. x402-proxy: payment travels in _meta["x402/payment"]). Otherwise the x402 PAYMENT-SIGNATURE header value: omit it to receive the payment terms, call again with it to run the tool.
success_definitionYesWhat counts as success, written down BEFORE paying. verified_success is later judged against this.
fallback_authorizedNoMay Ghost route to a different candidate than the first? Off by default: an unrequested reroute is a payment the operator did not choose.
provider_candidatesYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changed
    • changedInput schema / properties / payment_signature / description
      Previous value: -"x402 PAYMENT-SIGNATURE header value. Omit it to receive the payment terms; call again with it to run the tool."New value: +"Leave empty when your MCP client pays automatically (e.g. x402-proxy: payment travels in _meta[\"x402/payment\"]). Otherwise the x402 PAYMENT-SIGNATURE header value: omit it to receive the payment terms, call again with it to run the tool."
  2. Added

TDQS

A4.3/5.0
Behavior5/5

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

With no annotations, the description carries the full behavioral burden and does so in detail: decision outputs, x402 pricing and settlement, prepaid credit/cache behavior, INSUFFICIENT_EVIDENCE handling, spend-limit setup, and an explicit unverified-delivery caveat. This is exactly the context an agent needs for a payment-affecting tool.

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 purpose and decision outputs are front-loaded, and most sentences carry useful operational detail. The payment/x402-proxy wording is lengthy, though largely justified for a payment gate.

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

Completeness4/5

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

For a complex tool with no annotations and no output schema, the description explains the decision statuses, economics logic, payment path, and outcome-reporting loop. It does not fully specify the response shape or all input semantics, leaving some gaps.

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 only 36% across 14 parameters, so the description must compensate. It lists key economic inputs and reinforces that unknown values stay UNKNOWN, but it does not define most fields or explain the provider-candidate structure, so it only partially fills the gap.

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 states a specific operation: a pre-spend gate called immediately before paying an x402/API provider, returning one of four explicit decisions. It clearly distinguishes this from ranking/search logic and is unambiguous against the sibling search/vet tools even without naming them.

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?

It gives explicit timing guidance ('Call this immediately before your agent pays') and explains the decision context. It does not name sibling alternatives or state when-not-to-use cases, keeping it below a 5.

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.

Resources