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
Setup instructions
Provider
24mlight
Release date
Apr 30, 2025
Language
Python
Stats
481 stars

The A-Share MCP server is a specialized Model Context Protocol (MCP) server focused on China's A-share market. It provides comprehensive data including stock information, historical K-line data, financial indicators, and macroeconomic data, designed to answer virtually any question about the Chinese stock market.

Installation

To set up and run the A-Share MCP server, follow these steps:

Prerequisites

  • Python 3.10 or higher
  • The uv package manager
  • No paid accounts required (uses Baostock data source)

Setup Process

# 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 Clients

Method 1: IDE with JSON Configuration (Cursor, VSCode, Trae)

Add this configuration to your IDE's MCP settings:

{
  "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 path
  • Use double backslashes (\\) for Windows paths
  • Ensure the uv command is accessible in your system

Method 2: CherryStudio Configuration

In CherryStudio's MCP server configuration interface:

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

Tip: If configuration doesn't activate immediately, navigate away from the settings page and then return to see the green indicator.

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 next day: Minute K-line data
  • 1:30 on the next day: Other financial report data
  • 17:30 on Saturdays: Weekly line data

Weekly updates:

  • Monday afternoons: SSE 50, CSI 300, CSI 500 constituent stock updates

Note that current trading day data is not available before 17:30.

Available Tools

The A-Share MCP server offers 40 specialized tools across four categories:

Stock Market Data

  • Get historical K-line data
  • Retrieve stock basic information
  • Access dividend data
  • Get adjustment factors

Financial Report Data

  • Profitability indicators
  • Operational capabilities
  • Growth metrics
  • Balance sheet data
  • Cash flow analysis
  • DuPont analysis
  • Performance express reports
  • Earnings forecasts

Market & Index Information

  • Trading calendar access
  • Market-wide security listings
  • Stock search functionality
  • Suspension information
  • Industry classifications
  • Index constituents (SSE 50, CSI 300, CSI 500)
  • Industry listings and members

Macroeconomic & Utility Tools

  • Interest rate data (deposits, loans)
  • Required reserve ratio
  • Money supply metrics
  • Trading date utilities
  • Market analysis timeframes
  • Code normalization
  • Stock analysis report generation

Each tool accepts parameters to customize the output format (markdown, JSON, CSV) and limit the number of results returned.

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

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

See the official Claude Code MCP documentation for more details.

For 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 > Tools & Integrations and click "New MCP Server".

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

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

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 explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

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

3. Restart Claude Desktop for the changes to take effect

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