A-Share MCP

by 24mlight

Not rated
GitHub

About

Provides A-share stock market data, including basic info, historical K-lines, financial indicators, and macroeconomic data using Baostock.

Details

Author
24mlight
Categories
Database, Finance, Other
Tags
#trading, #data-analysis

Setup

Install A-Share MCP in your MCP client (Claude Desktop, Cursor, Windsurf, and others).

Repository: https://github.com/24mlight/a-share-mcp-is-just-i-need

Follow the installation instructions in the repository README, then restart your MCP client.

本项目是一个基于专注于 A 股市场的 MCP 服务器,它提供股票基本信息、历史 K 线数据、财务指标、宏观经济数据等多种查询功能,理论上来说,可以回答有关 A 股市场的任何问题,无论是针对大盘还是特定股票。

a_share_mcp/ │ ├── mcp_server.py # 主服务器入口文件 ├── pyproject.toml # 项目依赖配置 ├── README.md # 项目说明文档 │ ├── src/ # 源代码目录 │ ├── __init__.py │ ├── baostock_data_source.py # Baostock数据源实现 │ ├── data_source_interface.py # 数据源接口定义 │ ├── utils.py # 通用工具函数 │ │ │ ├── formatting/ # 数据格式化模块 │ │ ├── __init__.py │ │ └── markdown_formatter.py # Markdown格式化工具 │ │ │ └── tools/ # MCP工具模块 │ ├── __init__.py │ ├── base.py # 基础工具函数 │ ├── stock_market.py # 股票市场数据工具 │ ├── financial_reports.py # 财务报表工具 │ ├── indices.py # 指数相关工具 │ ├── market_overview.py # 市场概览工具 │ ├── macroeconomic.py # 宏观经济数据工具 │ ├── date_utils.py # 日期工具 │ └── analysis.py # 分析工具 │ └── resource/ # 资源文件 └── img/ # 图片资源 ├── img_1.png # CherryStudio配置示例 └── img_2.png # CherryStudio配置示例

- 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 之前询问当天的数据,是无法获取到的。

# 1. 创建虚拟环境(仅创建,不会安装任何包) uv venv # 2. 激活虚拟环境 # Windows .venv\Scripts\activate # macOS/Linux # source .venv/bin/activate # 3. 安装所有依赖(必须在激活的虚拟环境中执行) uv sync

在支持 MCP 的客户端(如 VS Code 插件、CherryStudio 等)中,你需要配置如何启动此服务器。推荐使用uv

方法一:使用 JSON 配置的 IDE (例如 Cursor、VSCode、Trae 等)

对于需要编辑 JSON 文件来配置 MCP 服务器的客户端,你需要找到对应的能配置 MCP 的地方(各个 IDE 和桌面 MCP Client 可能都不一样),并在mcpServers对象中添加一个新的条目。

