全球财经快讯
stock_news_globalGet current global financial news and market updates for informed investment decisions.
Instructions
获取最新的全球财经快讯
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- mcp_aktools/__init__.py:319-333 (handler)The main handler for the stock_news_global tool. Fetches global financial news via akshare's stock_info_global_sina() and supplements with newsnow_news() helper.
@mcp.tool( title="全球财经快讯", description="获取最新的全球财经快讯", ) def stock_news_global(): news = [] try: dfs = ak.stock_info_global_sina() csv = dfs.to_csv(index=False, float_format="%.2f").strip() csv = csv.replace(datetime.now().strftime("%Y-%m-%d "), "") news.extend(csv.split("\n")) except Exception: pass news.extend(newsnow_news()) return "\n".join(news) - mcp_aktools/__init__.py:319-322 (registration)Tool registration via FastMCP decorator with title '全球财经快讯'.
@mcp.tool( title="全球财经快讯", description="获取最新的全球财经快讯", ) - mcp_aktools/__init__.py:336-365 (helper)Helper function called by stock_news_global to fetch news from configurable NewsNow sources (wallstreetcn, cls-telegraph, jin10 via environment variables).
def newsnow_news(channels=None): base = os.getenv("NEWSNOW_BASE_URL") if not base: return [] if not channels: channels = os.getenv("NEWSNOW_CHANNELS") or "wallstreetcn-quick,cls-telegraph,jin10" if isinstance(channels, str): channels = channels.split(",") all = [] try: res = requests.post( f"{base}/api/s/entire", json={"sources": channels}, headers={ "User-Agent": USER_AGENT, "Referer": base, }, timeout=60, ) lst = res.json() or [] for item in lst: for v in item.get("items", [])[0:15]: title = v.get("title", "") extra = v.get("extra") or {} hover = extra.get("hover") or title info = extra.get("info") or "" all.append(f"{hover} {info}".strip().replace("\n", " ")) except Exception: pass return all