home / mcp / mcp baostock server

MCP BaoStock Server

Provides BaoStock-based stock data via MCP endpoints for stock basics, K-lines, industries, dividends, quarterly metrics, indices, and valuations.

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "huggingagi-mcp-baostock-server": {
      "command": "uv",
      "args": [
        "run",
        "mcp-baostock-server"
      ]
    }
  }
}

You can run the MCP BaoStock Server to access BaoStock-based stock market data through a consistent MCP interface. This server exposes endpoints for basic stock info, historical K-line data, industry classifications, dividends, quarterly financial indicators, index data, and valuation metrics, making it easy to query and integrate market data into your applications.

How to use

Connect to the MCP BaoStock Server using your MCP client to access multiple stock data endpoints. You can retrieve stock basics, historical K-lines, industry classifications, dividend information, quarterly profitability and operating metrics, growth indicators, index data, and valuation metrics. Use the client to request data for any supported symbol (for example, sh.600519 for Kweichow Moutai or sz.000001 for Ping An Bank) and specify the data you need (date ranges, data types, and aggregation as needed). Ensure you handle responses and potential errors (network issues, missing data, or rate limits) in your application.

Typical use patterns include: fetching daily or period-based K-line history for a given symbol, querying the latest basic stock information, or pulling quarterly indicators to analyze profitability, operating efficiency, or growth trends. Integrate the responses into dashboards, analytics modules, or trading tools to enrich your market insights.

How to install

Prerequisites you need before starting the server:

- Python 3.10+

- baostock

- pandas

Step 1: Install dependencies

pip install baostock pandas

Step 2: Start the MCP BaoStock Server

uv run mcp-baostock-server

Additional notes

You will use MCP client tooling to interact with the server. The server exposes a range of endpoints for stock basics, K-line data, industry classifications, dividends, quarterly profitability, quarterly operating metrics, quarterly growth indicators, index data, and valuation metrics. Ensure your client handles input validation, date ranges, symbol formats, and potential data gaps.

Examples of data endpoints

Key data you can query includes basic stock information, daily K-lines for a date range, industry classifications for a stock, dividend details for a year, quarterly profitability indicators (net profit, gross margin, etc.), quarterly operating metrics (receivables turnover, inventory turnover, etc.), quarterly growth metrics (revenue growth rate, net profit growth rate), index data for major indices, and valuation metrics (P/E, P/B, etc.).

Tools and capabilities

The server provides a set of endpoints to access the following capabilities:

                    Security and access

                    Ensure you implement appropriate access controls and handle data securely in your application. Validate inputs, manage API rate limits, and gracefully handle missing or incomplete data.

                    Available tools

                    getStockInfo

                    Fetches basic stock information including listing date and industry classifications for a given symbol.

                    getKLines

                    Returns historical daily K-line data for a symbol within a specified date range, with options for pre-adjusted data.

                    getIndustry

                    Retrieves industry classification information for a given stock symbol.

                    getDividend

                    Provides dividend payout details for a specified year or period.

                    getProfitability

                    Obtains quarterly profitability indicators such as net profit and gross margin.

                    getOperation

                    Provides quarterly operating metrics, including turnover-related indicators.

                    getGrowth

                    Gives quarterly growth indicators like revenue growth and net profit growth.

                    getIndexData

                    Fetches index data for major indices over a date range.

                    getValuation

                    Returns valuation metrics such as P/E and P/B over time.