Using Legend Prime with Claude Code
Connect Claude Code to Legend Prime and manage DeFi portfolios through natural conversation.Quick Setup (Local MCP — recommended)
The local MCP server gives Claude Code full capabilities including one-shot plan execution with automatic signing.The
legend-cli binary installation paths below are planned but may not yet be available. Check legend.xyz for the latest.1. Install the CLI
2. Log in
3. Connect the local MCP server
4. Verify
list_accounts, get_portfolio, plan_and_execute.
5. Create a signing account (optional, for transactions)
Ask Claude:“Create a new Legend account with keygen”Claude calls
create_account, which generates a P256 key in Secure Enclave and creates a Turnkey-backed sub-account. This is a one-time setup.
Alternative: Remote MCP
If you only need read-only access (portfolios, activities, reference data), the remote MCP server is simpler:/mcp > “legend” > “Authenticate” > Google SSO.
Example Session
Read-only operations (no signing needed)
You: What’s in my Legend portfolio?Claude calls
list_accounts then get_portfolio and reports your holdings:
“You have 1,623.”
You: What are the best yield rates for USDC?Claude reads the
yield_markets from your portfolio and compares:
“Best USDC yields: Compound on Base at 4.2%, Aave on Arbitrum at 3.8%, Morpho on Ethereum at 5.1%.”
Creating and executing plans (local MCP)
You: Put $500 of my USDC into that Morpho vault on EthereumWith the local MCP server, Claude calls
plan_and_execute — it creates the plan, signs it with your P256 key, and executes in one step:
“Done. I executed an earn plan for 500,000,000 USDC (smallest units) into Morpho on Ethereum. Transaction is executing now.”
You: What happened with that transaction?Claude calls
get_activities and reports:
“The earn transaction completed successfully. Your USDC is now earning 5.1% APY on Morpho.”
Reference data
You: What networks and assets does Legend support?Claude calls
list_networks and list_assets:
“Legend supports Base, Ethereum, Arbitrum, Optimism, Polygon, Unichain, World Chain, and HyperEVM. Available assets include USDC, USDT, WETH, cbBTC, wstETH, and more.”
Add a CLAUDE.md Snippet
Drop this into your project’sCLAUDE.md so Claude uses Legend tools effectively:
Tips
- Start with reads —
list_accounts,get_portfolio,list_networksdon’t need signing. Great for exploration. - Plans are free — creating a plan doesn’t commit to anything. It’s a preview.
- Plans expire — 2 minutes to sign and execute after creation.
- Use
plan_and_execute— one tool call instead of three separate steps (create, sign, execute). - Use
/mcpto debug — shows connection status, tools, and errors. - JSON output from CLI — the
--jsonflag on any CLI command outputs JSON that Claude can parse easily.