OpenAI Agents SDK + Forge MCP for DeFi treasuries
How to wire OpenAI Agents SDK agents to Forge Treasury MCP — tool policies, PROFILE_NOT_LIVE handling, and non-custodial calldata on Base.
Last updated: May 26, 2026 · Published 2026-05-26
Forge Treasury smart contracts are unaudited. Yield is variable and not guaranteed. Read Risks & Disclosures before depositing USDC or integrating MCP tools.
The OpenAI Agents SDK treats external capabilities as first-class tools — a natural fit for Forge Treasury's Model Context Protocol (MCP) server. Forge MCP at `https://mcp.forgetreasury.com/mcp` exposes vault tools that return deposit calldata and vault metadata for Base mainnet (chain ID `8453`). The Agents SDK orchestrates tool calls; your agent's wallet signs on-chain. Forge does not custody USDC or private keys in production (Option A).
Why OpenAI Agents SDK + MCP for DeFi treasuries
DeFi treasury automation fails when models hallucinate contract addresses or skip pre-flight checks. MCP registers Forge tools with JSON Schema at connection time — the Agents SDK passes validated arguments to `deposit`, `simulate_deposit`, and `list_profiles`. That is tighter than prompting an agent to "call the Forge API" from memory. For Base USDC idle balances, the SDK can enforce a tool policy: always `list_profiles` before `deposit`, always `simulate_deposit` before broadcast, never combine APY streams in final user messages.
- Typed tools: Parameters match MCP schemas — amount, agentAddress, profile.
- Tracing: Agents SDK run logs show which Forge tools fired — useful for audit trails.
- Handoffs: Separate "research" and "execution" agents — research reads stats; execution signs calldata.
- MCP transport: Streamable HTTP to Forge prod or stdio to local `pnpm mcp:dev`.
Integration architecture
Three components: (1) OpenAI Agents SDK agent with instructions enforcing non-custodial boundaries; (2) MCP server connection to Forge (remote or local); (3) signing layer — separate tool or human-in-the-loop for USDC `approve` and vault `deposit` broadcast. Production Forge MCP returns calldata only. The Agents SDK must not assume MCP executes transactions — that would blur the R4 non-custodial fact pattern.
| Agent role | Allowed Forge tools | Must not |
|---|---|---|
| Discovery | list_profiles, get_vault_stats | Broadcast transactions |
| Simulation | simulate_deposit, get_current_apy | Quote fixed APY as promise |
| Execution prep | deposit (calldata only) | Sign with server CDP wallet |
| Monitoring | get_balance, get_forge_rewards | Merge yield + FORGE in summaries |
Wiring MCP into the Agents SDK
OpenAI's MCP integration patterns (via `MCPServer` helpers in the Agents SDK ecosystem) connect to Forge at session start. Verify connectivity with `https://mcp.forgetreasury.com/health` before agent runs — `/mcp` expects MCP protocol clients, not browser GET requests. Map MCP tool names verbatim in agent instructions so traces align with Docs tables.
- Configure MCP server URL: production `https://mcp.forgetreasury.com/mcp` or local dev endpoint.
- Register Forge tools on the Agents SDK `Agent` instance.
- Set instructions: Base chain 8453, native USDC `0x833589…2913`, Core vault for conservative profile.
- Add guardrail: abort on `PROFILE_NOT_LIVE` — do not retry deposit with guessed parameters.
- Connect wallet/signing capability for approve + send steps outside MCP.
Production tool catalog
| Tool | Agents SDK use | Output highlights |
|---|---|---|
| list_profiles | Session bootstrap | Live flags: conservative yes, balanced pending |
| simulate_deposit | Mandatory pre-deposit | Target bps, disclaimers, no chain effect |
| deposit | Calldata generation | Encoded ForgeVault.deposit — sign locally |
| withdraw | Exit calldata | Performance fee context in docs, not tool |
| get_vault_stats | Monitoring hook | Share price, adapterCount, TVL |
| get_balance | Post-tx verification | fUSDC balance for agentAddress |
| get_current_apy | Planning only | advertisedAs = target/illustrative |
| get_forge_rewards | Separate emission stream | Not USDC yield |
| claim_forge | Merkle claim calldata | Optional; user-initiated |
Recommended run loop
- Agent calls `list_profiles` — confirm conservative → Core vault live.
- Agent calls `get_vault_stats` — cache adapterCount; invalidate after known timelock dates.
- User or policy agent requests deposit — run `simulate_deposit` first.
- Review simulation JSON with user; link FORGE emissions vs yield if APY discussed.
- Signing tool: USDC approve to Core vault `0x2C9a3922…193B` if needed.
- Agent calls `deposit` — signing tool broadcasts calldata from agent EOA.
- Agent calls `get_balance` — confirm fUSDC credited.
Handling PROFILE_NOT_LIVE and profile errors
MVP gating returns structured errors when agents request `balanced` or `aggressive` profiles on deposit, simulate, or APY tools. The Agents SDK should parse `isError: true` and `code: "PROFILE_NOT_LIVE"` — not treat the response as partial success. Full profile semantics: list_profiles guide. Until Middle timelock executes, Balanced strategy requires manual Core-only routing or waiting for Phase 2 multi-tx calldata.
| Code | Meaning | Agent action |
|---|---|---|
| PROFILE_NOT_LIVE | Strategy not yet depositable | Inform user; offer conservative or wait |
| PROFILE_UNKNOWN | Invalid profile string | Call list_profiles; suggest conservative |
| RPC failure | Base read timeout | Retry stats tools; never double-send deposit |
R4-aligned agent instructions
Embed compliance guardrails directly in Agents SDK `instructions` — they are enforceable policy, not marketing footnotes:
- Disclose unaudited contracts and early-stage TVL when recommending deposits.
- Never state performance fee is zero — 15% on profits above high-water mark at withdraw.
- Separate USDC vault yield (share price) from FORGE Merkle claims.
- Do not project billion-scale AUM or "default APY" from MCP constants.
- Include link to Risks & Disclosures in deposit recommendations.
Local dev: Agents SDK + AgentKit merge
Running `pnpm mcp:dev` with CDP credentials in `mcp-server/.env` merges Coinbase AgentKit wallet tools alongside Forge tools — useful for gas and transfer experiments on Base Sepolia. Never deploy CDP keys to Hetzner production MCP. Vault deposits must originate from the end-user agent EOA, not the CDP experimental wallet. Details: Coinbase AgentKit local setup.
Comparison with LangChain pattern
Both LangChain and OpenAI Agents SDK benefit from the same MCP contract — Forge tool names and schemas are framework-agnostic. Choose based on your runtime (Python Agents SDK vs LangGraph). See LangChain + Forge MCP for parallel patterns. Core product reference remains MCP-native treasury.
Frequently asked questions
Does the Agents SDK replace a wallet?
No. MCP returns calldata; you still need a signing integration (wallet MCP, viem script, or manual broadcast).
Can one agent call both Forge and AgentKit tools?
Locally yes — when AgentKit merge is enabled. Use AgentKit for gas/transfers only; route vault deposits through Forge calldata signed by the user EOA.
Is simulate_deposit optional?
Technically yes; operationally no. Adapter books change after timelock — simulation catches stale policy before irreversible deposits.
Summary
OpenAI Agents SDK + Forge MCP = traced tool loops for Base USDC treasuries. Bootstrap with `list_profiles`, simulate before deposit, sign locally, handle `PROFILE_NOT_LIVE` explicitly. Keep APY copy R4-safe. Production MCP is calldata-only, no CDP. Conservative strategy · Docs · Stats.
External resources
Primary protocol documentation and data sources. Forge is not affiliated with these projects; links are for education only.
Related reading
- LangChain + Forge MCP on BaseIntegration pattern for LangChain agents calling Forge Treasury MCP — simulation-first deposits, local signing, and R4-safe APY copy on Base mainnet.
- What is an MCP-native treasury?How Forge Treasury uses the Model Context Protocol so AI agents can discover, quote, and deposit into USDC vaults without custodial intermediaries.
- Coinbase AgentKit + Forge MCP — local setupHow to merge AgentKit wallet tools into local Forge MCP for dev — and why CDP credentials never ship to production Hetzner.
- MCP list_profiles: Conservative vs BalancedHow Forge MCP list_profiles maps strategies to vaults, why balanced returns PROFILE_NOT_LIVE, and the agent bootstrap sequence.
Share this article
Draft copy for social posts — review before publishing. URL: https://forgetreasury.com/learn/openai-agents-sdk-mcp-defi-treasury
Open Graph / preview card
OpenAI Agents SDK + Forge MCP Traced tool loops for Base USDC vaults — simulate, calldata, local sign. PROFILE_NOT_LIVE handling. Unaudited MVP. https://forgetreasury.com/learn/openai-agents-sdk-mcp-defi-treasury
Twitter / X
OpenAI Agents SDK + Forge MCP: list_profiles → simulate → sign calldata locally. Handle PROFILE_NOT_LIVE. Unaudited — /risks first: https://forgetreasury.com/learn/openai-agents-sdk-mcp-defi-treasury
The OpenAI Agents SDK pairs naturally with Forge Treasury MCP for DeFi treasury automation on Base — typed tools, simulation-first deposits, and explicit non-custodial signing. This guide covers error handling, R4-safe APY copy, and why production MCP excludes CDP keys. https://forgetreasury.com/learn/openai-agents-sdk-mcp-defi-treasury