Agent setup

Connect AI Agent

Inspect conditions and consumer_operations in tools/list or OpenAPI before sending an unsigned quote. The same structured decisions are available with REST and MCP. See the four decision examples.

For a remote MCP client, copy the endpoint and verify the connection. For code, choose REST, the typed Node SDK or a tested framework example. All three routes can inspect quotes without signing or spending.

MCP

Add a remote Streamable HTTP server. Set the URL below. Discovery uses no API key and connects without wallet access.

MCP endpoint
https://api.fresh402.com/mcp
  1. Run initialize, then send notifications/initialized.
  2. Send tools/list to see all 12 tools and their input schemas.
  3. Use free fresh402_register, try an eligible fresh402_check with evaluation:true, or inspect the challenge for a paid tool.

Use the protocol version returned by the server and forward an MCP session ID if one is issued. A paid MCP call can have HTTP 200 with result.isError and a challenge in the tool result.

Verify with the official Node MCP SDK

Node.js 24+. Save the JavaScript as discover.mjs and run node discover.mjs. Expect 12 tool names. Legacy clients supporting 2025-06-18 or 2025-11-25 can use initialization and the negotiated protocol header.

Terminal
npm install @modelcontextprotocol/client@2.4.0 --ignore-scripts
JavaScript
import { Client, StreamableHTTPClientTransport } from '@modelcontextprotocol/client';
const client = new Client({ name: 'fresh402-connection', version: '1.0.0' }, {
  versionNegotiation: { mode: { pin: '2026-07-28' } },
});

try {
  await client.connect(new StreamableHTTPClientTransport(
    new URL('https://api.fresh402.com/mcp'),
  ));
  const { tools } = await client.listTools();
  console.log(tools.map(({ name }) => name));
} finally {
  await client.close();
}
MCP inputs and payment metadata

REST

Send JSON to https://api.fresh402.com. Read current limits and tool schemas before execution.

Get an unpaid quote

Send the exact operation body with no payment credential or prepaid key. The Website Change examples below expect HTTP 402 before source work. Read its challenge to verify chain, native USDC, recipient, amount and resource before a separate authorization.

Generic MCP and HTTP clients can read quotes. Payment requires the compatible x402 or MPP client and explicit spending authority, or an eligible prepaid key.

Choose a payment method

Copy a command for your environment

Free access rules

Windows PowerShell

Read eligibility first. The second script makes a live Check only if eligible. Run it once when you intend to use the allowance.

Read walletless eligibility
PowerShell
$eligibility = Invoke-RestMethod -Uri 'https://api.fresh402.com/v1/check/evaluation-eligibility'
$eligibility | ConvertTo-Json -Depth 5
Check only if eligible
PowerShell
$api = 'https://api.fresh402.com'
$eligibility = Invoke-RestMethod -Uri "$api/v1/check/evaluation-eligibility"
if ($eligibility.state -eq 'eligible') {
    $body = @{url='https://example.com/'; evaluation=$true} | ConvertTo-Json -Compress
    try {
        Invoke-RestMethod -Method Post -Uri "$api/v1/check" -ContentType 'application/json' -Body $body
    } catch {
        Write-Warning 'Read the response before retrying. Keep the original input; do not switch to payment.'
        throw
    }
} else {
    "Evaluation: $($eligibility.state). Use the Playground or replay an existing identical input."
}

Windows Command Prompt

Read release metadata, then inspect a quote. Use curl.exe to select the executable.

Read release metadata
Windows CMD
curl.exe -fsS "https://api.fresh402.com/release.json"
Inspect an unpaid quote
Windows CMD
curl.exe -sS -i -X POST "https://api.fresh402.com/v4/workflows/website-change-intelligence" -H "Content-Type: application/json" -d "{\"url\":\"https://example.com/\"}"

Bash

Start with discovery, a fixed server fixture or an unpaid quote. Free Register may fetch and save a watch. Run it only when you need a baseline.

Read release metadata
Bash
curl -fsS 'https://api.fresh402.com/release.json'
Run the fixed server fixture
Bash
curl -fsS 'https://api.fresh402.com/v4/demos/website-change'
Register a free baseline
Bash
curl -fsS 'https://api.fresh402.com/v1/register' \
  -H 'Content-Type: application/json' \
  --data '{"url":"https://example.com/"}'
Initialize MCP
Bash
curl -fsS 'https://api.fresh402.com/mcp' \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json, text/event-stream' \
  --data '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{},"clientInfo":{"name":"fresh402-quickstart","version":"1.0"}}}'
Inspect an unpaid quote
Bash
curl -sS -i 'https://api.fresh402.com/v4/workflows/website-change-intelligence' \
  -H 'Content-Type: application/json' \
  --data '{"url":"https://example.com/"}'

Python 3

Save as quote.py and run python quote.py. The script expects HTTP 402 and spends nothing.

Save quote.py
Python
import json
from urllib.error import HTTPError, URLError
from urllib.request import Request, urlopen

request = Request(
    "https://api.fresh402.com/v4/workflows/website-change-intelligence",
    data=json.dumps({"url": "https://example.com/"}).encode("utf-8"),
    headers={
        "Content-Type": "application/json",
        "User-Agent": "Fresh402-Python-Example/1.0",
    },
    method="POST",
)
try:
    with urlopen(request, timeout=15) as response:
        raise RuntimeError(f"Expected an unpaid 402 quote, got {response.status}")
except HTTPError as error:
    if error.code != 402:
        raise
    print(json.dumps(json.load(error), indent=2))
except URLError as error:
    raise SystemExit(f"Quote unavailable: {error.reason}")

Node.js SDK

Use Node 24+ and ESM. Pin fresh402-sdk@0.7.0, the current published prerelease on next. The default latest tag selects 0.4.0-rc.1.

Install the pinned SDK
Terminal
npm install fresh402-sdk@0.7.0 --ignore-scripts
Save quote.mjs
JavaScript
import { createProductionClient, SERVER_WORKFLOWS } from 'fresh402-sdk';

const client = createProductionClient();
await client.discover();
const tool = 'fresh402_website_change_intelligence';
const quote = await client.quote(tool, { url: 'https://example.com/' });
console.log(JSON.stringify({ workflows: SERVER_WORKFLOWS, quote }, null, 2));
Run quote.mjs
Terminal
node quote.mjs

The package exports fresh402-sdk and fresh402-sdk/workflows. The client below prepares an unsigned quote without a key or signer. A caller supplies separate credentials and authorization for live paid execution.

Inspect the pinned npm package · Full SDK reference

Agent frameworks

Use a real client example for OpenAI Agents SDK, LangChain, LangGraph, CrewAI or Vercel AI SDK. Begin with discovery and an unpaid quote.

Choose a framework example

Choose how the agent pays

  • Without a wallet. List tools, run free Register or inspect a quote. Check free eligibility before a Check with evaluation:true.
  • With a compatible wallet. Connect the x402 or MPP client. Check the exact resource, network, native USDC, merchant and amount. Set a spending limit before the host authorizes payment. Save the original operation for recovery.
  • With a prepaid key. Read the authenticated service quote, verify its eligible balance and tariff, and set an exact maximum debit plus a stable idempotency key.
Compare payment methods · Recover an original operation

Save what you need to continue or recover

For a fresh observation, supply an owned observation ID and the documented comparison mode. That request is a new operation. After a lost response, save the exact input, original payment credential or prepaid idempotency key, private recovery capability and original origin. Replay the original operation through its original access method. Never issue a replacement authorization while its status is uncertain.

Find the exact recovery path