FTK market data (ftk-mcp)

MCP server for Polymarket wallet true PnL and leaderboard, Polymarket BTC markets vs options-implied probability, GPU rental markets and cross-venue perp funding/spreads. Pays per call in USDC via x402 with a per-call price cap; free sample tools.

文件

FTK agent kit

Prediction-market and crypto-derivatives data for trading agents, paid per call in USDC with x402 - no account, no API key, no subscription. This kit is everything an agent needs to call the FTK market data API:

  • ftk-mcp: an MCP server (stdio) that exposes every /v1 endpoint as a tool and does the x402 payment step itself (402 -> check price -> sign USDC authorization -> retry), with a per-call price cap;
  • examples/btc_edge_agent.py: a small agent that pays for one call and prints Polymarket BTC markets that are mispriced against the options market;
  • tests that run a full paid call against a local API with the real x402 middleware and an offline facilitator (no chain, no real money).

What the API sells: Polymarket wallet true PnL and a PnL leaderboard, Polymarket BTC price-target markets vs. options-implied probability (edge after fees), Polymarket GPU rental-price markets, and live cross-venue perpetual-futures funding and spreads.

Polymarket data is for individual traders and individual developers only; it is not sold to funds, market makers, fintech companies or data vendors. FTK is not affiliated with Polymarket or Deribit and uses only official public APIs. MIT licence (see LICENSE). Source: https://github.com/0x3f97/ftk-agent-kit. Not on PyPI yet; install from that repository as below.

Quick start (about 3 minutes)

Requires Python 3.10+ and uv.

1. Install and look at the data for free (no wallet, nothing is signed):

git clone https://github.com/0x3f97/ftk-agent-kit && cd ftk-agent-kit
uv sync
curl -s https://api.ftkai.io/v1/sample/polymarket-btc-edge | head -c 600; echo     # free fixed sample, same schema
uv run python examples/btc_edge_agent.py                                          # sample + the price quote

The last command prints the schema check and price: 0.5 USDC on eip155:8453 to 0x...: that is the 402 offer.

2. Give the agent a wallet. Create a new wallet just for this, put a few USDC on Base in it (no ETH needed: the facilitator pays gas), and export its key in the shell that runs the agent:

export FTK_BUYER_PRIVATE_KEY=0x...     # dedicated low-balance wallet, never your main wallet
export FTK_MAX_PRICE_USD=0.50          # refuse any single payment above this

3. First paid call:

uv run python examples/btc_edge_agent.py --min-edge 0.02 --tier 1500
# example output:
# paid 0.5 USDC, settlement 0x..., data age 312 s
# +0.034  YES  model 0.1079  ask 0.058  Will Bitcoin dip to $40,000 by December 31, 2026?

4. Use it from your agent (Claude Code shown; any stdio MCP client works, see Configure below):

claude mcp add ftk -e FTK_MAX_PRICE_USD=0.50 -e FTK_BUYER_PRIVATE_KEY=$FTK_BUYER_PRIVATE_KEY \
  -- uv run --directory "$PWD" ftk-mcp

Then ask: "Use ftk_pm_btc_edge to list Polymarket BTC markets with at least 2 cents of edge after fees."

Free alternatives before paying: ftk_sample (fixed rows, exact paid schema) and ftk_free (real but delayed or truncated data, small daily allowance per IP).

Tools

toolcostreturns
ftk_docsfreethe API description (/llms.txt): prices, fields, freshness, venues, rate limits, when you are not charged
ftk_sample(endpoint, min_vol, limit)freeFIXED illustrative rows (placeholder symbols, invented numbers) in exactly the paid schema, so an agent can check fields before paying
ftk_funding(min_vol, limit)$0.01 per calllive funding opportunities: best short/long venue pair per symbol, annualized spread now/24h/7d, entry basis, fees, volume, capacity
ftk_spreads(min_vol, limit)$0.01 per calllive spreads: highest bid vs lowest ask venue per symbol, gross and net of estimated taker fees (bp), funding carry
ftk_pm_wallet(address)$0.25 per callPolymarket wallet: native PnL vs true PnL (unpriced placeholder positions at 0), strategy breakdown; pay-per-call covers cached wallets (the scored set), others get a free 404; with FTK_API_KEY an uncached wallet is queued (free 503, Retry-After ~2 min)
ftk_pm_leaderboard(window, max_capital, label, limit)$0.50 per callPolymarket wallets ranked by PnL after fees, with coverage and computed_at
ftk_pm_gpu_rental(gpu, family, period)$0.25 per callPolymarket GPU rental-price markets: bid/ask, implied probability, days remaining, market-implied average per event, live public GPU rental prices (GPU.ai, Akash, Lambda) and the gap; FTK own rental index
ftk_pm_btc_edge(tier, min_edge, kind, min_hours)$0.50 per callPolymarket BTC price-target markets vs options-implied probability: fill cost for 400/1500/5000 USDC and edge after fees (derived values only; not affiliated with Polymarket or Deribit)

