ashare-mcp
This server provides tools to fetch and analyze Chinese A-share (沪深京) financial statements, enabling LLMs to query structured financial data from East Money (东方财富) via akshare — free, with no API token required.
get_three_statements— Retrieve the three core annual financial statements (balance sheet, income statement, cash flow statement) for any A-share listed company by stock code and year. Supports multiple code formats (e.g.,000001,SZ000001,000001.SZ). Returns ~150 curated fields in CNY with in-memory caching.cross_check_balance— Run financial consistency checks to verify internal coherence across the three statements, including: balance sheet equation, cash flow identity, and beginning/ending cash reconciliation. Returns pass/fail/skipped status and numerical differences (with a 10,000 CNY rounding tolerance).compare_peers— Compare up to ~10 companies side-by-side for a given year on key metrics (total assets, revenue, net profit, operating cash flow, equity, derived ROE), with rankings, summary statistics (max/min/avg/std dev), and concurrent fetching for speed.track_company_history(HTTP API) — View cross-year trends with YoY growth, CAGR, and anomaly detection.parse_document(optional, requires[pdf]extra) — Convert PDF/DOCX/PPTX/images to LLM-ready markdown using MinerU.
ashare-mcp
Turn A-share financial reports into tools your LLM can call. An MCP server that turns Chinese A-share financial statements into tools your LLM can call.
Let Claude (or any MCP client) get structured balance sheets, income statements, and cash flow statements with a single prompt like "How was Ping An Bank's 2024 annual report?" Fields are curated, units are clear, and it is cache-friendly.
Data sourced from East Money via akshare, completely free, no token required.
Why build another one?
Most "Financial LLM" projects on GitHub are crowded in trading agents and SEC 10-K RAG—the former is highly homogenized, and the latter only serves US stocks. The combination of A-shares + Chinese + MCP protocol layer is almost a blank space.
ashare-mcp has a very narrow focus: do one thing—A-share financial reports—and do it well enough to be integrated into any LLM client in ten seconds. It doesn't predict stock prices, write research reports, or make decisions for you—it simply moves data from East Money into LLM tool calls, with clean fields, clear units, and explicit error handling.
Related MCP server: sfc-data-mcp
Quick Start
git clone https://github.com/yli769227-jpg/ashare-mcp.git
cd ashare-mcp
python3 -m venv .venv && source .venv/bin/activate
pip install -e .Run a smoke test:
python -c "from ashare_mcp.data_source import get_annual_statements; \
r = get_annual_statements('SZ000001', 2024); \
print(r['company_name'], r['balance_sheet']['TOTAL_ASSETS'])"
# -> 平安银行 5769270000000.0Integrate with Claude Desktop
Edit ~/Library/Application Support/Claude/claude_desktop_config.json (Mac):
{
"mcpServers": {
"ashare": {
"command": "/absolute/path/to/ashare-mcp/.venv/bin/python",
"args": ["-m", "ashare_mcp.server"]
}
}
}Restart Claude Desktop, and you can ask directly:
Help me look at Ping An Bank's 2024 annual report. What are the total assets, total liabilities, net profit, and operating cash flow?
Tool List
Tool | Input | Output |
|
| Three major annual statements (curated ~150 fields) |
|
| 3 cross-check results + variance + industry-specific |
|
| Peer comparison for N companies + ranking / max-min-avg-std + ROE |
Code normalization supports multiple formats: 000001 / SZ000001 / sz.000001 / 000001.SZ.
cross_check_balance currently includes 4 cross-checks (the first 3 are industry-agnostic, the 4th is industry-aware):
Balance Sheet Equilibrium —
TOTAL_ASSETS = TOTAL_LIABILITIES + TOTAL_EQUITYCash Flow Identity —
NETCASH_OPERATE + NETCASH_INVEST + NETCASH_FINANCE + RATE_CHANGE_EFFECT = CCE_ADDEnd/Beginning Cash Reconciliation —
END_CCE − BEGIN_CCE = CCE_ADDOperating Profit Decomposition (Industry-Aware)
Banks:
OPERATE_PROFIT = OPERATE_INCOME − OPERATE_EXPENSEIndustrial/Commercial:
OPERATE_PROFIT = TOTAL_OPERATE_INCOME − TOTAL_OPERATE_COST + OTHER_INCOME + INVEST_INCOME + FAIRVALUE_CHANGE_INCOME + ASSET_IMPAIRMENT_INCOME + CREDIT_IMPAIRMENT_INCOME + ASSET_DISPOSAL_INCOME [+ EXCHANGE_INCOME]Automatic Industry Identification: If
ACCEPT_DEPOSIT > 1 billion, use the bank formula; ifTOTAL_OPERATE_INCOME+TOTAL_OPERATE_COSTexist, use the industrial formula; otherwiseskipped(insurance, etc., not yet supported).
Tolerance: 10,000 RMB for the first 3 (rounding of individual items), 10 million RMB for the 4th (cumulative rounding of multiple items). If fields are missing or the industry cannot be identified, the check is skipped, which does not affect other checks. Tested on 3 industries (banks / liquor / batteries) and 4 companies' 2024 annual reports, all passed 4/4.
Leverages LRU cache: Call get_three_statements first, then cross_check_balance, and the latter returns in < 1ms (data for the same stock is already in memory).
compare_peers default metrics: TOTAL_ASSETS / TOTAL_OPERATE_INCOME / PARENT_NETPROFIT / NETCASH_OPERATE / TOTAL_EQUITY, automatically derives ROE = PARENT_NETPROFIT / Average Equity (average of current year-end equity and last year-end equity; last year's data is retrieved via LRU cache at almost zero cost; if last year's data is missing, it falls back to year-end equity, marked in the roe_method field as ending_equity_fallback). Automatic fallback: For banks, if TOTAL_OPERATE_INCOME is missing, it falls back to OPERATE_INCOME and marks it in the fallbacks field. Concurrency implementation: ThreadPoolExecutor (max_workers=8), pulls data for N companies in parallel (failure of one does not crash the whole process, recorded in errors). Tested 4 major banks' 2024 annual reports in ~38s; China Merchants Bank ROE 12.85% (long-term leader in retail).
Architecture
flowchart LR
LLM[Claude / 任意 MCP 客户端] -->|JSON-RPC over stdio| Server[ashare-mcp<br/>FastMCP server]
Server -->|代码归一化| Norm[股票代码归一化<br/>SZ/SH/BJ 自动判断]
Server -->|拉取三表| DS[数据源封装<br/>akshare 包装层]
DS -->|缓存命中| Cache[(进程内存缓存<br/>lru_cache)]
DS -->|缓存未命中| YearlyEM[akshare<br/>by_yearly_em]
YearlyEM -->|HTTP| EM[东方财富<br/>财报数据接口]
DS -->|字段过滤| Filter[剔除元数据列<br/>剔除同比列<br/>剔除空/零字段]
Server -->|结构化 JSON| LLMKey Design:
Field names retain original East Money English (
TOTAL_ASSETS/LOAN_ADVANCE/NETPROFIT). LLMs can understand them directly, and fields for different industries like banks / industrial / insurance are all in the same dictionary, requiring no industry judgment.In-process memory caching makes "multi-year comparison for the same company" almost zero-cost—cold start pulls the full volume, subsequent year switching is < 1ms.
Logs go to stderr, not polluting the MCP stdio protocol channel.
Roadmap
Version | Tool | Status |
v0 |
| ✅ |
v1 |
| ✅ |
v1 |
| ✅ |
v1.5 (Current) |
| ✅ |
v1.5 (Current) |
| ✅ |
v2 | Year-over-year trend tool | Pending |
v2 | Quarterly data + YoY/QoQ derived metrics | Pending |
v2 | Official MCP registry release | Pending |
Local Development
# 增量验证(每次改完跑一遍)
python -c "from ashare_mcp.utils import normalize_stock_code; \
assert normalize_stock_code('000001') == 'SZ000001'"
python -c "from ashare_mcp.server import mcp; \
import asyncio; print([t.name for t in asyncio.run(mcp.list_tools())])"Data Disclaimer
Data source: East Money, via akshare.
Data latency, definitions, and accuracy are subject to East Money, and do not constitute investment advice.
For educational and research purposes only.
License
MIT — see LICENSE.
Available Tools
3 toolscompare_peersA
同业 N 家公司同年年报横向对比,自动算排名 / 最大最小 / 均值 / 标准差,加派生指标 ROE。
参数: stock_codes: 公司代码列表,如 ['000001', '600036', '601398']。建议 2-10 家。 支持各种格式:'000001' / 'SZ000001' / 'sz.000001' / '000001.SZ'。 year: 年份。 metrics: 可选,自定义对比字段。默认包括: TOTAL_ASSETS / TOTAL_OPERATE_INCOME / PARENT_NETPROFIT / NETCASH_OPERATE / TOTAL_EQUITY。 派生指标 ROE = PARENT_NETPROFIT / TOTAL_EQUITY 总是会算上。 银行业 TOTAL_OPERATE_INCOME 缺失时自动 fallback 到 OPERATE_INCOME(在 fallbacks 字段里标注)。
返回: { "year": 2024, "report_date": "2024-12-31", "metrics": ["TOTAL_ASSETS", ..., "ROE"], "companies": [ { "stock_code": "SZ000001", "company_name": "平安银行", "values": {metric: number}, "ranks": {metric: rank}, # 1 = 最大 "fallbacks": {original_key: actual_key} | null } ], "summary": { metric: {"max", "min", "avg", "std", "count"} }, "errors": [ {"stock_code": "...", "error": "..."} # 单家失败不挂整体 ] }
并发实现: ThreadPoolExecutor(max_workers=8),N 家公司并行拉。 缓存联动: 已经查过的公司走 lru cache,< 1ms 复用。
Inputs: stock_codes (required), year (required), metrics.
cross_check_balanceA
跑财务勾稽校验,检测三大表数据是否互相自洽。返回每条校验的 passed/failed/skipped 状态与误差。
参数: stock_code: A 股代码,支持多种格式(同 get_three_statements)。 year: 年份,如 2024。仅支持年报。
返回: { "stock_code": "SZ000001", "company_name": "平安银行", "report_date": "2024-12-31", "checks": [ { "name": "balance_sheet_equation", "label": "资产负债平衡", "formula": "TOTAL_ASSETS = TOTAL_LIABILITIES + TOTAL_EQUITY", "lhs_value": 5769270000000.0, "rhs_value": 5769270000000.0, "diff": 0.0, "tolerance": 10000.0, "status": "passed" }, ... ], "summary": {"total": 3, "passed": 3, "failed": 0, "skipped": 0} }
当前 v1 包含 3 条行业通用勾稽:
资产负债平衡: TOTAL_ASSETS = TOTAL_LIABILITIES + TOTAL_EQUITY
现金流恒等式: 三大现金流 + 汇率影响 = 现金净增加额
期末/期初现金对账: END_CCE - BEGIN_CCE = CCE_ADD
容忍度 1 万元(财报舍入)。字段缺失时该条 status='skipped',不影响其它校验。
Inputs: stock_code (required), year (required).
get_three_statementsA
拉取 A 股某只股票某年的年报三大财务报表(资产负债表 / 利润表 / 现金流量表)。
参数: stock_code: A 股代码,支持多种格式 —— '000001' / 'SZ000001' / 'sz.000001' / '000001.SZ'。 year: 年份(整数),如 2024。仅支持年报(报告期 12-31)。
返回: { "stock_code": "SZ000001", "company_name": "平安银行", "report_date": "2024-12-31", "currency": "CNY", "unit": "yuan (元)", "balance_sheet": {...}, # 字段如 TOTAL_ASSETS / LOAN_ADVANCE / ACCEPT_DEPOSIT "income_statement": {...}, # 字段如 OPERATE_INCOME / NETPROFIT / PARENT_NETPROFIT "cash_flow_statement": {...}, # 字段如 NETCASH_OPERATE / NETCASH_INVEST / NETCASH_FINANCE }
数据源: 东方财富(via akshare)。字段名为东方财富原始英文(SCREAMING_SNAKE_CASE)。 单位: 人民币元。 缓存: 进程内存缓存,同一只股票多次查询(不同年份)只走一次网络。
Inputs: stock_code (required), year (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 3 tools
Each tool has a clear, distinct purpose: retrieving financial statements, cross-checking consistency, and comparing peers. There is no overlap or ambiguity.
All tool names follow a consistent snake_case verb_noun pattern (compare_peers, cross_check_balance, get_three_statements), making them predictable and clear.
Three tools is minimal but sufficient for the focused domain of A-share annual financial analysis. The count feels well-scoped without being overly thin.
The tools cover core workflows: data retrieval, internal consistency checks, and peer comparison. Minor gaps like quarterly data or individual ratio lookups exist, but the surface is largely complete for annual report analysis.
Maintenance
Related MCP Connectors
China A-share & equity research MCP server (回声投研) for market quotes, filings, financials, fund flows, concepts & sentiment.
Chinese company registry, litigation, IP and credit data for AI agents. Read-only remote MCP server.
China A-share market data for research, backtesting and AI agents via MCP.
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.
Related MCP Servers
- AlicenseAqualityBmaintenanceMCP server that provides access to Chinese stock market data using akshare-one101,550 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.-
- AlicenseAqualityDmaintenanceMCP server to fetch Vietnamese corporate financial reports (balance sheet, income statement, cash flow) from cafef.vn using public API, no PDF or OCR needed.31MIT

fd-cn-reportofficial
AlicenseBqualityBmaintenanceAn MCP server for Chinese financial reports, providing 44 tools to resolve companies, list/retrieve filings, extract report sections, run AI-based indicator extraction, search via Elasticsearch, and browse a 21,698-rule industry rules dashboard.4436 PyPI3MIT