Skip to main content
Glama
sF1nX

x402station-mcp

Pre-flight safety check

preflight

Check if a x402 URL is safe to pay before processing payment. Returns ok status and warnings to avoid decoys, zombies, and dead endpoints.

Instructions

Ask x402station whether a given x402 URL is safe to pay. Returns {ok, warnings[], metadata}. Costs $0.001 USDC (auto-signed with AGENT_PRIVATE_KEY). Call this BEFORE any other paid x402 request to avoid decoys (price ≥ $1k), zombie services, and dead endpoints. ok:true only when no critical warning fires.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYesThe full URL of the x402 endpoint the agent is about to pay.

Implementation Reference

  • The `preflight` method is the handler function for the preflight tool. It takes a walletProvider and args (url), and calls the paid oracle endpoint /api/v1/preflight with the provided URL.
    async preflight(
      walletProvider: EvmWalletProvider,
      args: z.infer<typeof PreflightSchema>,
    ): Promise<string> {
      return this.callPaid(walletProvider, "/api/v1/preflight", { url: args.url });
    }
  • The `@CreateAction` decorator registers the `preflight` tool with name "preflight", description, and input schema (PreflightSchema).
    @CreateAction({
      name: "preflight",
      description:
        "Ask x402station whether a given x402 URL is safe to pay. Returns {ok, warnings[], metadata}. Costs $0.001 USDC (auto-signed via the wallet provider). Call this BEFORE any other paid x402 request to avoid decoys (price ≥ $1k USDC), zombie services, dead endpoints, and price/latency anomalies. ok:true only when no critical warning fires.",
      schema: PreflightSchema,
    })
  • The `PreflightSchema` defines the input schema for the preflight tool: a single `url` field (string, must be a valid URL).
    export const PreflightSchema = z.object({
      url: z
        .string()
        .url()
        .describe(
          "Full URL of the x402 endpoint the agent is about to pay (must be http(s)://, max 2048 chars).",
        ),
    });
  • The `callPaid` helper method is the underlying implementation that sends the POST request to the oracle. It uses the paying fetch (with x402 auto-signing), parses the JSON response, and extracts the payment receipt header.
    private async callPaid(
      walletProvider: EvmWalletProvider,
      path: string,
      body: unknown,
    ): Promise<string> {
      const fetchPay = await this.getPayingFetch(walletProvider);
      const r = await fetchPay(`${this.baseUrl}${path}`, {
        method: "POST",
        headers: { "content-type": "application/json" },
        body: JSON.stringify(body ?? {}),
      });
    
      const receiptHeader =
        r.headers.get("x-payment-response") ?? r.headers.get("payment-response");
      let paymentReceipt: unknown = null;
      if (receiptHeader) {
        try {
          paymentReceipt = JSON.parse(atob(receiptHeader));
        } catch {
          paymentReceipt = { raw: receiptHeader };
        }
      }
    
      const raw = await r.text();
      if (!r.ok) {
        const snippet = raw.length > 200 ? raw.slice(0, 200) + "…" : raw;
        return JSON.stringify(
          {
            error: true,
            status: r.status,
            message: `x402station ${path} returned ${r.status}`,
            details: snippet,
          },
          null,
          2,
        );
      }
      let data: unknown;
      try {
        data = JSON.parse(raw);
      } catch {
        return JSON.stringify(
          {
            error: true,
            message: `x402station ${path} returned 200 with non-JSON body`,
            details: raw.slice(0, 200),
          },
          null,
          2,
        );
      }
    
      return JSON.stringify({ result: data, paymentReceipt }, null, 2);
    }
Behavior5/5

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

No annotations provided, so description fully discloses behavior: costs $0.001 USDC, auto-signed with AGENT_PRIVATE_KEY, returns ok only when no critical warning fires. Warns about specific threats (decoys ≥$1k, zombie services, dead endpoints).

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?

Two sentences: first defines purpose and output, second provides usage guidance and cost. No wasted words; critical information presented first.

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?

Despite no output schema, description explains return structure and conditions. Covers cost, signing, and specific dangers to avoid. For a simple tool with one parameter, this is highly complete.

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

Parameters4/5

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

Single parameter 'url' has schema description ('The full URL of the x402 endpoint') and description adds context ('given x402 URL') and ties it to safety check purpose. Schema coverage is 100%, so baseline 3; description adds value by connecting parameter to tool's role.

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 clearly states the tool checks if an x402 URL is safe to pay, specifies the return value format ({ok, warnings[], metadata}), and distinguishes it from sibling tools by emphasizing it should be called before paid requests to avoid decoys, zombies, and dead endpoints.

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?

Explicitly instructs to call 'BEFORE any other paid x402 request' to avoid specific risks (decoys, zombies, dead endpoints). Also mentions cost ($0.001 USDC) and auto-signing. Lacks explicit when-not-to-use guidance, but the positive directive is clear.

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

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/sF1nX/x402station-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server