ashare-mcp
The ashare-mcp server provides comprehensive Chinese A-share market data via baostock and EastMoney APIs, exposing 25+ tools across these categories:
Market Data
Retrieve basic stock profiles, list all securities with trading status, query the trading calendar, and fetch historical K-line (OHLCV) data at daily, weekly, monthly, or minute frequencies with optional price adjustment.
Dividend & Price Adjustment
Access dividend/rights-issue records and forward/backward price adjustment factors for specific stocks.
Quarterly Financial Statements
Profitability (ROE, net margin, EPS), operating efficiency (turnover ratios), growth metrics (YOY equity/asset/net income), balance sheet ratios (current ratio, debt-to-asset), cash flow ratios, and DuPont decomposition analysis.
Earnings Reports
Retrieve performance express reports (业绩快报) and earnings forecast/pre-announcements (业绩预告) for a stock within a date range.
Industry & Index Constituents
Get Shenwan industry classifications and list constituents of major indices: SSE 50, CSI 300, and CSI 500 on specific dates.
Macro Indicators
Benchmark deposit/loan rates, required reserve ratio history, and monthly/yearly M0/M1/M2 money supply data.
Corporate Disclosure Announcements (EastMoney)
List a stock's announcements filterable by date range or keyword, and download the full PDF of any announcement. This works outside mainland China.
Utility
get_current_timereturns the current server time, useful for constructing relative date ranges.
English | 简体中文
ashare-mcp
An MCP server built on baostock that exposes all 23 baostock data endpoints as MCP tools: K-line, quarterly financials (profit / operation / growth / balance / cash-flow / DuPont), performance express & forecast reports, dividends, adjust factors, industry classification, index constituents, the trading calendar, and macro series.
It also ships two disclosure-announcement (公告) tools backed by EastMoney's public HTTP APIs — list announcements for a stock and download the PDF — since baostock has no announcement surface. EastMoney's endpoints are reachable outside mainland China, so these work even when baostock's data port is blocked.
The data layer sits behind a DataProvider abstraction. v1 ships the
baostock backend, with the seam in place to add other sources later without
touching the tool layer. The announcement tools live alongside the provider
(they don't go through baostock at all).
Install
uv syncRelated MCP server: sfc-data-mcp
Run (stdio)
uv run ashare-mcpConfigure it in a stdio MCP client (Claude Desktop / Claude Code / Cursor):
{
"mcpServers": {
"ashare": {
"command": "uv",
"args": ["--directory", "/path/to/ashare-mcp", "run", "ashare-mcp"]
}
}
}Tools
Category | Tools |
Market |
|
Dividend / adjust |
|
Quarterly financials |
|
Reports |
|
Industry / constituents |
|
Macro |
|
Disclosure (EastMoney) |
|
Utility |
|
Every baostock-backed data tool returns a uniform shape:
{"count": int, "fields": [...], "data": [{...}, ...]}. The announcement
tools return their own shape (see below).
Disclosure announcements (公告)
Two EastMoney-backed tools, independent of baostock:
get_stock_announcements(code, start_date="", end_date="", page_size=50, keyword="")— list a stock's announcements newest-first.codeacceptssh.600519/sz.002049/600519.start_date/end_dateare inclusiveYYYY-MM-DDfilters.keywordis a case-sensitive substring on the title (e.g.重组). Returns{code, count, data:[{art_code, title, notice_date, type, pdf_url_guess}]}.download_stock_announcement(art_code, save_dir="")— download the announcement PDF by theart_codereturned above. Resolves the real attachment URL via EastMoney's content API (falls back to theH2_<art_code>_1.pdfconvention if needed). Returns{art_code, title, save_dir, files:[{path, url, bytes}]}— open the returnedpathwith the MCP client's file/Read tool to read the PDF.
Typical flow: call get_stock_announcements → pick an art_code →
download_stock_announcement → read the saved PDF.
Codes
Pass baostock-form codes: sh.600519, sz.000001, bj.430047. Bare 6-digit
codes (e.g. 600519) are normalized best-effort, but ambiguous index codes
(e.g. 000001 is both SSE Composite sh.000001 and Ping An Bank sz.000001)
should be passed with an explicit prefix.
Configuration
Env var | Default | Meaning |
|
| Data backend. Only |
|
| Where |
Development
uv run pytest -q # unit tests (no network)
uv run pytest -q -m network # live baostock smoke testNotes
baostock's data port must be reachable from your network (reachable inside mainland China; may time out elsewhere). If baostock tools start timing out, check this first. The EastMoney announcement tools use a separate HTTPS endpoint and are typically reachable outside CN.
baostock needs no registration, but each process still must call
bs.login()to open a session — this server logs in once and logs out on shutdown.The announcement tools are stdlib-only (no new dependencies) and run off the baostock session, so they keep working even if baostock is down.
Available Tools
24 toolsget_adjust_factorC
Price adjustment factors (复权因子, baostock 涨跌幅复权算法). Fields: code, dividOperateDate, foreAdjustFactor, backAdjustFactor, adjustFactor.
Inputs: code (required), start_date, end_date.
get_all_stockA
All securities and their trading status on a given day (default: latest
trading day). day format 'YYYY-MM-DD'.
Fields: code, tradeStatus (1可交易/0停牌), code_name.
Inputs: day.
get_balance_dataC
Quarterly solvency / balance-sheet ratios (季频偿债能力). quarter 1..4. Fields: currentRatio, quickRatio, cashRatio, YOYLiability, liabilityToAsset, assetToEquity.
Inputs: code (required), year, quarter.
get_cash_flow_dataC
Quarterly cash-flow ratios (季频现金流量). quarter 1..4. Fields: CAToAsset, NCAToAsset, tangibleAssetToAsset, ebitToInterest, CFOToOR, CFOToNP, CFOToGr.
Inputs: code (required), year, quarter.
get_current_timeA
Current local server time as 'YYYY-MM-DD HH:MM:SS'. Useful for building relative date ranges (e.g. 'last 30 days') for the date parameters below.
Inputs: no named parameters. Returns: result
get_deposit_rate_dataC
Benchmark deposit rates (存款利率) over a date range.
Inputs: start_date, end_date.
get_dividend_dataC
Dividend / rights-issue records. yearType: 'report'(预案公告年, default) / 'operate'(除权除息年) / 'dividend'(分红年). Fields include dividCashPsBeforeTax/AfterTax, dividStocksPs, dividRegistDate, dividOperateDate, dividPayDate.
Inputs: code (required), year, yearType.
get_dupont_dataC
Quarterly DuPont decomposition (季频杜邦指数). quarter 1..4. Fields: dupontROE, dupontAssetStoEquity, dupontAssetTurn, dupontPnitoni, dupontNitogr, dupontTaxBurden, dupontIntburden, dupontEbittogr.
Inputs: code (required), year, quarter.
get_forecast_reportC
Earnings forecast / pre-announcements (业绩预告) in [start_date, end_date]. Fields include profitForcastExpStatDate, profitForcastType, profitForcastChgPctUp/Dwn.
Inputs: code (required), start_date, end_date.
get_growth_dataC
Quarterly growth (季频成长能力). quarter 1..4. Fields: YOYEquity, YOYAsset, YOYNI, YOYEPSBasic, YOYPNI, YOYOperation.
Inputs: code (required), year, quarter.
get_history_k_dataA
Historical K-line bars.
frequency: d=日 w=周 m=月 5/15/30/60=分钟线.
adjustflag: 1后复权 2前复权 3不复权(默认).
Dates 'YYYY-MM-DD'. fields is auto-selected per frequency (daily includes
peTTM/pbMRQ/psTTM/pcfNcfTTM/turn/pctChg; minute adds a time column); pass
a comma-separated fields string only to override.
Inputs: code (required), start_date, end_date, frequency, +2 more.
get_hs300_stocksC
CSI 300 (沪深300) constituents on date (default latest).
Fields: updateDate, code, code_name.
Inputs: date.
get_loan_rate_dataC
Benchmark loan rates (贷款利率) over a date range.
Inputs: start_date, end_date.
get_money_supply_data_monthB
Monthly money supply M0/M1/M2 (货币供应量-月). Dates 'YYYY-MM'.
Inputs: start_date, end_date.
get_money_supply_data_yearB
Yearly money supply M0/M1/M2 (货币供应量-年). Dates 'YYYY'.
Inputs: start_date, end_date.
get_operation_dataC
Quarterly operating capability (季频营运能力). quarter 1..4. Fields: NRTurnRatio, NRTurnDays, INVTurnRatio, INVTurnDays, CATurnRatio, AssetTurnRatio.
Inputs: code (required), year, quarter.
get_performance_express_reportC
Performance express reports (业绩快报) filed in [start_date, end_date]. Fields include performanceExpStatDate, performanceExpressROEWa, performanceExpressEPSChgPct.
Inputs: code (required), start_date, end_date.
get_profit_dataC
Quarterly profitability (季频盈利能力). quarter 1..4. Fields: roeAvg, npMargin, gpMargin, netProfit, epsTTM, MBRevenue, totalShare, liqaShare.
Inputs: code (required), year, quarter.
get_required_reserve_ratio_dataC
Required reserve ratio (存款准备金率). yearType: 0生效日期(default)/1公告日期.
Inputs: start_date, end_date, yearType.
get_stock_basicA
Basic securities profile. Pass code (e.g. 'sh.600519') OR code_name
(Chinese name). Empty both -> all securities.
Fields: code, code_name, ipoDate, outDate, type (1股票/2指数/3其它),
status (1上市/0退市).
Inputs: code, code_name.
get_stock_industryB
Industry classification (申万). Empty code -> whole market.
Fields: updateDate, code, code_name, industry, industryClassification.
Inputs: code, date.
get_sz50_stocksB
SSE 50 (上证50) constituents on date (default latest).
Fields: updateDate, code, code_name.
Inputs: date.
get_trade_datesB
Trading-calendar flags between two dates (default: from 2015-01-01). Fields: calendar_date, is_trading_day (1是/0否).
Inputs: start_date, end_date.
get_zz500_stocksB
CSI 500 (中证500) constituents on date (default latest).
Fields: updateDate, code, code_name.
Inputs: date.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 24 tools
Each tool retrieves a distinct set of financial data (e.g., balance sheet ratios, cash flow, dividends, K-line, index constituents). Descriptions are detailed and clearly separate overlapping concepts like different ratio types or index members.
All tool names follow a consistent 'get_<data_type>_<optional_modifier>' pattern using snake_case, making it easy for an agent to infer purpose from the name alone.
At 24 tools, the count is slightly above the ideal range but still justified given the broad domain coverage (fundamentals, technicals, macro, market indices). Each tool addresses a specific data need without redundancy.
Covers a wide range of A-share market data: financial ratios, K-line, dividends, forecasts, banking rates, money supply, and index constituents. Minor gaps like real-time quotes or SEC filings are understandable for a historical/derived data server.
Related MCP Connectors
China A-share market data over MCP: 22 tools for quotes, K-line, financials, money flow, top-trader boards, sectors, macro, convertible bonds and factor screening. Five tools need no API key, so you can connect and try it immediately.
MCP server exposing the Backtest360 engine API as tools for AI agents.
China A-share market data for research, backtesting and AI agents via MCP.
MCP server for Financial Modeling Prep API with 250+ financial data tools
Related MCP Servers
- AlicenseAqualityBmaintenanceMCP server that provides access to Chinese stock market data using akshare-one9574 PyPI247MIT
- FlicenseNot gradedqualityDmaintenanceMCP server that wraps SFC financial data API into 32 tools for comprehensive A-share market data, including real-time quotes, rankings, limit-up statistics, news, themes, financials, charts, research reports, and watchlists.-
- AlicenseBqualityDmaintenanceMCP server exposing 43 financial data tools for A-share, HK, US stocks, crypto, and market news via open-stock-data.4363 PyPI15MIT
- AlicenseBqualityDmaintenanceMCP server that wraps AKShare's 1000+ financial data functions, enabling LLMs to query Chinese stock, macro, futures, fund, bond, option, forex, and alternative data through standardized tools.143Apache 2.0