
与MCP服务器的代理RAG
概览
是一个强大的项目,集成了MCP(模型上下文协议)服务器和客户端,用于构建(检索增强生成)应用。 这种配置为您的RAG系统配备了先进工具,例如: 服务器托管这些智能工具,而客户端则展示如何无缝连接和使用它们。 服务器由 mcp 库中的 FastMCP 类驱动,提供了以下实用工具: 客户端演示了如何连接和交互MCP服务器: * 从MCP库建立与ClientSession的连接 * 列出所有可用的服务器工具 * 调用任何带有自定义参数的工具 * 利用MCP工具进行流程查询 * Python 3.9 或更高版本 * Openai Python 包 * mcp 库 * python-dotenv 用于环境变量管理 1. 创建一个 .env 文件(使用 .env.sample 作为模板) 2.将 OpenAI 模型设置为 .env 格式:
概述(AI 翻译)
✨ 概述
Agentic RAG with MCP Server 是一个强大的项目,集成了 MCP(模型上下文协议)服务器和客户端,用于构建 Agentic RAG(检索增强生成)应用。
这种配置为您的RAG系统配备了先进工具,例如:
- 🕵️ ♂️ 实体提取
- 🔍 查询精细化
- ✅ 相关性检查
服务器托管这些智能工具,而客户端则展示如何无缝连接和使用它们。
🖥️ 服务器 — server.py
服务器由 mcp 库中的 FastMCP 类驱动,展示了以下便捷工具:
| 工具名称 | 说明 | 图标 |
|---|---|---|
get_time_with_prefix |
返回当前日期和时间 | ⏰ |
extract_entities_tool |
使用 OpenAI 从查询中提取实体——增强文档检索相关性 | 🧠 |
refine_query_tool |
通过 OpenAI 驱动的优化 提升用户查询质量 | ✨ |
check_relevance |
通过LLM检查块相关性过滤掉无关内容 | ✅ |
本页由 AI 翻译,技术细节请以原文为准。
README
🚀 Agentic RAG with MCP Server 
✨ Overview
Agentic RAG with MCP Server is a powerful project that brings together an MCP (Model Context Protocol) server and client for building Agentic RAG (Retrieval-Augmented Generation) applications.
This setup empowers your RAG system with advanced tools such as:
- 🕵️♂️ Entity Extraction
- 🔍 Query Refinement
- ✅ Relevance Checking
The server hosts these intelligent tools, while the client shows how to seamlessly connect and utilize them.
🖥️ Server — server.py
Powered by the FastMCP class from the mcp library, the server exposes these handy tools:
| Tool Name | Description | Icon |
|---|---|---|
get_time_with_prefix |
Returns the current date & time | ⏰ |
extract_entities_tool |
Uses OpenAI to extract entities from a query — enhancing document retrieval relevance | 🧠 |
refine_query_tool |
Improves the quality of user queries with OpenAI-powered refinement | ✨ |
check_relevance |
Filters out irrelevant content by checking chunk relevance with an LLM | ✅ |
🤝 Client — mcp-client.py
The client demonstrates how to connect and interact with the MCP server:
- Establish a connection with
ClientSessionfrom themcplibrary - List all available server tools
- Call any tool with custom arguments
- Process queries leveraging OpenAI or Gemini and MCP tools in tandem
⚙️ Requirements
- Python 3.9 or higher
openaiPython packagemcplibrarypython-dotenvfor environment variable management
🛠️ Installation Guide
# Step 1: Clone the repository
git clone https://github.com/ashishpatel26/Agentic-RAG-with-MCP-Server.git
# Step 2: Navigate into the project directory
cd Agentic-RAG-with-MCP-Serve
# Step 3: Install dependencies
pip install -r requirements.txt
🔐 Configuration
- Create a
.envfile (use.env.sampleas a template) - Set your OpenAI model in
.env:
OPENAI_MODEL_NAME="your-model-name-here"
GEMINI_API_KEY="your-model-name-here"
🚀 How to Use
- Start the MCP server:
python server.py
- Run the MCP client:
python mcp-client.py
📜 License
This project is licensed under the MIT License.
Thanks for Reading 🙏
安装
This server does not publish a one-line install command.
Open the repository installation guide 新手?先看 mcpskill.org 教程 →