get_ma_data
Retrieve mergers and acquisitions data from Yahoo Finance. Specify action type, company name, page number, and results limit to search or fetch the latest updates.
Instructions
获取并购相关数据。
参数说明: action_type: str latest 或 search name: str 搜索模式下的公司名称 page: int 页码,默认 0 limit: int 返回数量,默认 100
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| action_type | Yes | ||
| limit | No | ||
| name | No | ||
| page | No |
Implementation Reference
- server.py:409-443 (handler)The asynchronous handler function that executes the get_ma_data tool. It fetches mergers and acquisitions data from the Financial Modeling Prep API, supporting 'latest' or 'search' by company name, with pagination.async def get_ma_data( action_type: str, name: str = "", page: int = 0, limit: int = 100, ) -> str: """获取并购信息""" 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/stable" endpoint_map = { "latest": "mergers-acquisitions-latest", "search": "mergers-acquisitions-search", } endpoint = endpoint_map.get(action_type.lower()) if not endpoint: return "Error: invalid action type" params = {"apikey": api_key, "page": page, "limit": limit} if action_type == "search": if not name: return "Error: name is required for search" params["name"] = name url = f"{base}/{endpoint}" try: resp = requests.get(url, params=params, timeout=10) resp.raise_for_status() data = resp.json() except Exception as e: return f"Error: getting M&A data {action_type}: {e}" return json.dumps(data)
- server.py:395-408 (registration)Registers the get_ma_data tool with the FastMCP server using the @fmp_server.tool decorator, specifying the name and a description that outlines the input parameters.@fmp_server.tool( name="get_ma_data", description="""获取并购相关数据。 参数说明: action_type: str latest 或 search name: str 搜索模式下的公司名称 page: int 页码,默认 0 limit: int 返回数量,默认 100""", )
- server.py:409-413 (schema)Type annotations defining the input schema (action_type: str required, name/page/limit optional with defaults) and output as str (JSON).async def get_ma_data( action_type: str, name: str = "", page: int = 0, limit: int = 100,