get_news_data
Retrieve recent stock-related news data by specifying a stock symbol and the number of records needed. Use this tool to access timely updates for informed investment decisions.
Instructions
Get stock-related news data.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| recent_n | No | Number of most recent records to return | |
| symbol | Yes | Stock symbol/ticker (e.g. '000001') |
Implementation Reference
- src/akshare_one_mcp/server.py:170-182 (handler)The handler function for the 'get_news_data' MCP tool. It is decorated with @mcp.tool for registration, defines the input schema using Annotated and Field, fetches news data using the akshare_one library, limits to recent_n records if specified, and returns the data as JSON.@mcp.tool def get_news_data( symbol: Annotated[str, Field(description="Stock symbol/ticker (e.g. '000001')")], recent_n: Annotated[ int | None, Field(description="Number of most recent records to return", ge=1) ] = 10, ) -> str: """Get stock-related news data.""" df = ako.get_news_data(symbol=symbol, source="eastmoney") if recent_n is not None: df = df.tail(recent_n) return df.to_json(orient="records") or "[]"