get_stock_info
Retrieve company profiles and key financial metrics by providing a stock ticker, such as "AAPL", using the Yahoo Finance MCP Server.
Instructions
获取公司概况及关键财务指标。
参数说明: ticker: str 股票代码,例如 "AAPL"
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ticker | Yes |
Implementation Reference
- server.py:135-149 (handler)The main handler function that fetches the stock profile data from the Financial Modeling Prep API using the ticker symbol and returns it as JSON.async def get_stock_info(ticker: str) -> str: """Get stock information for a given ticker symbol""" api_key = os.environ.get("FMP_API_KEY") if not api_key: return "Error: FMP_API_KEY environment variable not set." url = f"https://financialmodelingprep.com/api/v3/profile/{ticker}" try: resp = requests.get(url, params={"apikey": api_key}, timeout=10) resp.raise_for_status() data = resp.json() except Exception as e: return f"Error: getting stock information for {ticker}: {e}" return json.dumps(data[0] if isinstance(data, list) and data else data)
- server.py:126-134 (registration)The decorator that registers the 'get_stock_info' tool with FastMCP, including the name and description with input schema details.@fmp_server.tool( name="get_stock_info", description="""获取公司概况及关键财务指标。 参数说明: ticker: str 股票代码,例如 "AAPL" """, )
- server.py:127-134 (schema)The tool description providing input schema: ticker as str.name="get_stock_info", description="""获取公司概况及关键财务指标。 参数说明: ticker: str 股票代码,例如 "AAPL" """, )