get_protocol_tvl
Retrieve the current Total Value Locked (TVL) for any DeFi protocol using its slug identifier. This tool provides real-time TVL data from DeFiLlama Pro to analyze protocol performance and market position.
Instructions
GET /api/tvl/{protocol}
Simplified endpoint to get current TVL of a protocol.
Parameters:
protocol: protocol slug (e.g., 'uniswap')
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| protocol | Yes |
Implementation Reference
- defillama_server.py:115-125 (handler)The handler function for the 'get_protocol_tvl' tool. It is automatically registered as an MCP tool via the @mcp.tool() decorator. The function signature and docstring define the input schema (protocol: str) and output (str representing JSON response). It fetches the current TVL from DefiLlama API using the make_request helper.@mcp.tool() async def get_protocol_tvl(protocol: str) -> str: """GET /api/tvl/{protocol} Simplified endpoint to get current TVL of a protocol. Parameters: protocol: protocol slug (e.g., 'uniswap') """ result = await make_request('GET', f'/api/tvl/{protocol}') return str(result)
- defillama_server.py:30-38 (helper)Helper function used by get_protocol_tvl (and other tools) to make HTTP requests to the DefiLlama Pro API, handling errors and returning JSON or error string.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:115-115 (registration)The @mcp.tool() decorator registers the get_protocol_tvl function as an MCP tool.@mcp.tool()