Agents

Build your own

Every CoinGraph agent is a few calls and a rule. Chain the same calls with your own rule, keep the ids, and your agent answers with sources and a proof without running a data pipeline.

The three building blocks #

MCP toolRESTGives youCredits
check_tokenPOST /v1/evaluateThe verdict across seven dimensions, your order against real liquidity, your rules pass, fail or unknown, and a proof id.5
get_token_snapshotGET /v1/state/{token}Only the sections your rule needs: derivatives with crowding, onchain flows, supply with unlocks, security.1
get_proofGET /v1/verify/{id}The exact object, its SHA-256 and the source calls, to keep with whatever your agent does next.free

Each recipe below makes the same decision: buy $5K of SOL only if the check says proceed, every rule passes, and futures are not crowded. One run costs 6 credits. A key takes two minutes: Keys & pricing.

Three recipes #

The Claude recipe needs CoinGraph connected and no code. The TypeScript and Python recipes send an account key.

Before I buy $5K of SOL, use CoinGraph:

1. Call check_token with token "solana", size_usd 5000 and this policy:
   min_depth_usd 500000, max_funding_pct 0.05, allow_mint_authority false.
2. Call get_token_snapshot for "solana" with sections "derivatives,onchain".
3. Answer GO only if the verdict is proceed, no policy rule is fail or unknown,
   and derivatives.crowding.regime is not "crowded". Otherwise answer HOLD.
4. Give the reasons with their sources, then call get_proof with the check's id
   and quote its sha256.

The policy object #

Send any of these with check_token or POST /v1/evaluate. Each comes back in policy_check as pass, fail or unknown with a one-line detail.

RuleMeansExample
min_depth_usdMinimum liquidity within 2% of the price.500000
max_top10_holder_pctMaximum share of supply held by the top 10 holders, in percent.60
max_funding_pctMaximum futures funding per 8 hours, in percent.0.05
max_exchange_inflow_usdMaximum net USD moved onto exchanges in 24 hours.5000000
allow_mint_authorityWhether a contract that can still mint or freeze is acceptable. Native coins pass, since no admin can mint them.false
max_unlock_pctMaximum share of supply unlocking in the next 30 days, in percent. Unknown where no schedule covers the token.2
!

Unknown is not a pass

A rule CoinGraph cannot measure is unknown, and a section it cannot measure is "unassessed". Decide what your agent does with each. The recipes above treat both as HOLD. Portfolio Checkup applies a policy like this to every holding in a wallet.

Starter files #

The examples/ folder of the repository has a smaller version: one check, no snapshot, and an exit code your agent can act on. No account or key is needed for a plain check. Add a size as the second argument, with COINGRAPH_KEY set, and it costs 5 credits.

Run
npx tsx check-before-acting.ts chainlink

export COINGRAPH_KEY=cg_live_your_key_here
npx tsx check-before-acting.ts solana 5000
The file
// Check a token with CoinGraph before your agent acts on it. Needs Node 18 or later, and no packages.
//
//   npx tsx check-before-acting.ts chainlink            free check, no key needed
//   npx tsx check-before-acting.ts solana 5000          sized to your order, needs COINGRAPH_KEY, costs 5 credits
//
// Exit code: 0 proceed, 1 caution or avoid, 2 the check could not be completed.
// CoinGraph never executes, custodies or advises. Your agent decides what to do with the answer.

const API = process.env.COINGRAPH_API ?? "https://coingraph.ai/api/v1";
const KEY = process.env.COINGRAPH_KEY;

type Reason = { dimension: string; text: string; source: string };
type Check = {
  id: string;
  as_of: string;
  data: {
    token: { id: string; symbol: string };
    verdict: "proceed" | "caution" | "avoid";
    confidence: number;
    reasons: Reason[];
    size_check: { order_usd: number; estimated_impact_pct: number | string } | null;
  };
};

async function checkToken(token: string, sizeUsd?: number): Promise<{ check: Check; charged: string | null; left: string | null }> {
  if (sizeUsd !== undefined && !KEY) throw new Error("A sized check needs a key. Create one at https://coingraph.ai/account/keys, then set COINGRAPH_KEY.");
  const res = await fetch(sizeUsd === undefined ? `${API}/evaluate/${encodeURIComponent(token)}` : `${API}/evaluate`, {
    method: sizeUsd === undefined ? "GET" : "POST",
    headers: { "content-type": "application/json", ...(KEY ? { authorization: `Bearer ${KEY}` } : {}) },
    body: sizeUsd === undefined ? undefined : JSON.stringify({ token, size_usd: sizeUsd }),
    signal: AbortSignal.timeout(30_000),
  });
  const body = await res.json();
  if (!res.ok) throw new Error(`${res.status} ${body.error?.code ?? "error"}: ${body.error?.message ?? "request failed"}`);
  return { check: body, charged: res.headers.get("x-credits-charged"), left: res.headers.get("x-credits-remaining") };
}

async function main() {
  const [token = "chainlink", size] = process.argv.slice(2);
  const sizeUsd = size === undefined ? undefined : Number(size);
  if (sizeUsd !== undefined && !(sizeUsd > 0)) throw new Error("The order size must be a positive number of US dollars.");

  const { check, charged, left } = await checkToken(token, sizeUsd);
  const { verdict, confidence, reasons, size_check } = check.data;

  console.log(`${check.data.token.symbol}: ${verdict} (confidence ${confidence}), as of ${check.as_of}`);
  for (const r of reasons) console.log(`  ${r.dimension}: ${r.text} [${r.source}]`);
  if (size_check) console.log(`  order: $${size_check.order_usd}, estimated impact ${size_check.estimated_impact_pct}%`);
  console.log(`Proof: https://coingraph.ai/proof/${check.id}`);
  if (charged) console.log(`Credits: ${charged} charged, ${left} left`);

  // Your agent's decision goes here. Keep the proof id with whatever it does next.
  process.exitCode = verdict === "proceed" ? 0 : 1;
}

main().catch((e: Error) => {
  // Fail closed: if the check can't be completed, the agent shouldn't act as though it passed.
  console.error(`Check not completed: ${e.message}`);
  process.exitCode = 2;
});
Exit codeMeaningWhat your agent should do
0proceedCarry on, and keep the proof id with what it does next.
1caution or avoidRead the reasons, then reduce, wait or stop.
2The check could not be completedStop. A failed check is not a pass.

Every check has a public proof page with the exact answer, its fingerprint and its sources. CoinGraph never executes, custodies or advises: your agent decides.

i

Note

Stuck on your first call? Write to support@coingraph.ai with what you tried.