Skip to main content
Glama
24mlight

A Share MCP

get_profit_data

Retrieve quarterly profitability data for A-share stocks to analyze financial performance and track earnings trends over specific periods.

Instructions

Quarterly profitability data.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYes
yearYes
quarterYes
limitNo
formatNomarkdown

Implementation Reference

  • MCP tool handler for 'get_profit_data'. Decorated with @app.tool(), it invokes the use case via run_tool_with_handling for caching/error handling.
    @app.tool()
    def get_profit_data(code: str, year: str, quarter: int, limit: int = 250, format: str = "markdown") -> str:
        """Quarterly profitability data."""
        return run_tool_with_handling(
            lambda: fetch_profit_data(active_data_source, code=code, year=year, quarter=quarter, limit=limit, format=format),
            context=f"get_profit_data:{code}:{year}Q{quarter}",
        )
  • mcp_server.py:51-58 (registration)
    Main server file where register_financial_report_tools is called to register the financial reports tools, including 'get_profit_data'.
    register_stock_market_tools(app, active_data_source)
    register_financial_report_tools(app, active_data_source)
    register_index_tools(app, active_data_source)
    register_market_overview_tools(app, active_data_source)
    register_macroeconomic_tools(app, active_data_source)
    register_date_utils_tools(app, active_data_source)
    register_analysis_tools(app, active_data_source)
    register_helpers_tools(app)
  • Use case implementation: input validation, data fetching from datasource, and output formatting.
    def fetch_profit_data(data_source: FinancialDataSource, *, code: str, year: str, quarter: int, limit: int, format: str) -> str:
        validate_year(year)
        validate_quarter(quarter)
        validate_output_format(format)
        df = data_source.get_profit_data(code=code, year=year, quarter=quarter)
        return _format_financial_df(df, code=code, year=year, quarter=quarter, dataset="Profitability", format=format, limit=limit)
  • Concrete data source method implementing get_profit_data by calling Baostock API via shared helper.
    def get_profit_data(self, code: str, year: str, quarter: int) -> pd.DataFrame:
        """Fetches quarterly profitability data using Baostock."""
        return _fetch_financial_data(bs.query_profit_data, "Profitability", code, year, quarter)
  • Shared helper function in data source for fetching financial data from Baostock, handling login, errors, and DataFrame construction.
    def _fetch_financial_data(
        bs_query_func,
        data_type_name: str,
        code: str,
        year: str,
        quarter: int
    ) -> pd.DataFrame:
        logger.info(
            f"Fetching {data_type_name} data for {code}, year={year}, quarter={quarter}")
        try:
            with baostock_login_context():
                # Assuming all these functions take code, year, quarter
                rs = bs_query_func(code=code, year=year, quarter=quarter)
    
                if rs.error_code != '0':
                    logger.error(
                        f"Baostock API error ({data_type_name}) for {code}: {rs.error_msg} (code: {rs.error_code})")
                    if "no record found" in rs.error_msg.lower() or rs.error_code == '10002':
                        raise NoDataFoundError(
                            f"No {data_type_name} data found for {code}, {year}Q{quarter}. Baostock msg: {rs.error_msg}")
                    else:
                        raise DataSourceError(
                            f"Baostock API error fetching {data_type_name} data: {rs.error_msg} (code: {rs.error_code})")
    
                data_list = []
                while rs.next():
                    data_list.append(rs.get_row_data())
    
                if not data_list:
                    logger.warning(
                        f"No {data_type_name} data found for {code}, {year}Q{quarter} (empty result set from Baostock).")
                    raise NoDataFoundError(
                        f"No {data_type_name} data found for {code}, {year}Q{quarter} (empty result set).")
    
                result_df = pd.DataFrame(data_list, columns=rs.fields)
                logger.info(
                    f"Retrieved {len(result_df)} {data_type_name} records for {code}, {year}Q{quarter}.")
                return result_df
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions 'Quarterly profitability data' but doesn't describe how the data is retrieved (e.g., from a database, API), any rate limits, authentication needs, or what the output looks like (e.g., format, structure). This leaves significant gaps in understanding the tool's behavior beyond its basic purpose.

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

Conciseness5/5

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

The description is extremely concise with a single phrase 'Quarterly profitability data', which is front-loaded and wastes no words. However, this conciseness comes at the cost of completeness, as it omits necessary details for effective tool use.

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?

Given the complexity (5 parameters, 0% schema coverage, no annotations, no output schema), the description is incomplete. It doesn't explain parameter meanings, behavioral traits, or output format, making it inadequate for an AI agent to reliably invoke the tool. Sibling tools suggest a financial data context, but the description doesn't leverage this for clarity.

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

Parameters2/5

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

Schema description coverage is 0%, so the description must compensate for undocumented parameters. It adds no meaning beyond the schema, failing to explain what 'code', 'year', 'quarter', 'limit', or 'format' represent (e.g., stock code, fiscal year, quarter number, result limit, output format). With 5 parameters and no schema descriptions, this is a major gap.

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

Purpose3/5

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

The description 'Quarterly profitability data' states what the tool provides (profitability data) and its temporal scope (quarterly), which is clear but vague. It uses a noun phrase rather than an action verb, and while it distinguishes from siblings like 'get_balance_data' or 'get_cash_flow_data' by focusing on profitability, it doesn't specify how it retrieves or processes this data (e.g., fetching, calculating).

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?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites, context for selecting it over similar tools (e.g., 'get_fina_indicator' or 'get_performance_express_report'), or any exclusions. Usage is implied by the name and description alone, with no explicit instructions.

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/24mlight/a_share_mcp_is_just_I_need'

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