tsrs-mcp-server

tsrs-mcp-server

By hanxuanliang GitHub

tushare rust mcp server

poem tushare
Overview

What is tsrs-mcp-server?

The tsrs-mcp-server is a Rust-based data server that implements the Model Context Protocol (MCP) to provide a series of stock market data query interfaces using the TuShare API.

How to use tsrs-mcp-server?

To use the tsrs-mcp-server, you need to set up your TuShare API token in the .env file and then build and run the server using Rust and Cargo.

Key features of tsrs-mcp-server?

  • Provides multiple tools for querying stock market data.
  • Supports various data retrieval functions such as daily stock limits, hot stock rankings, and minute-level trading data.
  • Easy integration with TuShare API for accessing financial data.

Use cases of tsrs-mcp-server?

  1. Retrieving daily stock limit data for analysis.
  2. Accessing hot stock rankings for investment decisions.
  3. Analyzing minute-level trading data for high-frequency trading strategies.

FAQ from tsrs-mcp-server?

  • How do I set up the TuShare API token?

Copy the .env.example file to .env and set your TuShare token in the .env file.

  • What programming language is used for this project?

The project is implemented in Rust.

  • Is there any documentation available?

Yes, detailed documentation is provided in the project repository.

Content

tsrs-mcp-server

这是一个基于 Model Context Protocol (MCP) 的TuShare数据服务器,提供了一系列股票市场数据查询接口。

项目简介

本项目是一个Rust实现的MCP服务器,封装了TuShare的API接口,提供了多个股票市场数据查询工具。项目使用了以下主要技术:

  • Rust
  • Model Context Protocol (MCP)
  • Poem MCP Server
  • TuShare API
  • 过程宏 (Procedural Macros)

功能特性

项目提供了以下MCP工具:

工具名称功能描述主要参数返回数据
limit_step获取每天连板个数晋级的股票trade_date, start_date, end_date, nums股票代码、名称、交易日期、连板次数
ths_hot获取同花顺App热榜数据trade_date股票信息、排名、热度、概念等
kpl_list获取涨跌停板数据tag, start_date, end_date涨跌停详细信息、成交数据等
kpl_concept获取开盘啦概念题材列表trade_date题材代码、名称、涨停数量等
kpl_concept_cons获取开盘啦概念题材的成分股trade_date, ts_code题材成分股详细信息
limit_cpt_list获取每天涨停股票最多的概念板块trade_date, start_date, end_date板块代码、名称、连板数据等
moneyflow_ths获取同花顺个股资金流向数据ts_code, trade_date, start_date, end_date资金流向详细数据
moneyflow_cnt_ths获取同花顺概念板块每日资金流向trade_date, start_date, end_date板块资金流向数据
stk_mins获取A股分钟数据ts_code, freq, start_date, end_date分钟级别的交易数据

项目结构

项目包含以下主要组件:

  • ts-derive: 提供用于TuShare API的过程宏实现
  • ts-model: 包含数据模型
  • src: 主程序实现

环境配置

在运行之前,需要设置TuShare的API token:

  • 复制 .env.example.env
  • .env 文件中设置你的TuShare token:
TUSHARE_TOKEN=your_token_here

构建

前提条件:安装 Rust 和 Cargo。

cargo build --release

./target/release/tsrs-mcp-server

运行

你可以在release中找到对应平台下的编译产物, 例如 tsrs-mcp-server-<tag>-aarch64-apple-darwin.tar.gz

运行方式如下图配置(仅展示在chatwise的配置):

chatwise-config

鸣谢

感谢以下项目和库, 尤其是 poem-mcpserver 对MCP编写的极强便捷性支持, 没有它, 本项目没有如此简便的实现方式。 同时感谢 TuShare API 提供的数据接口。 最后要感谢 rust, 没有 procedural macros, 本项目的模版实现将变得异常机械化。

License

本项目采用 MIT 许可证。详见 LICENSE 文件。

No tools information available.
No content found.