Skip to main content
Glama
desk3
by desk3

get_fear_greed_index

Analyze market sentiment for crypto investments by retrieving the Fear and Greed Index, which provides real-time and historical data to inform trading decisions.

Instructions

Discover our Fear and Greed Index, a powerful tool that analyzes market sentiment to help you make informed crypto investment decisions. Stay ahead of market trends with real-time and historical data available through our easy-to-use API

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Core handler function implementing the get_fear_greed_index tool logic by calling the external API endpoint.
    async def get_fear_greed_index() -> dict[str, Any]:
        """
        Get crypto fear and greed index。
        :return: index
        """
        url = 'https://mcp.desk3.io/v1/market/fear-greed'
        try:
            return request_api('get', url)
        except Exception as e:
            raise RuntimeError(f"Failed to fetch fear & greed index: {e}")
  • Registration of the get_fear_greed_index tool in the list_tools handler, including schema (no input params required).
    types.Tool(
        name="get_fear_greed_index",
        description="Discover our Fear and Greed Index, a powerful tool that analyzes market sentiment to help you make informed crypto investment decisions. Stay ahead of market trends with real-time and historical data available through our easy-to-use API",
        inputSchema={
            "type": "object",
            "properties": {},
            "required": [],
        },
    ),
  • MCP tool call handler dispatch case that executes get_fear_greed_index and returns JSON response.
    case "get_fear_greed_index":
        try:
            data = await get_fear_greed_index()
            return [
                types.TextContent(
                    type="text",
                    text=json.dumps(data, indent=2),
                )
            ]
        except Exception as e:
            raise RuntimeError(f"Failed to fetch fear & greed index: {e}")
  • JSON schema for tool inputs (empty, no parameters required).
    inputSchema={
        "type": "object",
        "properties": {},
        "required": [],
    },
  • Helper function used by get_fear_greed_index to make authenticated API requests.
    def request_api(method: str, url: str, params: dict = None, data: dict = None) -> any:
        headers = {
            'Accepts': 'application/json',
            'X-DESK3_PRO_API_KEY': API_KEY,
        }
        try:
            logging.info(f"Requesting {method.upper()} {url} params={params} data={data}")
            if method.lower() == 'get':
                response = requests.get(url, headers=headers, params=params)
            elif method.lower() == 'post':
                response = requests.post(url, headers=headers, json=data)
            else:
                raise ValueError(f"Unsupported HTTP method: {method}")
            response.raise_for_status()
            logging.info(f"Response {response.status_code} for {url}")
            return json.loads(response.text)
        except Exception as e:
            logging.error(f"Error during {method.upper()} {url}: {e}")
            raise

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/desk3/cryptocurrency-mcp-server'

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