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
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/desk3_service/server.py:110-119 (handler)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}")
- src/desk3_service/server.py:591-599 (registration)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": [], }, ),
- src/desk3_service/server.py:773-783 (handler)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}")
- src/desk3_service/server.py:594-598 (schema)JSON schema for tool inputs (empty, no parameters required).inputSchema={ "type": "object", "properties": {}, "required": [], },
- src/desk3_service/server.py:23-41 (helper)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