This server provides comprehensive data and analysis capabilities for the Chinese A-share market, including:
- Historical Market Data: Fetch daily, weekly, monthly, or minute-level K-line data with various adjustment options
- Basic Stock Information: Access fundamental details, listing dates, industry classifications
- Dividend & Adjustment Data: Retrieve historical dividends and price adjustment factors
- Financial Reports: Query detailed quarterly metrics for profitability, operations, growth, balance sheets, cash flow, and DuPont analysis
- Performance Data: Access performance express and forecast reports
- Index Information: Get constituent stocks for SZSE 50, CSI 300, and CSI 500 indices
- Macroeconomic Indicators: Retrieve deposit/loan rates, reserve ratios, money supply data, and SHIBOR rates
- Trading Dates & Utilities: Check trading calendars, current/latest trading dates, and market analysis timeframes
- Stock Analysis Tools: Generate data-driven fundamental and technical analysis reports
Provides stock market data analysis tools for A-share markets through data accessed via Baostock, offering historical K-line data, financial reports, market indices, and macroeconomic indicators.
📊 a-share-mcp 📈
本项目是一个基于专注于 A 股市场的 MCP 服务器,它提供股票基本信息、历史 K 线数据、财务指标、宏观经济数据等多种查询功能,理论上来说,可以回答有关 A 股市场的任何问题,无论是针对大盘还是特定股票。
项目结构
功能特点
先决条件
- Python 环境: Python 3.10+
- 依赖管理: 使用
uv
包管理器安装依赖 - 数据来源: 基于 Baostock 数据源,无需付费账号。在此感谢 Baostock。
- 提醒:本项目于 Windows 环境下开发。
数据更新时间
以下是 Baostock 官方数据更新时间,请注意查询最新数据时的时间点 Baostock 官网
每日数据更新时间:
- 当前交易日 17:30,完成日 K 线数据入库
- 当前交易日 18:00,完成复权因子数据入库
- 第二自然日 11:00,完成分钟 K 线数据入库
- 第二自然日 1:30,完成前交易日"其它财务报告数据"入库
- 周六 17:30,完成周线数据入库
每周数据更新时间:
- 每周一下午,完成上证 50 成份股、沪深 300 成份股、中证 500 成份股信息数据入库
所以说,在交易日的当天,如果是在 17:30 之前询问当天的数据,是无法获取到的。
安装环境
在项目根目录下执行:
要启动 A 股 MCP 服务器,请按照以下步骤操作:
使用:在 MCP 客户端中配置服务器
在支持 MCP 的客户端(如 VS Code 插件、CherryStudio 等)中,你需要配置如何启动此服务器。 推荐使用 uv
。
方法一:使用 JSON 配置的 IDE (例如 Cursor、VSCode、Trae 等)
对于需要编辑 JSON 文件来配置 MCP 服务器的客户端,你需要找到对应的能配置 MCP 的地方(各个 IDE 和桌面 MCP Client 可能都不一样),并在 mcpServers
对象中添加一个新的条目。
JSON 配置示例 (请将路径替换为你的实际绝对路径):
注意事项:
command
: 确保填写的uv
命令或uv.exe
的绝对路径是客户端可以访问和执行的。args
: 确保参数列表完整且顺序正确。- 路径转义: 路径需要写成双反斜杠
\\
。这是 Windows 系统特有的情况。如果是在 macOS 或 Linux 系统中,路径使用正斜杠/作为目录分隔符,就不需要这种转义处理。
workingDirectory
: 虽然uv --directory
应该能解决工作目录问题,但如果客户端仍然报错ModuleNotFoundError
,可以尝试在客户端配置中明确设置此项为项目根目录的绝对路径。
方法二:使用 CherryStudio
在 CherryStudio 的 MCP 服务器配置界面中,按如下方式填写:
- 名称:
a-share-mcp
(或自定义) - 描述:
本地 A 股 MCP 服务器
(或自定义) - 类型: 选择 标准输入/输出 (stdio)
- 命令:
uv
(或者填系统中绝对路径下 uv.exe) - 包管理源: 默认
- 参数:
- 第一个参数填:
--directory
- 第二个参数填:
C:\\Users\\YourName\\Projects\\a_share_mcp
- 第三个参数填:
run
- 第四个参数填:
python
- 第五个参数填:
mcp_server.py
- 确保所有参数按下回车转行隔开的,否则报错(是不是手把手教学了?)
- 第一个参数填:
- 环境变量: (通常留空)
Tricks(必看): 有时候在 Cherrystudio 填写好参数后,点击右上方的开关按钮,会发现没任何反应,此时只要随便点击左侧目录任一按钮,跳出 mcp 设置界面,然后再回到 mcp 设置界面,就会发现 mcp 已经闪绿灯配置成功了。
CherryStudio 使用示例: 理论上来说,你可以问有关 A 股的任何问题 :)
重要提示:
- 确保命令字段中的
uv
或其绝对路径有效且可执行。 - 确保参数字段按顺序正确填写了五个参数。
工具列表
该 MCP 服务器提供以下工具:
贡献指南
欢迎提交 Issue 或 Pull Request 来帮助改进项目。贡献前请先查看现有 Issue 和文档。
☕️ 请作者喝杯咖啡
如果这个项目对你有帮助,欢迎请我喝杯咖啡 ❤️
许可证
本项目采用 MIT 许可证 - 详情请查看 LICENSE 文件
remote-capable server
The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.
Tools
A Model Context Protocol server providing tools for querying A-share stock market data, including historical prices, financial reports, market indices, and macroeconomic indicators.
Related Resources
Related MCP Servers
- -securityFlicense-qualityProvides real-time access to global stock market data including current prices, historical charts, and company financial information through a Model Context Protocol (MCP) server for AI assistants.Last updated -TypeScript
- AsecurityAlicenseAqualityA Model Context Protocol server that enables interaction with Yahoo Finance to retrieve stock pricing, company information, and historical financial data through natural language queries.Last updated -912PythonMIT License
- AsecurityAlicenseAqualityA Model Context Protocol server focused on China's A-share stock market that provides data on stocks, financials, market indices, and macroeconomic indicators.Last updated -27328PythonMIT License
- -securityAlicense-qualityA Model Context Protocol server that provides intelligent stock data assistance through Tushare's financial data API, enabling users to query comprehensive stock information, financial data, and market indices through natural language.Last updated -10PythonMIT License