guojianchuan821113/tushare-mcp-server
3.3
If you are the rightful owner of tushare-mcp-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.
Tushare MCP Server encapsulates multiple Tushare Pro interfaces as MCP tools for AI clients.
Tools
13
Resources
0
Prompts
0
Tushare MCP Server
将 Tushare Pro 的多个接口封装为 MCP 工具,通过 stdio 供 AI 客户端(如 Claude Desktop)调用。所有工具返回 Pandas DataFrame 的 orient="records" JSON 字符串。
前置条件
- Python 3.10+
- 已安装 uv
- 有效的 Tushare Pro Token
安装依赖
uv sync
配置 Token
在项目根目录创建/编辑 .env(已提供示例):
TUSHARE_TOKEN=your_tushare_token_here
代码将优先从环境变量 TUSHARE_TOKEN 读取,若无则再从 .env 加载。
运行服务器
uv run src/tushare_mcp_server/server.py
服务器使用 stdio 作为 MCP 传输层。
已封装的工具
stk_factor_pro— 股票技术面因子(专业版技术指标)moneyflow— 个股资金流向moneyflow_cnt_ths— 同花顺概念板块资金流向moneyflow_ind_ths— 同花顺行业板块资金流向cyq_perf— 股票筹码分布stock_basic— 股票基本信息index_classify— 行业分类信息fina_indicator— 财务指标stk_holdernumber— 股东人数ths_daily— 同花顺指数日线index_weekly— 指数周线trade_cal— 交易日历stk_auction_o— 集合竞价
行业分析工具
在 src/tool_kits/ 目录下提供了额外的行业分析工具:
申万一级行业指数估值评估 (sector_index.py)
基于PE/PB历史分位数评估行业估值状态(高估/低估/中性)。
新增:行业盈利增长分析 (sector_index.py - profit_growth 模式)
最新功能:计算申万一级行业指数的最新季度加权净利润同比增速,作为行业景气度核心指标。
主要特性:
- 使用官方月度成分股权重和个股扣非净利润同比增长率
- 优先使用
dt_netprofit_yoy(扣非净利润增速),缺失时使用netprofit_yoy替代 - 自动过滤异常值(|增速| > 1000%)和无效数据
- 提供数据质量标记和详细的处理日志
使用方法:
# 运行估值分析(默认)
python src/tool_kits/sector_index.py
# 运行盈利增长分析
python src/tool_kits/sector_index.py profit_growth
函数接口:
from src.tool_kits.sector_index import get_industry_profit_growth, evaluate_all_industries_profit_growth
# 单个行业分析
result = get_industry_profit_growth('801760.SI', '20251110')
# 批量分析所有行业
results_df = evaluate_all_industries_profit_growth()
详见
所有工具均返回 JSON 字符串;若发生错误(参数/网络等),返回形如:
{"error": "<错误信息>"}
集成到 Claude Desktop(示例)
在 claude_desktop_config.json 中添加:
{
"mcpServers": {
"tushare-mcp-server": {
"command": "uv",
"args": ["run", "/Users/guojianchuan/Downloads/github_workspace/tushare-mcp-server/src/tushare_mcp_server/server.py"]
}
}
}
许可证
本项目用于演示 MCP 服务器的基本封装方式。