Skip to main content
Glama
kukapay

crypto-feargreed-mcp

get_historical_fng_tool

Retrieve historical Crypto Fear & Greed Index data for analysis of market sentiment trends over a specified number of days.

Instructions

Get historical Fear & Greed Index for specified number of days as a tool.

Parameters: days (int): Number of days to retrieve (must be a positive integer).

Returns: str: Historical Fear & Greed Index values for the specified period.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
daysYes

Implementation Reference

  • main.py:69-82 (handler)
    The handler function for the 'get_historical_fng_tool' MCP tool. It is registered via @mcp.tool() decorator, includes input schema in docstring and type hints, logs the request, and delegates to the core get_historical_fng helper.
    @mcp.tool()
    async def get_historical_fng_tool(days: int, ctx: Context) -> str:
        """
        Get historical Fear & Greed Index for specified number of days as a tool.
    
        Parameters:
            days (int): Number of days to retrieve (must be a positive integer).
    
        Returns:
            str: Historical Fear & Greed Index values for the specified period.
        """
        ctx.info(f"Fetching historical Fear & Greed Index for {days} days")
        return await get_historical_fng(str(days))
  • main.py:34-59 (helper)
    The core helper function that fetches historical Crypto Fear & Greed Index data from the API endpoint and formats the response. Called by the tool handler.
    @mcp.resource("fng://history/{days}")
    async def get_historical_fng(days: str) -> str:
        """Get historical Crypto Fear & Greed Index for specified number of days"""
        try:
            days_int = int(days)
            if days_int <= 0:
                raise ValueError("Days must be a positive integer")
            
            async with httpx.AsyncClient() as client:
                response = await client.get(API_URL, params={"limit": days_int})
                response.raise_for_status()
                data = response.json()["data"]
                
                result = ["Historical Crypto Fear & Greed Index:"]
                for entry in reversed(data):  # Latest first
                    timestamp = datetime.fromtimestamp(int(entry["timestamp"]))
                    result.append(
                        f"{timestamp} UTC: {entry['value']} ({entry['value_classification']})"
                    )
                return "\n".join(result)
        except ValueError as e:
            return f"Error: {str(e)}"
        except httpx.HTTPStatusError as e:
            return f"Error fetching historical FNG: {str(e)}"
        except Exception as e:
            return f"Unexpected error: {str(e)}"

Tool Definition Quality

Score is being calculated. Check back soon.

Install Server

Other 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/crypto-feargreed-mcp'

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