Skip to main content
Glama
aahl

AkTools MCP Server

by aahl

获取股票/加密货币相关新闻

stock_news

Fetch recent news for stocks or cryptocurrencies using their symbol. Get relevant financial updates to inform trading decisions.

Instructions

根据股票代码或加密货币符号获取近期相关新闻

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
symbolYes股票代码/加密货币符号
limitNo返回数量(int)

Implementation Reference

  • Tool registration via @mcp.tool decorator with title='获取股票/加密货币相关新闻' and description
    @mcp.tool(
        title="获取股票/加密货币相关新闻",
        description="根据股票代码或加密货币符号获取近期相关新闻",
    )
  • Main handler function that fetches stock news by symbol, deduplicates, and returns joined news strings up to limit
    def stock_news(
        symbol: str = Field(description="股票代码/加密货币符号"),
        limit: int = Field(15, description="返回数量(int)", strict=False),
    ):
        news = list(dict.fromkeys([
            v["新闻内容"]
            for v in ak_cache(stock_news_em, symbol=symbol, ttl=3600).to_dict(orient="records")
            if isinstance(v, dict)
        ]))
        if news:
            return "\n".join(news[0:limit])
        return f"Not Found for {symbol}"
  • Helper function that queries eastmoney.com search API for news articles about the given symbol, returns a DataFrame with sorted news content
    def stock_news_em(symbol, limit=20):
        cbk = "jQuery351013927587392975826_1763361926020"
        resp = requests.get(
            "http://search-api-web.eastmoney.com/search/jsonp",
            headers={
                "User-Agent": USER_AGENT,
                "Referer": f"https://so.eastmoney.com/news/s?keyword={symbol}",
            },
            params={
                "cb": cbk,
                "param": '{"uid":"",'
                         f'"keyword":"{symbol}",'
                         '"type":["cmsArticleWebOld"],"client":"web","clientType":"web","clientVersion":"curr",'
                         '"param":{"cmsArticleWebOld":{"searchScope":"default","sort":"default","pageIndex":1,"pageSize":10,'
                         '"preTag":"<em>","postTag":"</em>"}}}',
            },
        )
        text = resp.text.replace(cbk, "").strip().strip("()")
        data = json.loads(text) or {}
        dfs = pd.DataFrame(data.get("result", {}).get("cmsArticleWebOld") or [])
        dfs.sort_values("date", ascending=False, inplace=True)
        dfs = dfs.head(limit)
        dfs["新闻内容"] = dfs["content"].str.replace(r"</?em>", "", regex=True)
        return dfs
  • Caching utility ak_cache that wraps function calls with TTL-based disk and memory caching, used to cache stock_news_em results with ttl=3600
    def ak_cache(fun, *args, **kwargs) -> pd.DataFrame | None:
        key = kwargs.pop("key", None)
        if not key:
            key = f"{fun.__name__}-{args}-{kwargs}"
        ttl1 = kwargs.pop("ttl", 86400)
        ttl2 = kwargs.pop("ttl2", None)
        cache = CacheKey.init(key, ttl1, ttl2)
        all = cache.get()
        if all is None:
            try:
                _LOGGER.info("Request akshare: %s", [key, args, kwargs])
                all = fun(*args, **kwargs)
                cache.set(all)
            except Exception as exc:
                _LOGGER.exception(str(exc))
        return all
  • Input schema: symbol (str, stock/crypto code) and limit (int, default 15) via pydantic Field
        symbol: str = Field(description="股票代码/加密货币符号"),
        limit: int = Field(15, description="返回数量(int)", strict=False),
    ):
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are present, and the description lacks behavioral details such as data source, recency definition, pagination, or limitations. The description is too brief to compensate for the absence of annotations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single concise sentence, but it omits useful context that could be included without becoming verbose.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a news retrieval tool, the description does not specify return format, date range, language, or caching behavior. Given the lack of output schema, more detail is needed for complete understanding.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the baseline is 3. The description adds no additional meaning beyond the schema's property descriptions for 'symbol' and 'limit'.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool retrieves recent news for a stock or cryptocurrency symbol, but it does not differentiate from the sibling tool 'stock_news_global', which may have a different scope.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus any of the many sibling tools, such as 'stock_news_global' or 'trading_suggest'.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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/aahl/mcp-aktools'

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