get_current_fng_tool
Access real-time Crypto Fear & Greed Index data to analyze market sentiment and make informed decisions using this MCP server tool.
Instructions
Get the current Crypto Fear & Greed Index as a tool.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- main.py:62-66 (handler)The main handler function for the 'get_current_fng_tool' tool, decorated with @mcp.tool(). It logs info and delegates to the get_current_fng resource function.@mcp.tool() async def get_current_fng_tool(ctx: Context) -> str: """Get the current Crypto Fear & Greed Index as a tool.""" ctx.info("Fetching current Fear & Greed Index") return await get_current_fng()
- main.py:14-31 (helper)Helper resource function get_current_fng() that fetches the actual FNG data from the API, called by the tool handler.@mcp.resource("fng://current") async def get_current_fng() -> str: """Get the current Crypto Fear & Greed Index""" try: async with httpx.AsyncClient() as client: response = await client.get(API_URL, params={"limit": 1}) response.raise_for_status() data = response.json()["data"][0] timestamp = datetime.fromtimestamp(int(data["timestamp"])) return ( f"Crypto Fear & Greed Index (as of {timestamp} UTC):\n" f"Value: {data['value']}\n" f"Classification: {data['value_classification']}" ) except httpx.HTTPStatusError as e: return f"Error fetching current FNG: {str(e)}" except Exception as e: return f"Unexpected error: {str(e)}"