get_stock_price
Retrieve the current stock price for a specific ticker symbol using Yahoo Finance data integration. Input the stock ticker symbol to receive up-to-date pricing information.
Instructions
Get the current stock price using yfinance.
Args:
symbol: Stock ticker (e.g. AAPL, TSLA, MSFT)
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"symbol": "<symbol>"
},
"name": "get_stock_price"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| symbol | Yes |
Implementation Reference
- findata.py:31-46 (handler)The tool handler decorated with @mcp.tool(), which implements the get_stock_price logic using yfinance library. Includes input schema in docstring and type hints.
@mcp.tool() async def get_stock_price(symbol: str) -> str: """Get the current stock price using yfinance. Args: symbol: Stock ticker (e.g. AAPL, TSLA, MSFT) """ try: stock = yf.Ticker(symbol) info = stock.info price = info["currentPrice"] currency = info.get("currency", "USD") return f"{symbol.upper()} is trading at {price} {currency}." except Exception: return f"Could not retrieve stock price for {symbol}."