{ "mcpServers": { "a-share-mcp": { "command": "uv", // 或者 uv.exe 的绝对路径, 例如: "C:\\path\\to\\uv.exe" "args": [ "--directory", "C:\\Users\\YourName\\Projects\\a_share_mcp", // 替换为你的项目根目录绝对路径,不一定是C盘,按实际的填写 "run", "python", "mcp_server.py" ], "transport": "stdio" // "workingDirectory": "C:\\Users\\YourName\\Projects\\a_share_mcp", // 使用 uv --directory 后,此项可能不再必需,但建议保留作为备用 } // ... other servers ... } }

- command: 确保填写的uv命令或uv.exe的绝对路径是客户端可以访问和执行的。
- args: 确保参数列表完整且顺序正确。
- 路径转义: 路径需要写成双反斜杠\\

这是 Windows 系统特有的情况。如果是在 macOS 或 Linux 系统中,路径使用正斜杠/作为目录分隔符,就不需要这种转义处理。
- 第一个参数填:--directory
- 第二个参数填:C:\\Users\\YourName\\Projects\\a_share_mcp
- 第三个参数填:run
- 第四个参数填:python
- 第五个参数填:mcp_server.py

Tricks(必看): 有时候在 Cherrystudio 填写好参数后,点击右上方的开关按钮,会发现没任何反应,此时只要随便点击左侧目录任一按钮,跳出 mcp 设置界面,然后再回到 mcp 设置界面,就会发现 mcp 已经闪绿灯配置成功了。

CherryStudio 使用示例:理论上来说,你可以问有关 A 股的任何问题 :)

- 确保命令字段中的uv或其绝对路径有效且可执行。
- 确保参数字段按顺序正确填写了五个参数。

该 MCP 服务器目前提供41个工具,覆盖股票、财报、宏观、日期分析等全方位数据。以下是完整列表:

- get_historical_k_data(历史K线)
- get_stock_basic_info(基础信息)
- get_dividend_data(分红配送)
- get_adjust_factor_data(复权因子)

- get_profit_data(盈利能力)
- get_operation_data(营运能力)
- get_growth_data(成长能力)
- get_balance_data(资产负债)
- get_cash_flow_data(现金流量)
- get_dupont_data(杜邦分析)
- get_performance_express_report(业绩快报)
- get_forecast_report(业绩预告)
- get_fina_indicator(财务指标汇总)

- get_trade_dates(交易日历)
- get_all_stock(全市场证券)
- search_stocks(股票搜索)
- get_suspensions(停牌信息)
- get_stock_industry(行业分类)
- get_index_constituents(指数成分)
- get_sz50_stocks(上证50)
- get_hs300_stocks(沪深300)
- get_zz500_stocks(中证500)
- list_industries(行业列表)
- get_industry_members(行业个股)

- get_deposit_rate_data(存款利率)
- get_loan_rate_data(贷款利率)
- get_required_reserve_ratio_data(存款准备金)
- get_money_supply_data_month(货币供应月)
- get_money_supply_data_year(货币供应年)
- get_latest_trading_date(最新交易日)
- get_market_analysis_timeframe(智能分析周期)
- is_trading_day(判断交易日)
- previous_trading_day(上一交易日)
- next_trading_day(下一交易日)
- get_last_n_trading_days(最近N日)
- get_recent_trading_range(近期范围)
- get_month_end_trading_dates(月末交易日)
- get_stock_analysis(生成分析报告)
- normalize_stock_code(代码标准化)
- normalize_index_code(指数代码标准化)
- list_tool_constants(常量查询)

欢迎提交 Issue 或 Pull Request 来帮助改进项目。贡献前请先查看现有 Issue 和文档。

- 财务指标汇总:get_fina_indicator一键获取 6 大类财务指标(盈利能力、营运能力、成长能力、偿债能力、现金流量、杜邦分析),按季度返回合并数据。

AudioAlpha turns 100+ daily finance and crypto podcasts into structured intelligence — α-sentiment scores, narrative signals, asset mentions, transcripts, and market snapshots with 40+ custom metrics. Built for AI-driven research and trading workflows.

Access Binance cryptocurrency market data, including prices, candlestick charts, and order books.

Token Metrics integration for fetching real-time crypto market data, trading signals, price predictions, and advanced analytics.

Access Chinese stock market data, including historical prices, real-time quotes, news, and financial statements.

Access real-time Binance cryptocurrency market data, including prices, order books, and trading history.

Provides real-time and historical cryptocurrency market data from major exchanges using the CCXT library.

Funding rounds, acquisitions & exec moves — deduped, enriched, typed. Query over REST, stream over webhooks, or hand to your agent over MCP. 50 free credits.

Access global financial market data through 70+ tools: end-of-day & intraday prices, fundamentals, earnings & financial statements, news & sentiment, screeners, technical indicators, macro and more - across stocks, ETFs, forex and crypto.

Access economic data from the Federal Reserve Bank of St. Louis (FRED).

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.