# CDP AgentKit

## What This Is

AgentKit is Coinbase's SDK for building AI agents that can perform onchain actions — transfers, swaps, contract deployments, NFT operations. It provides pre-built "tools" that plug into LLM frameworks (LangChain, Vercel AI SDK, MCP).

**CLAUDIA's decision:** Use AgentKit as an **internal library** for blockchain ops, NOT as the MCP server framework. CLAUDIA's MCP server uses raw `@modelcontextprotocol/sdk` for full control over exposed tools (see `claudia-mcp-server` skill).

***

## Why NOT AgentKit MCP for CLAUDIA's MCP Server

AgentKit MCP auto-exposes blockchain tools (transfer, swap, deploy) to any connected client. For CLAUDIA's MCP server, this is wrong because:

1. **Security risk** — external agents could trigger transfers from CLAUDIA's wallet
2. **Wrong tools** — CLAUDIA exposes analysis/scanner tools, not generic blockchain ops
3. **No control** — can't customize tool descriptions, schemas, or access control
4. **Tool sprawl** — adds 15+ blockchain tools alongside CLAUDIA's 6 DeFi tools

**Use AgentKit MCP for:** Internal development tools, testing, admin operations. **Use raw MCP SDK for:** Production mcp.claudia.wtf server.

***

## Where AgentKit IS Useful for CLAUDIA

### As an Internal Library

CLAUDIA's MCP server tools sometimes need to do blockchain ops behind the scenes:

```typescript
// Inside a CLAUDIA MCP tool handler — NOT exposed as MCP tool itself
import { CdpClient } from '@coinbase/cdp-sdk'

// MCP tool: CLAUDIA Full Analysis
server.registerTool('full_analysis', schema, async ({ ticker }) => {
  const result = await runFullAnalysis(ticker)

  // Internal blockchain op: write verdict to D1 + optionally tip analyst wallet
  // Uses CDP SDK directly, NOT exposed as MCP tool
  const cdp = new CdpClient()
  const wallet = await cdp.evm.getOrCreateAccount({ name: 'claudia-mcp-agent' })
  // ... internal operation

  return { content: [{ type: 'text', text: JSON.stringify(result) }] }
})
```

### For Admin/Dev Tools

AgentKit MCP is great for internal Claude Code tools during development:

```bash
# Add AgentKit MCP to Claude Code for admin operations
claude mcp add --transport stdio coinbase-agentkit \
  -- npx -y @coinbase/agentkit-model-context-protocol

# Now Claude Code can:
# - Check treasury wallet balance
# - Execute manual burns
# - Transfer tokens for testing
# - Deploy contracts
```

### For Future Autonomous Agent Features

If CLAUDIA builds autonomous agents (Phase 4+) that need to independently execute onchain operations, AgentKit provides the tool framework:

```typescript
import { AgentKit } from '@coinbase/agentkit'
import { getMcpTools } from '@coinbase/agentkit-model-context-protocol'

// Initialize AgentKit with CLAUDIA's agent wallet
const agentKit = await AgentKit.from({
  cdpApiKeyId: process.env.CDP_API_KEY_ID,
  cdpApiKeySecret: process.env.CDP_API_KEY_SECRET,
  cdpWalletSecret: process.env.CDP_WALLET_SECRET,
})

// Get all available blockchain tools
const tools = getMcpTools(agentKit)
// tools includes: transfer, swap, deploy, getBalance, etc.
```

***

## Packages

```bash
# Core AgentKit
npm install @coinbase/agentkit

# MCP extension (for internal tools)
npm install @coinbase/agentkit-model-context-protocol

# Also needs
npm install @modelcontextprotocol/sdk @coinbase/cdp-sdk
```

***

## Available Tools (AgentKit MCP)

When using AgentKit MCP, these tools are auto-exposed:

| Tool                    | What It Does                         |
| ----------------------- | ------------------------------------ |
| `getBalance`            | Check token balance on any EVM chain |
| `transfer`              | Send tokens to address               |
| `swap`                  | Swap tokens on supported DEXs        |
| `deployContract`        | Deploy a smart contract              |
| `callContract`          | Call a contract function             |
| `getWalletAddress`      | Get agent's wallet address           |
| `requestFaucet`         | Get testnet tokens                   |
| `signMessage`           | Sign arbitrary messages              |
| `getTransactionReceipt` | Check tx status                      |

**These are powerful but dangerous** if exposed publicly. Only use internally.

***

## Networks Supported

AgentKit supports all EVM networks + Solana:

* Base, Base Sepolia
* Ethereum, Sepolia
* Arbitrum, Optimism, Polygon
* Solana (via separate module)

For CLAUDIA: Base is the only relevant network.

***

## Integration with CLAUDIA's Architecture

```
CLAUDIA Architecture with AgentKit:

mcp.claudia.wtf (production MCP server)
  → Raw @modelcontextprotocol/sdk
  → CLAUDIA-specific tools (analysis, scanner, agents)
  → Server Wallets for internal blockchain ops
  → NOT AgentKit MCP

Internal admin tools (development)
  → AgentKit MCP via Claude Code
  → Full blockchain tool access
  → Treasury management, testing, debugging

Future autonomous agents (Phase 4+)
  → AgentKit as library
  → Agent decides when to swap, transfer, etc.
  → Spending limits via CDP Policies
```

***

## Common Mistakes

1. **Using AgentKit MCP as production MCP server** — exposes blockchain ops to external agents
2. **Not setting policies** — AgentKit agents can spend unlimited by default
3. **Mixing AgentKit tools with CLAUDIA tools in same MCP server** — confuses LLM tool selection
4. **Forgetting wallet secret** — AgentKit can read but not write without CDP\_WALLET\_SECRET
5. **Using AgentKit for simple transfers** — `@coinbase/cdp-sdk` is simpler for one-off ops

***

## See Also

* `claudia-mcp-server` — CLAUDIA's production MCP server (uses raw SDK, not AgentKit)
* `cdp-server-wallets` — direct SDK for backend wallet operations
* `cdp-agentic-wallet` — CLI-based agent wallet (different approach)
* AgentKit repo: <https://github.com/coinbase/agentkit>
* AgentKit docs: <https://docs.cdp.coinbase.com/agent-kit/welcome>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.claudia.wtf/for-developers/cdp-agentkit.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
