Skip to content

cdkbotmcp/cdk-agent-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cdk-agent-example

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.


Option 1 — Claude Desktop (no code)

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.


Option 2 — TypeScript script

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

Option 3 — Python script

cd python
pip install -r requirements.txt

export PRIVATE_KEY=0x...
python agent.py "Cyberpunk 2077"

Same flow as TypeScript. Same testnet defaults.


How it works (the x402 flow)

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.

Switching to mainnet

export CHAIN=base                  # default is base-sepolia

Mainnet USDC contract: 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913 Need real USDC + ETH for gas. ~$25 USDC + $0.01 gas for a typical game.

Getting testnet funds (free)

Approve ~$25 USDC + a small amount of ETH and you can run dozens of test purchases.

Discovery

License

MIT

About

Minimal AI-agent scripts that buy game keys via CDK x402 API. Python + TypeScript + Claude Desktop MCP. Testnet by default.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors