Tushare_MCP logo

Tushare_MCP

Community
buuzzy

a finance MCP tool

Publisherbuuzzy
Repositorytushare_MCP
LanguagePython
Forks
16
Stars
49
Available tools
0
Transport typestdio, streamable-http
Categories
LicenseMIT
Links
  • Connect tools to AI workflows

    Tushare_MCP exposes MCP capabilities that can be used by compatible AI clients and agents.

  • 0 available tools

    Browse the callable actions below, including names and descriptions when provided by the server.

  • Ready-to-copy setup

    Use the installation snippets to configure this server in your preferred MCP client.

  • Open source signals

    49 stars and 16 forks from the linked repository.

Tushare MCP 📈

基于 MCP (Model Context Protocol) 协议构建的 A 股金融数据 AI 助手扩展 (v0.1.0)


Tushare MCP 是一款连接 AI(Claude, Cursor)与 Tushare 金融大数据的桥梁。它实现了 Model Context Protocol (MCP) 标准,让你的 AI 助手能够直接调用 30+ 个专业金融数据接口,实时查询股票行情、财务报表、公司基本面等关键数据。

本项目采用了更为方便、平价的 tinyshare SDK,替代了官方的 tushare 库。使用下述依赖:

import tinyshare as ts

如果你完全不知道如何使用,请阅读下方腾讯文档: Tushare MCP 使用说明

如果你想通过添加 mcp server 直接使用,忽略繁琐过程,可以联系我试用: 微信:Buuzzy0603


试用端点,可免费体验 mcp tools,无需 token

如果不知道如何使用,把下面这两个地址发给 AI,让它添加 mcp server

### stock endpoint
https://stock-mcp.pricetrade.top/sse

### fund endpoint
https://fund-mcp.pricetrade.top/sse

2025.02.20 补齐 ETF、工具基金接口

本次更新重点补齐了公募基金及 ETF 接口。同时,针对大模型(特别是数据对比与分析场景)强烈的“多代码逗号分隔查询”倾向,而底层 Tushare API 又不原生支持的痛点,我们在所有的 Fund 模块底层植入了 “本地请求切割与合并处理器”。该机制能够智能拦截逗号列表,在后台循环发起多次原子请求并拼接整合数据帧。

2025.02.16 重构

本次迭代实现了从单文件脚本向模块化工程的重构。我们将原来的单体 server.py 拆分为 server.py (仅负责服务编排与路由)、 tools/ (按业务领域拆分的逻辑核心) 以及 utils/ (基础设施) 三层架构。此改动彻底解耦了服务启动与业务逻辑,使得每个 Tushare 接口(如行情、财务)拥有独立的文件空间,显著提升了代码的可维护性与扩展性,为后续接入更多数据源和多人协作奠定了坚实的工程基础。

🌟 核心功能

1. 🤖 完美适配主流 AI 客户端

  • Claude Desktop: 标准 Streamable HTTP / Stdio 模式支持,本地直接运行。
  • Cursor IDE: 在编辑器中直接询问代码相关的股票数据,辅助金融编程。

2. 📊 全维度数据覆盖

  • 基础数据: 股票列表、IPO 新股、交易日历、上市公司基本面。
  • 行情数据: 日/周/月线行情、每日指标(PE/PB/市值)、涨跌停分析。
  • 财务报表: 利润表、资产负债表、现金流量表、业绩预告、主营业务构成。
  • 基金与ETF: 场内/场外基金列表、每日行情与份额、基金经理简历、基金持仓、基金分红与净值、专业技术因子。
  • 特色数据: 沪深港通十大成交股、融资融券、股权质押。

3. 🛠 智能 Token & API 管理

  • 一键配置: 提供 setup_tushare_token 工具,对话即可完成配置。
  • 本地加密: Token 安全存储于本地环境,无需重复输入。
  • 批量查询重写: 针对 Tushare 不支持批量 ts_code 查询的基金接口,在本地自动实现“逗号分割 -> 循环请求 -> 数据拼接”,完美适配 LLM 批量查询习惯。