Paid tools return {"status", "paid", "quote", "transaction", "as_of", "age_seconds", "rows"}. as_of / age_seconds describe the snapshot (refreshed about once a minute).

Configure (Claude Desktop / Claude Code / any stdio MCP client)

{
  "mcpServers": {
    "ftk": {
      "command": "uv",
      "args": ["run", "--directory", "/path/to/ftk-agent-kit", "ftk-mcp"],
      "env": {
        "FTK_MAX_PRICE_USD": "0.50",
        "FTK_BUYER_PRIVATE_KEY": "<0x... key of a wallet holding a little USDC on Base>"
      }
    }
  }
}

Claude Code: claude mcp add ftk -e FTK_MAX_PRICE_USD=0.50 -e FTK_BUYER_PRIVATE_KEY=<key> -- uv run --directory /path/to/ftk-agent-kit ftk-mcp

variabledefaultmeaning
FTK_API_BASEhttps://api.ftkai.ioAPI origin
FTK_BUYER_PRIVATE_KEYunsetwallet key used to sign x402 payments. Without it the paid tools never pay: they return the price quote from the 402 response. Use a dedicated low-balance wallet.
FTK_MAX_PRICE_USD0.50refuse to sign any payment above this per call (0.50 covers every tool: Polymarket leaderboard and btc-edge $0.50, wallet $0.25; set 0.01 to allow only the $0.01 tables)
FTK_API_KEYnonemonthly-plan key: sent as x-api-key, no x402 payment is signed
FTK_EXPECTED_PAY_TOunsetif set, refuse to pay any other recipient address

How payment works

  1. The tool sends a plain GET to the paid endpoint. The API answers 402 Payment Required with a PAYMENT-REQUIRED header (base64 JSON: amount, asset, network, payTo).
  2. The tool checks the offer before signing: scheme exact, network Base mainnet (eip155:8453), asset = USDC on Base, amount <= FTK_MAX_PRICE_USD, and payTo = FTK_EXPECTED_PAY_TO if set. Anything else is refused and nothing is signed.
  3. It signs an EIP-3009 USDC authorization with the x402 SDK and retries with PAYMENT-SIGNATURE. The server verifies the signature, runs the query, and settles the payment only if the response is a success; on any error (4xx/5xx, including 503 for a stale snapshot) nothing is settled. The settlement transaction hash is returned as transaction.

Note: a 200 is charged even when it is an empty array, and a call that times out on the client side after the server answered may still be settled. See ftk_docs for the exact policy.

Test

uv sync                          # includes the dev group: pytest, fastapi, uvicorn, x402[fastapi]
uv run pytest                    # no network, no real money
  • tests/test_server.py: offer checks, price cap, quote-only without a key, API-key mode, tool parameters.
  • tests/test_paid_call_local.py: starts a local stand-in API (tests/local_api.py) guarded by the real x402 FastAPI middleware, with an offline facilitator (tests/fake_facilitator.py) that verifies the EIP-3009 signature. The MCP server, over stdio, pays for funding, wallet, leaderboard and btc-edge with a key generated in the test.
  • tests/test_example_agent.py: the example agent against the same local API, dry run and paid run.
  • Optional: FTK_TEST_BASE=http://127.0.0.1:8081 uv run pytest adds a stdio round-trip against a running API (free tools and the 402 quote only; it never pays).

Files

pathwhat
src/ftk_mcp/server.pythe MCP server (one file)
examples/btc_edge_agent.pyexample agent
tests/tests, local stand-in API, offline facilitator
pyproject.toml, uv.lockdependencies: mcp, httpx, x402[evm] (dev: pytest, fastapi, uvicorn, x402[fastapi])
integrations/ftk-mcp-lite: three free-by-default tools with paste-ready configs for Vibe-Trading and Condor (README)
LICENSEMIT