Skip to main content
Glama
16Coffee

Yahoo Finance MCP Server

by 16Coffee

get_stock_actions

Retrieve historical stock dividend and split data by providing a stock ticker. This tool extracts detailed corporate action records from Yahoo Finance for informed investment analysis.

Instructions

获取股票的分红与拆股历史。

参数说明: ticker: str 股票代码,例如 "AAPL"

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tickerYes

Implementation Reference

  • server.py:190-198 (registration)
    Tool registration using @fmp_server.tool decorator, specifying name and description with input schema implied.
    @fmp_server.tool( name="get_stock_actions", description="""获取股票的分红与拆股历史。 参数说明: ticker: str 股票代码,例如 "AAPL" """, )
  • The core handler function that retrieves historical stock dividends and splits from the Financial Modeling Prep API using requests and pandas, returning JSON data.
    async def get_stock_actions(ticker: str) -> str: """Get stock dividends and stock splits 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." base = "https://financialmodelingprep.com/api/v3" try: div_resp = requests.get( f"{base}/historical-price-full/stock_dividend/{ticker}", params={"apikey": api_key}, timeout=10, ) div_resp.raise_for_status() div_df = pd.DataFrame(div_resp.json().get("historical", [])) split_resp = requests.get( f"{base}/historical-price-full/stock_split/{ticker}", params={"apikey": api_key}, timeout=10, ) split_resp.raise_for_status() split_df = pd.DataFrame(split_resp.json().get("historical", [])) except Exception as e: return f"Error: getting stock actions for {ticker}: {e}" return json.dumps( { "dividends": div_df.to_dict("records"), "splits": split_df.to_dict("records"), } )

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/16Coffee/finance-mcp'

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