4. ⚡ 高性能架构

  • Streamable HTTP: 基于 MCP SDK 原生 Streamable HTTP 传输协议,取代旧版 SSE。
  • Tinyshare SDK: 深度优化的 Tushare 接口封装,支持重试与异常处理。

🏗️ 技术架构

🚀 快速开始

1. 环境准备

确保已安装 python 3.10+。

bash
# 1. 克隆项目
git clone <repository-url> tushare_mcp
cd tushare_mcp

# 2. 创建虚拟环境
python3 -m venv venv
source venv/bin/activate  # macOS/Linux
# venv\Scripts\activate   # Windows

# 3. 安装依赖
pip install -r requirements.txt

2. 配置说明

你也可以通过环境变量手动配置:

bash
# 创建配置文件
touch .env

# 写入 Token(推荐使用 MCP 工具 setup_tushare_token 自动配置)
echo "TUSHARE_TOKEN=你的token" >> .env

3. 启动服务

方式 A: HTTP Server (Streamable HTTP 模式) - 推荐

适用于 Cursor 等支持远程 MCP 的客户端。

bash
python server.py
# 服务将运行在 http://localhost:8000
# MCP 端点: http://localhost:8000/mcp

方式 B: Stdio 模式

适用于 Claude Desktop 本地集成。

bash
python server.py --stdio

🔌 客户端连接

Cursor 配置

  1. 打开 Cursor Settings -> Features -> MCP
  2. 点击 "+ Add New MCP Server"
  3. 填写信息:
    • Name: tushare
    • Type: Streamable HTTP
    • URL: http://localhost:8000/mcp

Claude Desktop 配置

编辑配置文件 ~/Library/Application Support/Claude/claude_desktop_config.json:

json
{
  "mcpServers": {
    "tushare": {
      "command": "/绝对路径/至/你的/venv/bin/python",
      "args": [
        "/绝对路径/至/你的/tushare_mcp/server.py",
        "--stdio"
      ]
    }
  }
}

🧰 工具列表

📈 基础与行情 (Stock)

工具名说明
get_stock_basic获取 A 股基础信息列表(代码、名称、上市日期等)
get_trade_cal获取各大交易所交易日历
get_stock_company获取上市公司基本信息(注册资本、法人、简介)
get_namechange历史名称变更记录
get_stk_managers上市公司管理层主要成员
dailyA 股股票/指数日线行情(开高低收、成交量),支持逗号分隔多代码
weekly / monthly股票/指数周线 / 月线行情,支持逗号分隔多代码
get_daily_basic每日指标(换手率、量比、PE、PB、总市值)
get_suspend_d每日停复牌信息
get_hsgt_top10沪深股通十大成交股

💰 财务数据 (Finance)

工具名说明
get_income_statement利润表
get_balance_sheet资产负债表
get_cash_flow现金流量表
get_forecast业绩预告
get_express业绩快报
get_fina_indicator财务指标数据(EPS、ROE、毛利率等)
get_fina_mainbz主营业务构成
get_disclosure_date财报披露计划日期

📈 基金与ETF (Fund)

工具名说明
etf_basic国内ETF基础信息列表
etf_indexETF所属或跟踪指数
etf_share_sizeETF每日份额和规模
fund_basic公募基金数据列表(场内+场外)
fund_company公募基金管理人名录
fund_manager公募基金经理名录与简历
fund_share公募基金规模与份额历史
fund_daily场内基金/ETF日线行情
fund_adj基金复权因子
fund_nav公募基金净值历史
fund_div公募基金分红记录
fund_portfolio公募基金持仓数据(十大重仓股)
fund_factor_pro场内基金技术面因子数据(MACD/RSI等)
stk_mins股票历史分钟行情(5/15/30/60分钟;1分钟未开放)

🌍 全球市场:港美股 (Global)

