semvec/pypi-packages huggingface dataset:
iflow-mcp_digital-duck-st_rag_mcp 0.1.1
RAG MCP Server with calculator, trigonometric, and stock quote tools
Requires Python: >=3.11

# RAG MCP

The RAG system is particularly well-designed, using sentence transformers to build rich contextual embeddings and performing semantic search to find the most relevant tools for each query. This makes the system much more robust than traditional keyword-based approaches.

## What is [MCP](https://modelcontextprotocol.io/introduction)

MCP stands for Model Context protocol, it helps provide contexts to LLM model for tool-use.

![MCP Arch](./docs/mcp-arch.png)


## Architecture Diagram 

MCP with RAG

![RAG MCP Arch](./docs/st_rag_mcp-arch.png)


The Mermaid diagram illustrates:

- **7 Distinct Layers** with color coding for easy understanding
- **Complete Data Flow** from user input through RAG processing to tool execution
- **Decision Tree Logic** showing how queries are routed through different parsing modes
- **RAG Integration** highlighting how semantic search enhances tool selection
- **Multi-LLM Support** showing integration with Google, OpenAI, and Anthropic
- **MCP Server Integration** with tool discovery and execution
- **Data Persistence** including SQLite storage and caching mechanisms

## Key Features

![RAG MCP UI](./docs/st_rag_mcp_ui.png)

1. **Intelligent Tool Selection** using RAG to find relevant tools dynamically
2. **Flexible Parsing Strategy** with fallback mechanisms (RAG → LLM → Rule-based)
3. **Comprehensive Logging** for debugging and performance analysis
4. **Caching Strategy** for efficient server discovery
5. **Multi-Provider LLM Support** for flexibility and redundancy

## Setup
```bash
# create a virtual environment
conda create -n mcp
conda activate mcp

# obtain source code
git clone https://github.com/digital-duck/st_rag_mcp.git
cd st_rag_mcp
pip install -r requirements.txt

# open 1st terminal
cd src
python mcp_server.py

# in 2nd terminal
conda activate mcp
cd src
streamlit run mcp_client.py
```

## Demo Video
- [MCP + RAG](https://youtu.be/K2jgrMsgZxA)


## References

- https://www.anthropic.com/news/integrations
- [RAG-MCP: Mitigating Prompt Bloat in LLM Tool Selection via Retrieval-Augmented Generation](https://arxiv.org/abs/2505.03275)
- [ALITA: GENERALIST AGENT ENABLING SCALABLE AGENTIC REASONING WITH MINIMAL PREDEFINITION AND MAXIMAL SELF-EVOLUTION](https://arxiv.org/abs/2505.20286)
- [MCP - RAG & Self-Evolve Agent](https://youtu.be/ZtwN79n9dRE?si=5GYFUrX7INMxhUNM)
akshare-proxy-patch 0.2.7
针对 AkShare 和 efinance 的底层补丁，自动为东财等接口注入代理认证头，从而避免 `stock_zh_a_spot_em` 等方法报错。
Requires Python: >=3.6

# AkShare Proxy Patch
针对 akshare 和 efinance 的插件补丁，自动为东财接口注入代理认证头，从而避免`akshare: stock_zh_a_spot_em`、`efinance: get_realtime_quotes` 等东财 eastmoney 接口报错问题。

## 安装

1. 将官方 [akshare](https://github.com/akfamily/akshare) 或 [efinance](https://github.com/Micro-sheep/efinance) 升级到最新

```
# akshare 用户
pip install --upgrade akshare

# efinance 用户
pip install --upgrade efinance
```

2. 安装最新版本的 `akshare-proxy-patch`
```
pip install akshare-proxy-patch==0.2.7
```

最好默认用国外源，国内源不是最新的，可能没更新

## 使用方法

1. `akshare` 和 `efinance` 使用方式一致，在文件顶部添加如下代码
```
# 文件顶部添加
import akshare_proxy_patch

# 参数1: AUTH_IP
# 参数2: AUTH_TOKEN，默认为空
# 参数3: retry 重试次数，默认30
akshare_proxy_patch.install_patch("101.201.173.125", "", 30)

# 你的正常业务代码保持不变

# 假如使用akshare
import akshare as ak
df = ak.stock_zh_a_spot_em()

# 假如使用 efinance
import efinance as ef
ef.stock.get_realtime_quotes()
```

## 目前Hook的接口域名清单 
- fund.eastmoney.com
- push2.eastmoney.com
- push2his.eastmoney.com

## 使用问题交流群

如遇到部分接口报错，可进群交流：

![8jmzvNOjKWFzwNUDW0Xiytcpfr50uMr5.webp](https://cdn.nodeimage.com/i/8jmzvNOjKWFzwNUDW0Xiytcpfr50uMr5.webp)