Skip to main content
Glama

MCP Yahoo Finance

by maxscheijen

get_earning_dates

Retrieve upcoming and historical earnings dates for a specific stock symbol directly from Yahoo Finance. Specify the stock symbol and adjust the limit to control the number of dates returned.

Instructions

Get earning dates.

Input Schema

NameRequiredDescriptionDefault
limitNomax amount of upcoming and recent earnings dates to return. Default value 12 should return next 4 quarters and last 8 quarters. Increase if more history is needed.
symbolYesStock symbol in Yahoo Finance format.

Input Schema (JSON Schema)

{ "properties": { "limit": { "description": "max amount of upcoming and recent earnings dates to return. Default value 12 should return next 4 quarters and last 8 quarters. Increase if more history is needed.", "type": "string" }, "symbol": { "description": "Stock symbol in Yahoo Finance format.", "type": "string" } }, "required": [ "symbol" ], "type": "object" }

Implementation Reference

  • Core handler function implementing the get_earning_dates tool. Fetches earnings dates using yfinance Ticker.get_earnings_dates, processes index to string dates if DataFrame, and returns JSON string.
    def get_earning_dates(self, symbol: str, limit: int = 12) -> str: """Get earning dates. Args: symbol (str): Stock symbol in Yahoo Finance format. limit (int): max amount of upcoming and recent earnings dates to return. Default value 12 should return next 4 quarters and last 8 quarters. Increase if more history is needed. """ stock = Ticker(ticker=symbol, session=self.session) earning_dates = stock.get_earnings_dates(limit=limit) if isinstance(earning_dates, pd.DataFrame): earning_dates.index = earning_dates.index.date.astype(str) # type: ignore return f"{earning_dates.to_json(indent=2)}" return f"{earning_dates}"
  • Registration of the get_earning_dates tool in the list_tools() handler using generate_tool to create the Tool object.
    generate_tool(yf.get_earning_dates),
  • Dispatch logic in call_tool() handler that invokes the get_earning_dates method with parsed arguments and returns the result as TextContent.
    case "get_earning_dates": price = yf.get_earning_dates(**args) return [TextContent(type="text", text=price)]
  • Helper function that generates the tool schema dynamically from the handler function's signature, type annotations, and docstring parameters.
    def generate_tool(func: Any) -> Tool: """Generates a tool schema from a Python function.""" signature = inspect.signature(func) docstring = inspect.getdoc(func) or "" param_descriptions = parse_docstring(docstring) schema = { "name": func.__name__, "description": docstring.split("Args:")[0].strip(), "inputSchema": { "type": "object", "properties": {}, }, } for param_name, param in signature.parameters.items(): param_type = ( "number" if param.annotation is float else "string" if param.annotation is str else "string" ) schema["inputSchema"]["properties"][param_name] = { "type": param_type, "description": param_descriptions.get(param_name, ""), } if "required" not in schema["inputSchema"]: schema["inputSchema"]["required"] = [param_name] else: if "=" not in str(param): schema["inputSchema"]["required"].append(param_name) return Tool(**schema)

Other Tools

Related Tools

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/maxscheijen/mcp-yahoo-finance'

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