Skip to main content
Glama

get_historical_fng_tool

Retrieve historical Crypto Fear & Greed Index values for a specified number of days to analyze market sentiment trends and make informed investment decisions.

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' tool. It is registered via the @mcp.tool() decorator and implements the tool logic by calling the underlying resource function.
    @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-60 (helper)
    The helper resource function 'get_historical_fng' that performs the actual API call to fetch historical Fear & Greed Index data, invoked 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)}"
  • main.py:71-79 (schema)
    The docstring in the tool handler provides the input schema description (parameters: days int) and output description.
    """ 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. """

Other Tools

Related 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