Skip to main content

MCP Tools

These tools are available via the Legend Prime MCP servers. Tools marked with (local only) are only available on the local MCP server (legend-cli mcp serve).

Reference Data

list_networks

List all supported blockchain networks. Parameters: None Returns: Array of {name, chain_id, display_name}. Use the name field (e.g. "base", "ethereum", "arbitrum") as the network parameter in other tools.

list_assets

List all supported tokens with decimals and network availability.
ParameterTypeRequiredDescription
networkstringNoFilter to assets available on this network
Returns: Map of symbol → {name, decimals, networks}. Common decimals: USDC/USDT = 6, ETH/WETH = 18.

Accounts

list_accounts

List all sub-accounts under your Prime Account. Parameters: None Returns: Array of accounts with account_id, signer_type, wallet addresses, created_at. Call this first to discover account IDs.

get_account_info

Get details for a specific account.
ParameterTypeRequiredDescription
account_idstringYesAccount ID (e.g. "acc_xxx")
Returns: Account details including account_id, signer_type, ethereum_signer_address, legend_wallet_address, solana_wallet_address.

Portfolio

get_portfolio

Get an account’s current balances, token prices, yield positions, and rewards.
ParameterTypeRequiredDescription
account_idstringYesAccount ID
Returns: Full folio data. Amounts use scientific notation:
  • "300.25e6" = 300.25 USDC (6 decimals)
  • "1.5e18" = 1.5 ETH (18 decimals)
Key folio sections:
  • balances — token amounts per network per wallet (balances/token/{network}/{symbol}/{wallet})
  • prices — USD token prices (prices/token/{symbol})
  • yield_markets — available yield with APY (yield_markets/{protocol}/{network}/{address}/{asset})
  • rewards — unclaimed protocol rewards
yield_market key mapping: The first path component maps to the plan protocol parameter: comet"compound", aave"aave", morpho_vault"morpho_vault". Use these exact values.

get_activities

Get recent transaction history.
ParameterTypeRequiredDescription
account_idstringYesAccount ID
limitintegerNoMax results (default 20, max 100)
Returns: Array of activities with status (pending, completed, failed), execution details, and transaction hashes.

Plans

Plans are free previews — nothing executes until you sign and call execute_plan. Plans expire after 2 minutes.

create_earn_plan

Create a plan to earn yield on an asset.
ParameterTypeRequiredDescription
account_idstringYesAccount ID
amountstringYesAmount in smallest unit ("1000000" = 1 USDC)
assetstringYesAsset symbol from yield_market key
networkstringYesNetwork from yield_market key
protocolstringYes"compound", "aave", or "morpho_vault"
Returns: plan_id, digest (for signing), expires_at, steps (action preview). Legend handles cross-chain bridging automatically — just specify the target network.

create_swap_plan

Create a plan to swap tokens.
ParameterTypeRequiredDescription
account_idstringYesAccount ID
sell_assetstringYesAsset to sell (e.g. "USDC")
buy_assetstringYesAsset to buy (e.g. "WETH")
networkstringYesNetwork for the swap
sell_amountstringNoAmount to sell (mutually exclusive with buy_amount)
buy_amountstringNoAmount to buy (mutually exclusive with sell_amount)
Returns: plan_id, digest, expires_at, steps.

Execution

execute_plan

Execute a previously created plan.
ParameterTypeRequiredDescription
account_idstringYesAccount ID
plan_idstringYesFrom a create_*_plan response
signaturestringYesEIP-712 signature (0x-prefixed hex)
Returns: plan_id, quark_intent_id, status.

How to Sign (remote MCP only)

When using the remote MCP server, the create_*_plan tools return a digest field. To get the signature: Using the CLI (Turnkey P256 accounts):
legend-cli sign 0xabc123...
# Output: 0xdef456...
Using viem (EOA accounts):
import { privateKeyToAccount } from "viem/accounts";
const signer = privateKeyToAccount(privateKey);
const signature = await signer.sign({ hash: digest });
Plans expire after 2 minutes. Create, sign, and execute promptly.

Local-Only Tools

These tools are only available on the local MCP server (legend-cli mcp serve). They leverage the P256 key stored on your machine.

login (local only)

Authenticate via Google SSO. Opens a browser, completes the OAuth flow, and saves a 30-day JWT to your profile. Parameters: None Returns: Confirmation with profile name.

create_account (local only)

Create a new sub-account with optional P256 key generation.
ParameterTypeRequiredDescription
keygenbooleanNoGenerate a P256 key and create a Turnkey account (default: true)
use_file_keybooleanNoUse file-based key instead of Secure Enclave (default: false)
signer_typestringNo"eoa" or "turnkey_p256" (when keygen is false)
ethereum_signerstringNoEthereum address (for EOA accounts)
Returns: Account details including account_id, signer_type, wallet addresses, and turnkey_sub_org_id. With keygen: true (the default), the tool generates a P256 key in Secure Enclave, creates a Turnkey-backed account, and saves the key reference to your profile — all in one step.

sign_digest (local only)

Sign an EIP-712 digest using the profile’s P256 key via Turnkey.
ParameterTypeRequiredDescription
digeststringYes0x-prefixed hex digest to sign
Returns: {signature: "0x..."} — the EIP-712 signature (132 hex chars).

plan_and_execute (local only)

Create a plan, sign it with the local P256 key, and execute — all in one tool call. This is the primary tool for agents that need to move funds.
ParameterTypeRequiredDescription
account_idstringYesAccount ID
actionstringYes"earn", "swap", "withdraw", "transfer", "borrow", or "repay"
amountstringVariesAmount in smallest unit
assetstringVariesAsset symbol
networkstringYesTarget network
protocolstringVariesProtocol (for earn/withdraw)
sell_assetstringVariesAsset to sell (for swap)
buy_assetstringVariesAsset to buy (for swap)
sell_amountstringVariesAmount to sell (for swap)
buy_amountstringVariesAmount to buy (for swap)
recipientstringVariesRecipient address (for transfer)
collateral_amountstringVariesCollateral amount (for borrow/repay)
collateral_assetstringVariesCollateral asset (for borrow/repay)
Returns: {plan_id, quark_intent_id, status, action} — the execution result. Example — earn yield:
{
  "account_id": "acc_xxx",
  "action": "earn",
  "amount": "1000000",
  "asset": "USDC",
  "network": "base",
  "protocol": "compound"
}
Example — swap:
{
  "account_id": "acc_xxx",
  "action": "swap",
  "sell_asset": "USDC",
  "buy_asset": "WETH",
  "sell_amount": "1000000",
  "network": "base"
}
plan_and_execute eliminates the three-step flow (create plan → sign digest → execute). The agent makes one tool call and gets back the execution result. This only works on the local MCP server because it needs access to the P256 key.

create_plan (local only)

Create a plan for any action type. Similar to the remote server’s create_earn_plan / create_swap_plan but unified into one tool.
ParameterTypeRequiredDescription
account_idstringYesAccount ID
actionstringYes"earn", "swap", "withdraw", "transfer", "borrow", or "repay"
Plus the same action-specific parameters as plan_and_execute. Returns: Full plan details including plan_id, digest, expires_at.