工具名说明
hk_daily / hk_weekly / hk_monthly港股日/周/月线行情(5位数字代码,如 00700;复权可选)
us_daily / us_weekly / us_monthly美股日/周/月线行情(ticker,如 AAPL;复权可选)
global_index_daily全球指数 K 线(恒指 HSI / 恒生科技 / 国企 / 道指 / 标普500 / 纳指100 / 纳指综合)
hk_fina_indicator港股主要财务指标(EPS/ROE/毛利率/营收与净利同比等,年度或报告期)
us_fina_indicator美股主要财务指标(营收/净利同比/毛利率/ROE/速动比率等,年报或季报)
hk_income / hk_balancesheet / hk_cashflow港股三大报表(逐科目金额,报告期分行)
us_income / us_balancesheet / us_cashflow美股三大报表(逐科目金额,报告期分行)
us_filings美股 SEC 申报文件(10-K/10-Q/8-K 等,含原文链接)
hk_announcements港股公告(披露易官方数据,含 PDF 链接)
search_symbol港美股代码/名称互查(不确定代码时先查)

完整工具列表请查阅 tools/ 目录或启动服务后访问 API 文档。

📁 项目结构

tushare_MCP/
├── api_docs/           # 原始 Tushare API 文档参考
├── mcp_test/           # MCP 工具测试记录
├── tools/              # MCP 工具实现核心代码
│   ├── finance/        # 财务类工具 (income, balance, cashflow...)
│   └── stock/
│       ├── basic/      # 基础数据工具 (stock_basic, trade_cal...)
│       └── quote/      # 行情数据工具 (daily, weekly, hsgt...)
├── utils/              # 通用工具函数 (logger, token_manager)
├── server.py           # MCP Server 入口 (FastAPI + FastMCP)
├── requirements.txt    # 项目依赖
└── README.md           # 项目文档

📄 License

MIT


Installation

TypingMind
Prerequisites:

Node.js 18+

{
  "mcpServers": {
    "buuzzy-tushare_mcp": {
      "command": "",
      "args": []
    }
  }
}

Use Tushare_MCP MCP with multiple AI models

TypingMind connects MCP tools at the workspace level, so once Tushare_MCP is connected, you can use it with different AI models in TypingMind instead of setting it up separately for each model. You can run MCP locally on your device or connect to a remote MCP server URL.

Option 1: Use the local connector

Use this when the MCP server needs access to local files, apps, or private resources on your computer.

1

Open the MCP settings

In TypingMind, go to Settings, Advanced Settings, then Model Context Protocol and choose Setup Connector.

  1. Open TypingMind in your browser.
  2. Click the Settings icon.
  3. Go to Advanced Settings.
  4. Open the Model Context Protocol section.
  5. Click Setup Connector and choose This Device.
TypingMind MCP connector setup screen with This Device selected
2

Run the connector command

Choose This Device, copy the command from TypingMind, and run it in Terminal. Keep the process running while you use MCP.

  1. Copy the setup command shown by TypingMind.
  2. Open Terminal on macOS or Windows Terminal on Windows.
  3. Paste and run the command.
  4. Approve the package install if Terminal asks you to proceed.
  5. Keep the Terminal window running while using MCP tools.
3

Add Tushare_MCP as a server

When the connector status is Ready, click Edit Servers and paste the MCP server configuration.

  1. Wait until the connector status shows Ready.
  2. Click Edit Servers.
  3. Paste the Tushare_MCP MCP server configuration.
  4. Save the server list.
  5. Refresh if you want to confirm the connector is still ready.
TypingMind MCP settings showing active server and Edit Servers button
{
  "mcpServers": {
    "buuzzy-tushare_mcp": {
      "command": "npx",
      "args": [
        "-y",
        "tushare_MCP"
      ]
    }
  }
}
4

Use it across models

