← Learn
Liveproduct· 6 min read· #langchain#mcp#integration

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.

Forge vault contracts are unaudited. MCP APY fields are target/illustrative — not guaranteed returns. Do not combine USDC vault yield and FORGE emission boosts in user-facing summaries. Read Risks & Disclosures before routing real funds.

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.

ConcernLangChain / your codeForge MCP
Profile discoveryCall `list_profiles` in tool loopReturns live flags + vault map
Economics previewMandatory `simulate_deposit` stepTarget bps, disclaimers, illustrative APY
USDC approvalSeparate ERC-20 approve txNot included — by design
Vault depositSign returned calldataReturns encoded `deposit(assets, receiver)`
MonitoringPoll `get_balance`, subgraphOn-chain reads via RPC
LangChain agent responsibilities vs Forge MCP

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`).

  1. Add MCP client dependency (`@modelcontextprotocol/sdk` or LangChain MCP integration).
  2. Connect to Forge remote or local MCP URL.
  3. Fetch tools and wrap as LangChain tools with identical names for prompt clarity.
  4. Inject system prompt: chain ID 8453, native Base USDC only, simulate before deposit.
  5. 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.

  1. `list_profiles` — confirm `conservative` is live; `balanced` may return not-live until Middle timelock (see list_profiles guide).
  2. `get_vault_stats` — read share price, adapter count, TVL; cross-check Stats.
  3. `simulate_deposit` — review target allocation across Spark/Morpho/Aave legs and disclaimer strings.
  4. Wallet: `approve` USDC for Core vault spender if allowance insufficient.
  5. `deposit` — receive calldata; sign from agent EOA, not Forge deployer or CDP experimental wallet.
  6. `get_balance` — verify fUSDC shares after confirmation.
MVP profile gating: only `conservative` → Core vault deposits are live. `deposit(profile="balanced")` returns structured `PROFILE_NOT_LIVE` until Middle adapters execute. Agents must handle `isError: true` without retry loops that burn gas.

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

CodeCauseLangChain agent should
PROFILE_NOT_LIVEbalanced/aggressive before Phase 2Fall back to conservative or abort with docs link
PROFILE_UNKNOWNTypo in profile stringCall list_profiles and retry with valid id
RPC / timeoutBase RPC flakeRetry read tools; do not double-broadcast deposit
Insufficient allowanceMissing USDC approveRun approve tool before deposit calldata
Common Forge MCP errors — agent behavior

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.

This is educational content — not investment, tax, or legal advice. Forge MCP provides plumbing, not portfolio management. Principal loss is possible via smart-contract bugs, USDC depeg, or underlying protocol failure. No insurance or principal protection. Unaudited contracts; do not use unverifiable APY in public marketing (R4 claim hygiene).

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

LinkedIn

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