get_stablecoin_charts_by_chain
Retrieve historical market capitalization charts for stablecoins on specific blockchain networks to analyze stablecoin adoption and trends over time.
Instructions
GET /stablecoins/stablecoincharts/{chain}
Get historical mcap sum of all stablecoins in a chain.
Parameters:
chain: chain slug (e.g., 'Ethereum')
stablecoin: stablecoin ID (optional)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| chain | Yes | ||
| stablecoin | No |
Implementation Reference
- defillama_server.py:180-194 (handler)The handler function decorated with @mcp.tool() registers and implements the tool. It constructs parameters if stablecoin is provided and calls the shared make_request helper to fetch data from DefiLlama's /stablecoins/stablecoincharts/{chain} endpoint, returning the JSON response as a string.@mcp.tool() async def get_stablecoin_charts_by_chain(chain: str, stablecoin: Optional[int] = None) -> str: """GET /stablecoins/stablecoincharts/{chain} Get historical mcap sum of all stablecoins in a chain. Parameters: chain: chain slug (e.g., 'Ethereum') stablecoin: stablecoin ID (optional) """ params = {} if stablecoin is not None: params['stablecoin'] = stablecoin result = await make_request('GET', f'/stablecoins/stablecoincharts/{chain}', params) return str(result)
- defillama_server.py:30-38 (helper)Shared helper function used by all tools, including get_stablecoin_charts_by_chain, to make HTTP requests to the DefiLlama API using httpx.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)}"