LangChain + Forge MCP on Base
Integration pattern for LangChain agents calling Forge Treasury MCP — simulation-first deposits, local signing, and R4-safe APY copy on Base mainnet.
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.
LangChain agents can treat Forge Treasury as a typed tool surface over the Model Context Protocol (MCP) — not a REST API with ad hoc routes. Production Forge MCP at `https://mcp.forgetreasury.com/mcp` exposes nine vault tools (`deposit`, `withdraw`, `simulate_deposit`, `get_vault_stats`, `get_balance`, `get_current_apy`, `list_profiles`, `get_forge_rewards`, `claim_forge`) that return calldata and metadata for Base mainnet (chain ID `8453`). Your LangChain agent signs transactions locally; Forge never holds user keys or USDC.
Why LangChain + MCP for Base treasuries
LangChain's tool-calling layer expects JSON Schema parameters and structured responses. MCP registers the same schemas at connection time — the model sees `deposit(amount, agentAddress, profile)` instead of inventing HTTP paths. For Base USDC treasuries, that reduces hallucinated vault addresses and wrong chain IDs. Forge embeds canonical constants (Core vault `0x2C9a3922b426005B979FDD1A8F43Eb61B309193B`, USDC `0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913`) in tool outputs so prompt-stale memory does not override live MCP responses.
- Discoverability: `tools/list` enumerates capabilities — no hidden `/api/v2/deposit` routes.
- Validation: MCP clients reject malformed tool args before broadcast.
- Composability: Chain `list_profiles` → `simulate_deposit` → wallet `approve` → `deposit` in one agent graph.
- Non-custodial boundary: Forge tools return calldata; LangChain wallet tools sign and send.
Architecture pattern
A typical integration runs three layers: (1) LangChain agent with system prompt enforcing simulation-before-deposit and R4-safe APY copy; (2) MCP client connected to Forge via Streamable HTTP (`/mcp` endpoint); (3) local signer — viem/ethers, Cast, or a wallet MCP — that holds the agent EOA private key. Production Hetzner MCP (Option A) ships Forge tools only — no CDP credentials on the server. Pair Forge MCP with your own signing provider; do not assume MCP executes transactions.
| Concern | LangChain / your code | Forge MCP |
|---|---|---|
| Profile discovery | Call `list_profiles` in tool loop | Returns live flags + vault map |
| Economics preview | Mandatory `simulate_deposit` step | Target bps, disclaimers, illustrative APY |
| USDC approval | Separate ERC-20 approve tx | Not included — by design |
| Vault deposit | Sign returned calldata | Returns encoded `deposit(assets, receiver)` |
| Monitoring | Poll `get_balance`, subgraph | On-chain reads via RPC |
Connecting LangChain to Forge MCP
LangChain supports MCP through community adapters and the official MCP SDK bridge patterns. At a high level: instantiate an MCP client pointed at `https://mcp.forgetreasury.com/mcp`, call `initialize`, then map each MCP tool to a LangChain `StructuredTool`. Health checks use `https://mcp.forgetreasury.com/health` — not the `/mcp` URL in a browser. For local development, run `pnpm mcp:dev` from the monorepo with `mcp-server/.env` configured for your target chain (Base mainnet `8453` or Sepolia `84532`).
- Add MCP client dependency (`@modelcontextprotocol/sdk` or LangChain MCP integration).
- Connect to Forge remote or local MCP URL.
- Fetch tools and wrap as LangChain tools with identical names for prompt clarity.
- Inject system prompt: chain ID 8453, native Base USDC only, simulate before deposit.
- Attach a wallet/signing tool for approve + broadcast — Forge MCP does not sign.
Recommended agent workflow on Base
Encode this sequence in your LangChain graph or ReAct loop. Skipping steps is how agents deposit to wrong profiles or quote misleading APY.
- `list_profiles` — confirm `conservative` is live; `balanced` may return not-live until Middle timelock (see list_profiles guide).
- `get_vault_stats` — read share price, adapter count, TVL; cross-check Stats.
- `simulate_deposit` — review target allocation across Spark/Morpho/Aave legs and disclaimer strings.
- Wallet: `approve` USDC for Core vault spender if allowance insufficient.
- `deposit` — receive calldata; sign from agent EOA, not Forge deployer or CDP experimental wallet.
- `get_balance` — verify fUSDC shares after confirmation.
System prompt guardrails (R4-aligned)
LangChain system prompts are part of your compliance surface. R4 legal research flags unverifiable APY, fixed-return promises, and combined yield+token headlines as high-risk marketing. Bake these rules into the agent template:
- Never claim "guaranteed", "audited", or "insured" — Forge contracts are unaudited MVP.
- Report USDC share-price change separately from FORGE Merkle claims (FORGE emissions guide).
- Disclose early-stage TVL (~$10 smoke testing as of May 2026) when showing vault stats.
- Link Risks & Disclosures in any user-facing deposit recommendation.
- Treat `get_current_apy` as planning data with `advertisedAs: target/illustrative` semantics.
Error handling in LangChain tool loops
| Code | Cause | LangChain agent should |
|---|---|---|
| PROFILE_NOT_LIVE | balanced/aggressive before Phase 2 | Fall back to conservative or abort with docs link |
| PROFILE_UNKNOWN | Typo in profile string | Call list_profiles and retry with valid id |
| RPC / timeout | Base RPC flake | Retry read tools; do not double-broadcast deposit |
| Insufficient allowance | Missing USDC approve | Run approve tool before deposit calldata |
Local vs production MCP endpoints
Production integrators should use `https://mcp.forgetreasury.com/mcp` — eight Forge tools, no AgentKit merge, no CDP env vars on Hetzner. Local full stack (`pnpm mcp:dev` + `mcp-server/.env`) can merge Coinbase AgentKit wallet tools for gas experiments — see Coinbase AgentKit local setup. AgentKit merge is local dev only; never deploy CDP keys to production MCP. Vault deposits must still originate from the end-user agent EOA.
Conservative routing reference
LangChain agents defaulting to stablecoin yield should route `profile: "conservative"` — 100% Core vault, diversified across Spark, Morpho, and Aave. This is a strategy label, not a separate contract. Full parameter table: Conservative strategy. After P2-C0 timelock (~May 27, 2026), Core expands from three to five adapter legs — re-run `get_vault_stats` before automated sweeps.
Testing checklist
- Verify MCP health endpoint returns OK before agent session start.
- Dry-run full tool chain with `simulate_deposit` — zero on-chain effect.
- First mainnet deposit: $1–10 USDC only; confirm fUSDC on Basescan.
- Log MCP tool version / server build in agent telemetry for incident replay.
- Run withdraw path on test amount before scaling automation.
Related reading
Start with MCP-native treasury for protocol philosophy, Cursor Forge MCP tutorial for step-by-step tool calls, and MCP vs REST if evaluating API styles. For OpenAI-specific SDK patterns, see OpenAI Agents SDK + MCP.
Frequently asked questions
Does LangChain need AgentKit to use Forge MCP?
No. Production Forge MCP is standalone. AgentKit is optional for local wallet/gas tooling — not required for calldata-only vault integration.
Can Forge MCP sign transactions for my LangChain agent?
No — by design. MCP returns calldata; your agent signs with its EOA. This preserves the non-custodial posture described in R4 legal research (FinCEN calldata-only fact pattern).
Which Base network — mainnet or Sepolia?
Production MCP targets Base mainnet (8453) with Circle native USDC. Sepolia testnet uses different vault addresses — see deploy docs. Agents must not hard-code Sepolia USDC on mainnet flows.
Summary for integrators
LangChain + Forge MCP = structured tool discovery, simulation-first deposits, local signing on Base. Use `list_profiles` → `simulate_deposit` → approve → `deposit`. Handle `PROFILE_NOT_LIVE` gracefully. Keep APY and FORGE emissions separate in copy. Production MCP has no CDP keys. Contracts unaudited; TVL early-stage. Risks · Docs · Stats.
External resources
Primary protocol documentation and data sources. Forge is not affiliated with these projects; links are for education only.
Related reading
- 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.
- OpenAI Agents SDK + Forge MCP for DeFi treasuriesHow to wire OpenAI Agents SDK agents to Forge Treasury MCP — tool policies, PROFILE_NOT_LIVE handling, and non-custodial calldata on Base.
- Agent treasury automation with Cursor and Forge MCPCursor MCP deeplink install, first vault info call, approve/deposit calldata walkthrough, test amounts, and troubleshooting on Base mainnet.
- 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/langchain-mcp-forge-treasury-base
Open Graph / preview card
LangChain agents + Forge MCP on Base MCP tool loop for USDC vault deposits — simulate, approve, sign locally. Unaudited MVP; separate yield from FORGE emissions. https://forgetreasury.com/learn/langchain-mcp-forge-treasury-base
Twitter / X
LangChain + Forge MCP: list_profiles → simulate_deposit → sign calldata locally on Base. Non-custodial, unaudited — read risks first: https://forgetreasury.com/learn/langchain-mcp-forge-treasury-base
LangChain integrators can treat Forge Treasury as a typed MCP tool surface on Base mainnet — structured discovery, simulation-before-deposit, and local EOA signing. Production MCP returns calldata only; APY fields are illustrative. Educational integration guide: https://forgetreasury.com/learn/langchain-mcp-forge-treasury-base