Skip to main content
Glama

get_yield_pools

Retrieve DeFi yield pool data from yields.llama.fi, including symbol, project, TVL, APY, and predictions. Optionally filter results by chain or project for focused insights.

Instructions

Fetch DeFi yield pools from the yields.llama.fi API, optionally filtering by chain or project. Returns symbol, project, tvlUsd, apy, apyMean30d, and predictions for each pool. Args: chain: Optional filter for blockchain (e.g., 'Ethereum', 'Solana') project: Optional filter for project name (e.g., 'lido', 'aave-v3')

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
chainNo
projectNo

Implementation Reference

  • The @mcp.tool()-decorated handler function that implements the get_yield_pools tool. Fetches data from https://yields.llama.fi/pools, extracts and filters pools by chain and project, formats the output with key fields like chain, pool (symbol), project, tvlUsd, apy, apyMean30d, predictions, and handles errors using the provided Context.
    @mcp.tool() async def get_yield_pools(chain: str = None, project: str = None, ctx: Context = None) -> List[Dict[str, Any]]: """ Fetch DeFi yield pools from the yields.llama.fi API, optionally filtering by chain or project. Returns symbol, project, tvlUsd, apy, apyMean30d, and predictions for each pool. Args: chain: Optional filter for blockchain (e.g., 'Ethereum', 'Solana') project: Optional filter for project name (e.g., 'lido', 'aave-v3') """ async with httpx.AsyncClient() as client: try: ctx.info("Fetching yield pools from yields.llama.fi") response = await client.get("https://yields.llama.fi/pools") response.raise_for_status() data = response.json() if data.get("status") != "success": raise ValueError("API returned non-success status") pools = data.get("data", []) filtered_pools = [] for pool in pools: # Extract required fields yield_pool = { "chain": pool.get("chain", ""), "pool": pool.get("symbol", ""), "project": pool.get("project", ""), "tvlUsd": pool.get("tvlUsd", 0.0), "apy": pool.get("apy", 0.0), "apyMean30d": pool.get("apyMean30d", 0.0), "predictions": pool.get("predictions", {}) } # Apply filters if chain and pool.get("chain", "").lower() != chain.lower(): continue if project and yield_pool["project"].lower() != project.lower(): continue filtered_pools.append(yield_pool) ctx.info(f"Returning {len(filtered_pools)} yield pools") return filtered_pools except Exception as e: ctx.error(f"Error fetching yield pools: {str(e)}") raise
  • The @mcp.tool() decorator registers the get_yield_pools function as an MCP tool.
    @mcp.tool()
  • Function signature defines input parameters (chain, project optional strings; ctx Context) and output type (List[Dict[str, Any]]). Docstring provides detailed parameter descriptions and return info.
    async def get_yield_pools(chain: str = None, project: str = None, ctx: Context = None) -> List[Dict[str, Any]]:

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/kukapay/defi-yields-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server