Skip to content

Quickstart

This walks you from zero to a live, non-custodial tool call. It assumes you have an agent runtime that speaks MCP (Claude, the OpenAI/Gemini function-calling APIs, LangChain, CrewAI, or a raw MCP client).

1. Point your agent at the MCP server

The hosted server speaks streamable HTTP at:

https://mcp.crank.ing/mcp

No API key is required to connect or to call free read tools. You only need a payment header once you call a value-bearing action past the daily free tier (see Authentication & x402).

For a raw MCP client:

from fastmcp import Client

async with Client("https://mcp.crank.ing/mcp") as client:
    tools = await client.list_tools()
    print(f"{len(tools)} tools available")

    quote = await client.call_tool(
        "get_quotes",
        {
            "input_token": "So11111111111111111111111111111111111111112",  # SOL
            "output_token": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",  # USDC
            "amount": 1_000_000_000,  # 1 SOL in lamports
            "caller_id": "my-agent",
        },
    )
    print(quote)

2. Read before you act

Free reads orient your agent. A typical opening sequence:

  1. get_balances — what the wallet holds.
  2. portfolio_snapshot — total value and allocation, the denominator for sizing.
  3. get_quotes / token_info / verify_token — price and authenticity of a target.
  4. get_market_briefing / detect_regime — macro and regime context.

Call get_trading_workflow once to get the ordered tool map for a full trade-and-invest flow, so your agent does not have to infer sequencing from 100 tool descriptions.

3. Build, sign, broadcast

Value-bearing tools return an unsigned base64 transaction. The pattern is always the same:

result = await client.call_tool("jupiter_swap", {
    "input_token": "So11111111111111111111111111111111111111112",
    "output_token": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
    "amount": 100_000_000,
    "wallet_address": "<YOUR_AGENT_PUBLIC_KEY>",
    "caller_id": "my-agent",
})

if result["ok"]:
    unsigned_tx = result["transaction"]   # base64
    # sign locally with YOUR key, then broadcast (or pass back via signed_transaction)

Crank only ever sees public keys. Signing happens in your process or signer.

4. Handle the payment gate

Past the daily free tier, a value-bearing call returns:

{"ok": false, "error": {"code": "PAYMENT_REQUIRED", "fee_usd": 0.18,
 "facilitator": "https://...", "accepts": [...]}}

Construct an x402 payment for the quoted amount, then retry the call with the payment_header argument set. Full flow: Authentication & x402.

5. Go to mainnet

Build and test against devnet (the default sandbox). When your flow is proven, switch the server's network and fund a mainnet wallet. Nothing about the tool surface changes between networks.

Next