Skip to main content
Glama

get_stock_basic_info

Retrieve essential stock profile information for Chinese A/B/H shares including company details, market data, and financial metrics using stock symbols.

Instructions

获取指定股票的基本概要信息

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
symbolYes股票代码 (例如: '000001')
output_formatNo输出数据格式: json, csv, xml, excel, markdown, html。默认: markdownmarkdown

Implementation Reference

  • The complete handler function for the 'get_stock_basic_info' tool, including decorator, input schema via Annotated Fields, logic to fetch data from multiple sources with fallback mechanism, and output formatting.
    @mcp.tool(name="get_stock_basic_info", description="获取指定股票的基本概要信息") def get_stock_basic_info( symbol: Annotated[str, Field(description="股票代码 (例如: '000001')")], output_format: Annotated[ Literal["json", "csv", "xml", "excel", "markdown", "html"], Field(description="输出数据格式: json, csv, xml, excel, markdown, html。默认: markdown"), ] = "markdown" ) -> str: """获取股票基本概要信息,支持 A 股和港股""" # 定义内部 fetch_func def get_stock_basic_info_fetcher(source: str, **kwargs: Any) -> pd.DataFrame: if source == "eastmoney": df = ak.stock_individual_info_em(symbol) elif source == "xueqiu": df = ak.stock_individual_basic_info_xq(symbol) elif source == "cninfo": df = ak.stock_profile_cninfo(symbol) elif source == "xq": df = ak.stock_individual_basic_info_hk_xq(symbol) return df df = _fetch_data_with_fallback( fetch_func=get_stock_basic_info_fetcher, primary_source="cninfo", fallback_sources=[ "eastmoney", "xq", "xueqiu", ], symbol=symbol, ) if df.empty: df = pd.DataFrame() return _format_dataframe_output(df, output_format)
  • Input parameter schema definition for the tool using Pydantic Field and typing.Annotated, specifying symbol (stock code) and output_format (json/csv/etc.).
    symbol: Annotated[str, Field(description="股票代码 (例如: '000001')")], output_format: Annotated[ Literal["json", "csv", "xml", "excel", "markdown", "html"], Field(description="输出数据格式: json, csv, xml, excel, markdown, html。默认: markdown"), ] = "markdown"
  • MCP tool registration using the @mcp.tool decorator with name and description.
    @mcp.tool(name="get_stock_basic_info", description="获取指定股票的基本概要信息")
  • Inner helper fetcher function that retrieves stock basic information from different data sources (eastmoney, xueqiu, cninfo, xq) based on the source parameter.
    def get_stock_basic_info_fetcher(source: str, **kwargs: Any) -> pd.DataFrame: if source == "eastmoney": df = ak.stock_individual_info_em(symbol) elif source == "xueqiu": df = ak.stock_individual_basic_info_xq(symbol) elif source == "cninfo": df = ak.stock_profile_cninfo(symbol) elif source == "xq": df = ak.stock_individual_basic_info_hk_xq(symbol) return df

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/xinkuang/china-stock-mcp'

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