ashare-mcp
A-share market data MCP server via baostock. Full-stack coverage: K-line, financials, DCF/DDM/PEG valuation, 11 technical indicators with proper split-day volume handling (OBV/MFI on raw bars), CN-style KDJ (J=3K-2D), risk metrics (Beta/Sharpe/MaxDD with stock-suspension-aware aligned returns), and PBoC macro data.
README
A-Share MCP Server
A-Share (中国A股) 市场数据 MCP 服务器,基于 baostock 数据源。
Vibe Coded -- 本项目由 AI 辅助编写 (vibe coding),代码质量和计算公式未经严格审计。 估值模型 (DCF / DDM / PEG)、技术指标、风险指标等涉及的数学公式可能存在错误, 产出的数字仅供学习参考,请勿作为任何投资决策的依据。 如果你发现了 bug,欢迎提 issue 或 PR。
功能概览
| 分类 | 工具 |
|---|---|
| 行情数据 | K线、快照、复权因子、股票列表、行业分类、交易日历、分红 |
| 财务数据 | 利润、增长、资产负债、现金流、杜邦分析、营运能力 |
| 指数成分 | 沪深300、上证50、中证500 |
| 宏观数据 | 货币供应量 (M0/M1/M2)、存贷款利率、存款准备金率 |
| 技术分析 | MACD、RSI、KDJ、BOLL、WR、CCI、ATR、ADX、OBV、MFI、均线 (SMA/EMA) |
| 估值分析 | PE/PB/PS 历史分位、行业对比、DCF、DDM、PEG |
| 风险指标 | Beta、Sharpe、最大回撤、波动率、信息比率 |
快速开始
需要 Python >= 3.12 和 uv。
# 克隆
git clone <repo-url>
cd ashare-mcp
# 安装依赖
uv sync
# 启动 (stdio 模式,供 MCP 客户端对接)
uv run python -m ashare_mcp
# 或 HTTP 模式
uv run python -m ashare_mcp --transport http --port 3000
注意事项
- 数据来源为 baostock 免费接口,无需注册、无需 API Key
- baostock 仅提供 A 股历史数据,不提供实时行情
- 技术指标需要足够的历史数据做 warmup(如 MACD 至少需要 33 个交易日),窗口过短会返回 null
- 复权因子仅在除权除息日存在记录,非除权日期查询会返回空
- DCF 中的 OCF 是由
MBRevenue * CFOToOR推算的(约 2% 精度),Capex 需调用者自行提供 - DDM 的股利增长率会被 clamp 到 [1%, 20%] 区间,防止极端外推
Credits
- firmmaple/a-share-mcp-server -- 原版实现,本项目从零重写但灵感来源于此
- LINUX DO 社区 -- 感谢社区的讨论和灵感
- baostock -- 免费开源的 A 股数据源
- FastMCP -- MCP 协议实现
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.