get_crypto_intraday
Fetch intraday cryptocurrency prices at customizable intervals (1min, 5min, 1hour) using Yahoo Finance data to monitor real-time market movements and trends.
Instructions
按时间间隔获取加密货币的分时价格,支持 1min、5min 和 1hour。
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| interval | No | 1min | |
| symbol | Yes |
Implementation Reference
- server.py:1215-1233 (handler)The handler function that implements the get_crypto_intraday tool by fetching intraday crypto price data from the Financial Modeling Prep API, validating the interval, and returning JSON data.async def get_crypto_intraday(symbol: str, interval: str = "1min") -> str: """获取加密货币的分时价格""" api_key = os.environ.get("FMP_API_KEY") if not api_key: return "Error: FMP_API_KEY environment variable not set." allowed = {"1min", "5min", "1hour"} if interval not in allowed: return "Error: invalid interval" url = f"https://financialmodelingprep.com/stable/historical-chart/{interval}" try: resp = requests.get(url, params={"symbol": symbol, "apikey": api_key}, timeout=10) resp.raise_for_status() data = resp.json() except Exception as e: return f"Error: getting {interval} crypto data for {symbol}: {e}" return json.dumps(data)
- server.py:1211-1214 (registration)The decorator that registers the get_crypto_intraday tool with the MCP server, including its name and description.@fmp_server.tool( name="get_crypto_intraday", description="""按时间间隔获取加密货币的分时价格,支持 1min、5min 和 1hour。""", )