Save the server list, open Plugins, enable the Tushare_MCP MCP tools, then select any supported AI model in TypingMind and use the tools in chat or assign them to an AI agent.

  1. Open the Plugins page in TypingMind.
  2. Enable the Tushare_MCP MCP tools.
  3. Start a chat and choose the AI model you want to use.
  4. Use the MCP tools in chat or assign them to an AI agent.
  5. Switch to another AI model whenever needed without reconnecting MCP.
TypingMind chat using enabled MCP tools with a selected AI model
Can you use Tushare_MCP to help me with this task?
Tushare_MCP
Sure. I read it.
Here is what I found using Tushare_MCP.

Option 2: Add an MCP server URL

Use this when Tushare_MCP is already hosted remotely or your team wants one shared connector that multiple users can access.

1

Open MCP connectors

In TypingMind, go to Plugins, open MCP connectors, then choose Add URL.

  1. Open TypingMind in your browser.
  2. Go to Plugins.
  3. Open MCP connectors.
  4. Click Add URL.
TypingMind Add Custom MCP Server URL form
2

Paste the server URL

Enter your server URL in the Server URL field. Add a connection name, description, icon, custom HTTP headers, or OAuth client settings if the server requires them.

  1. Paste your server URL into the Server URL field.
  2. Enter a connection name for Tushare_MCP.
  3. Add a description and icon if you want it to be easier to identify.
  4. Add custom HTTP headers or OAuth client details if the server requires authentication.
3

Create the connection

Click Create connection, then return to the Plugins list and confirm the new MCP connection is active.

  1. Click Create connection.
  2. Return to the MCP connectors list.
  3. Confirm the Tushare_MCP connection appears as active.
  4. Refresh the plugin list if the connection does not appear immediately.
4

Switch models without reconnecting

Start a chat with your preferred model, enable the Tushare_MCP tools from Plugins, and switch to another model whenever needed. The MCP connection stays available to the TypingMind workspace.

  1. Start a new chat in TypingMind.
  2. Select the AI model you want to use.
  3. Enable the Tushare_MCP tools from Plugins.
  4. Ask the model to use the tool when needed.
  5. Switch to another AI model and reuse the same MCP connection.
TypingMind chat using enabled MCP tools with a selected AI model
Can you use Tushare_MCP to help me with this task?
Tushare_MCP
Sure. I read it.
Here is what I found using Tushare_MCP.

Frequently asked questions

What is the Tushare_MCP MCP server used for?

Tushare_MCP is an MCP server that lets compatible AI clients connect to external tools and context. In TypingMind, you can add this MCP server once and make its tools available in your AI workspace.

Can I use Tushare_MCP MCP with multiple AI models in TypingMind?

Yes. TypingMind connects MCP tools at the workspace level, so you can use Tushare_MCP with different AI models such as Claude, ChatGPT, Gemini, or other models you have configured in TypingMind without setting up the MCP server separately for each model.

Why use Tushare_MCP MCP with TypingMind?

TypingMind is one of the best frontends for LLM chat because it brings multiple AI models, prompts, plugins, AI agents, API keys, and MCP tools into one workspace. With Tushare_MCP connected, you can use its MCP tools across your preferred models while keeping your chat workflow organized in TypingMind.

How do I connect Tushare_MCP MCP to TypingMind?

Tushare_MCP can be connected in TypingMind with the local MCP connector or by adding a remote MCP server URL. Use the local connector when the server needs access to files, apps, or private resources on your device, and use a server URL when the MCP server is hosted remotely.

What tools does Tushare_MCP MCP provide in TypingMind?

Tushare_MCP exposes MCP capabilities that can be enabled from the TypingMind Plugins page and used in chat or assigned to AI agents.

Do I need to share my API keys with TypingMind to use Tushare_MCP MCP?

No. TypingMind is local-first and lets you keep your model providers, API keys, prompts, and MCP configuration under your control. If Tushare_MCP requires authentication, add the required headers, OAuth settings, or local configuration for that MCP server when you create the connection.

Related MCP Servers

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