get_chains
Retrieve current total value locked (TVL) data for all blockchain networks to analyze DeFi ecosystem metrics and chain performance.
Instructions
GET /api/v2/chains
Get current TVL of all chains.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- defillama_server.py:127-134 (handler)The handler function for the 'get_chains' MCP tool. It is decorated with @mcp.tool() for automatic registration and schema generation. Fetches the current TVL of all chains from the DefiLlama API using the shared make_request helper.@mcp.tool() async def get_chains() -> str: """GET /api/v2/chains Get current TVL of all chains. """ result = await make_request('GET', '/api/v2/chains') return str(result)
- defillama_server.py:30-37 (helper)Shared helper function used by get_chains (and all other tools) to make HTTP requests to the DefiLlama API.async def make_request(method: str, endpoint: str, params: Optional[Dict[str, Any]] = None) -> Any: """Make a request to the DefiLlama API.""" try: response = await client.request(method, endpoint, params=params) response.raise_for_status() return response.json() except Exception as e: return f"Error: {str(e)}"
- defillama_server.py:127-127 (registration)The @mcp.tool() decorator registers the get_chains function as an MCP tool with the name derived from the function name.@mcp.tool()