Skip to main content
Glama
24mlight

A-Share MCP Server

normalize_index_code

Convert common stock index codes to Baostock format for consistent data processing in China's A-share market analysis.

Instructions

Normalize common index codes to Baostock format.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYes

Implementation Reference

  • The main handler function for the 'normalize_index_code' tool. It is decorated with @app.tool() for MCP registration, logs the input, and delegates execution to the core logic via run_tool_with_handling for error handling.
    @app.tool()
    def normalize_index_code(code: str) -> str:
        """Normalize common index codes to Baostock format."""
        logger.info("Tool 'normalize_index_code' called with input=%s", code)
        return run_tool_with_handling(
            lambda: normalize_index_code_logic(code),
            context="normalize_index_code",
        )
  • Core helper function containing the exact normalization logic, mapping common index code strings to Baostock format codes (e.g., 'HS300' -> 'sh.000300') with validation.
    def normalize_index_code_logic(code: str) -> str:
        validate_non_empty_str(code, "code")
        raw = code.strip().upper()
        if raw in {"000300", "CSI300", "HS300"}:
            return "sh.000300"
        if raw in {"000016", "SSE50", "SZ50"}:
            return "sh.000016"
        if raw in {"000905", "ZZ500", "CSI500"}:
            return "sh.000905"
        raise ValueError("Unsupported index code. Examples: 000300/CSI300/HS300, 000016, 000905.")
  • mcp_server.py:58-58 (registration)
    Top-level registration call in the main MCP server setup that invokes register_helpers_tools(app), thereby registering the 'normalize_index_code' tool.
    register_helpers_tools(app)
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions normalization to 'Baostock format,' hinting at a transformation process, but doesn't specify whether this is a read-only operation, what errors might occur (e.g., invalid codes), or any performance traits like rate limits. This leaves significant gaps in understanding the tool's behavior.

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 a single, efficient sentence that front-loads the core purpose without unnecessary details. It's appropriately sized for a simple tool, with zero wasted words, making it easy to parse quickly.

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 tool's moderate complexity (normalization task with 1 parameter), no annotations, no output schema, and low schema coverage, the description is incomplete. It lacks details on input format, output format, error handling, and differentiation from siblings, making it insufficient for reliable agent use without additional context.

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?

The input schema has 1 parameter with 0% description coverage, and the description adds minimal semantic value by implying 'code' refers to 'common index codes' for normalization. However, it doesn't clarify the expected input format (e.g., examples like '000001.SH'), valid ranges, or how it differs from stock codes, failing to compensate for the low schema coverage.

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 states the tool's purpose as 'Normalize common index codes to Baostock format,' which provides a specific verb ('normalize') and resource ('common index codes'), but it's vague about what 'common index codes' entails and doesn't differentiate from the sibling tool 'normalize_stock_code' (which likely handles stock codes instead). It avoids tautology by not restating the name/title, but lacks specificity in 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?

The description offers no guidance on when to use this tool versus alternatives, such as the sibling 'normalize_stock_code' for stock codes or other data-fetching tools. There's no mention of prerequisites, context, or exclusions, leaving the agent with no usage direction beyond the implied purpose.

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