This MCP server provides a comprehensive interface for accessing A-share (Chinese stock market) data through the Model Context Protocol. It offers various data querying capabilities including stock information, historical price data, financial indicators, and macroeconomic data.
To set up the A-share MCP server, follow these steps:
# 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
You'll need to configure this server in an MCP-compatible client (like VS Code, CherryStudio, etc.).
Add the following configuration to your MCP client's JSON 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:
uv
command is accessible or provide the absolute path to uv.exe
\\
in the pathIn CherryStudio's MCP server configuration interface:
a-share-mcp
(or custom name)Local A-share MCP Server
(or custom description)uv
(or absolute path to uv.exe)--directory
C:\\Users\\YourName\\Projects\\a_share_mcp
run
python
mcp_server.py
Tip: If the server doesn't start immediately, try navigating away from the MCP settings page and then back again.
The server provides a variety of tools organized in several categories:
get_historical_k_data
: Retrieve historical K-line dataget_stock_basic_info
: Get basic stock informationget_dividend_data
: Obtain dividend historyget_adjust_factor_data
: Get price adjustment factorsget_profit_data
: Retrieve profit statement dataget_operation_data
: Get operational metricsget_growth_data
: Access growth indicatorsget_balance_data
: Get balance sheet dataget_cash_flow_data
: Retrieve cash flow informationget_dupont_data
: Access DuPont analysis dataget_trade_dates
: Get trading datesget_all_stock
: List all stockssearch_stocks
: Search for stocks by keywordget_suspensions
: Get list of suspended stocksget_stock_industry
: Get stock industry classificationget_sz50_stocks
: Get SSE 50 Index constituentsget_hs300_stocks
: Get CSI 300 Index constituentsget_zz500_stocks
: Get CSI 500 Index constituentsget_index_constituents
: Get any index constituentslist_industries
: List all industriesget_industry_members
: Get stocks in a specific industryget_deposit_rate_data
: Get deposit interest ratesget_loan_rate_data
: Get loan interest ratesget_required_reserve_ratio_data
: Get required reserve ratiosget_money_supply_data_month
: Get monthly money supply dataget_money_supply_data_year
: Get yearly money supply dataget_latest_trading_date
: Get the latest trading dateis_trading_day
: Check if a date is a trading dayprevious_trading_day
: Get the previous trading daynext_trading_day
: Get the next trading daynormalize_stock_code
: Normalize stock code formatget_stock_analysis
: Get stock analysis reportMost tools support optional limit
and format
parameters for customizing output:
# Get CSI 300 index constituents in JSON format
get_index_constituents(index='hs300', format='json', limit=100)
# Search for stocks with code containing "600"
search_stocks(keyword='600', date='2025-01-10', limit=20)
# Get historical data for a stock in CSV format
get_historical_k_data(code='sh.600000', start_date='2024-01-01', end_date='2024-06-30', frequency='d', format='csv', limit=200)
# Get the previous trading day
previous_trading_day('2025-01-04')
# Normalize a stock code
normalize_stock_code('000001.SZ') # -> 'sz.000001'
Baostock data updates follow this schedule:
Daily Updates:
Weekly Updates:
Note that on trading days, data for the current day won't be available until after 17:30.
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.
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.
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"
}
}
}
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.
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.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.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