A-Share Financial Data (Baostock) MCP server

Provides financial data tools for Chinese stock market analysis through the Baostock API, enabling retrieval of historical prices, financial reports, industry classifications, index constituents, and macroeconomic indicators.
Back to servers
Provider
24mlight
Release date
Apr 30, 2025
Language
Python
Stats
171 stars

The A-Share MCP Server is a specialized tool for the Chinese A-share stock market, providing comprehensive data access including stock information, historical price data, financial indicators, and macroeconomic data through the Model Context Protocol (MCP).

Installation

To set up the A-Share MCP Server on your system:

# 1. Create a virtual environment
uv venv

# 2. Activate the virtual environment
# On Windows
.venv\Scripts\activate
# On macOS/Linux
# source .venv/bin/activate

# 3. Install all dependencies
uv sync

Configuring MCP in Your Client

Method 1: JSON Configuration (Cursor, VSCode, Trae, etc.)

Add the following to your MCP servers configuration:

{
  "mcpServers": {
    "a-share-mcp": {
      "command": "uv",
      "args": [
        "--directory",
        "C:\\Users\\YourName\\Projects\\a_share_mcp", 
        "run",
        "python",
        "mcp_server.py"
      ],
      "transport": "stdio"
    }
  }
}

Important Notes:

  • Replace the directory path with your actual project location
  • Use double backslashes for Windows paths
  • Ensure the uv command is accessible in your system PATH

Method 2: CherryStudio Configuration

In the CherryStudio MCP server interface:

  • Name: a-share-mcp (or custom name)
  • Description: Local A-Share MCP Server (or custom description)
  • Type: Select Standard Input/Output (stdio)
  • Command: uv (or full path to uv.exe)
  • Parameters: Add each parameter on a separate line:
    1. --directory
    2. C:\\Users\\YourName\\Projects\\a_share_mcp
    3. run
    4. python
    5. mcp_server.py

Troubleshooting: If the server doesn't activate immediately, try navigating away from the MCP settings and then back again.

Data Update Schedule

Baostock data updates follow this schedule:

  • Daily updates:

    • 17:30 on trading days: Daily K-line data
    • 18:00 on trading days: Adjustment factor data
    • 11:00 on the following day: Minute K-line data
    • 1:30 on the following day: "Other financial report data"
    • 17:30 on Saturdays: Weekly data
  • Weekly updates:

    • Monday afternoons: SSE 50, CSI 300, CSI 500 component stocks

Note that current trading day data won't be available until after 17:30.

Available Tools

The A-Share MCP Server provides numerous tools organized into categories:

Stock Market Data

  • get_historical_k_data: Historical price data
  • get_stock_basic_info: Basic stock information
  • get_dividend_data: Dividend history
  • get_adjust_factor_data: Adjustment factors

Financial Statement Data

  • get_profit_data: Profit statements
  • get_operation_data: Operation metrics
  • get_growth_data: Growth indicators
  • get_balance_data: Balance sheet information
  • get_cash_flow_data: Cash flow data
  • get_dupont_data: DuPont analysis data

Market Overview

  • get_trade_dates: Trading calendar information
  • get_all_stock: Complete stock listings

Index Related Data

  • get_stock_industry: Industry classifications
  • get_sz50_stocks: SSE 50 components
  • get_hs300_stocks: CSI 300 components
  • get_zz500_stocks: CSI 500 components

Macroeconomic Data

  • get_deposit_rate_data: Deposit rates
  • get_loan_rate_data: Loan rates
  • get_required_reserve_ratio_data: RRR data
  • get_money_supply_data_month: Monthly money supply
  • get_money_supply_data_year: Annual money supply
  • get_shibor_data: SHIBOR rates

Date & Analysis Tools

  • get_latest_trading_date: Latest market day
  • get_stock_analysis: Stock analysis metrics

How to add this MCP server to Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "cursor-rules-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "cursor-rules-mcp"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later