Minimal AI-agent style scripts that buy video game keys via CDK API using x402 USDC payments on Base. Drop-in starting point for your own agent.
Three ways to use CDK:
| Setup time | Tools | |
|---|---|---|
| MCP (Claude Desktop / Cursor / Cline) | 30 seconds | Add JSON config → restart → chat |
| TypeScript | 5 minutes | npm i viem + agent.ts |
| Python | 5 minutes | pip install web3 requests + agent.py |
All three buy a real product key. All three default to Base Sepolia testnet so you can test end-to-end without spending real money.
Add this to ~/Library/Application Support/Claude/claude_desktop_config.json (Mac) or %APPDATA%\Claude\claude_desktop_config.json (Windows):
{
"mcpServers": {
"cdk": {
"url": "https://mcp.cdk.bot/mcp",
"transport": "streamable-http"
}
}
}Restart Claude. Type: "Search for Cyberpunk 2077 on Steam and show me the cheapest offer." Claude uses 8 CDK tools natively. Same config works in Cursor (~/.cursor/mcp.json) and Cline.
cd typescript
npm install
export PRIVATE_KEY=0x... # your testnet wallet private key
npx tsx agent.ts "Cyberpunk 2077"Output:
[1/4] Searching for 'Cyberpunk 2077'...
→ Cyberpunk 2077 (Steam) — $24.99
[2/4] Getting price quote...
→ $24.99 USDC to 0x88E54... (5 min TTL)
[3/4] Sending USDC on base-sepolia...
→ sent 24.99 USDC, tx=0xab12...
[4/4] Confirming purchase + receiving key...
✓ Key delivered: SANDBOX-AAAA-BBBB-CCCC
Order ID: 0eb9...
Receipt: https://api.cdk.bot/orders/0eb9.../receipt
cd python
pip install -r requirements.txt
export PRIVATE_KEY=0x...
python agent.py "Cyberpunk 2077"Same flow as TypeScript. Same testnet defaults.
Agent CDK API Base chain
│ │ │
├─── GET /games/match ──→ │ │
│←── { best_match } ──────┤ │
│ │ │
├─── POST /purchase ────→ │ │
│←── 402 + quote_id ──────┤ (price locked 5 min) │
│ │ │
├─── ERC-20 transfer USDC ──────────────────────────→ │
│ │ │
├─── POST /purchase ────→ │ │
│ + tx_hash │ verify on-chain ─────→ │
│ │ (5 block confirmations) │
│←── { key_code } ────────┤ │
Three HTTP calls. One on-chain tx. Price is locked by quote_id (5 min TTL) so it can't drift between browse and pay. Refunds (instant for not_delivered, 24h SLA for key issues) are paid back to the sending wallet with onchain proof.
export CHAIN=base # default is base-sepoliaMainnet USDC contract: 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913
Need real USDC + ETH for gas. ~$25 USDC + $0.01 gas for a typical game.
- Sepolia ETH (for gas): https://www.alchemy.com/faucets/base-sepolia
- Sepolia USDC: https://faucet.circle.com/
Approve ~$25 USDC + a small amount of ETH and you can run dozens of test purchases.
- API: https://api.cdk.bot
- MCP server: https://mcp.cdk.bot/mcp
- Agent card: https://api.cdk.bot/.well-known/agent.json
- x402 descriptor: https://api.cdk.bot/.well-known/x402
- OpenAPI: https://api.cdk.bot/openapi.json
- Docs: https://api.cdk.bot/docs
MIT