AA

abvijaykumar/agentic-rag-mcp

API 开发

本页由 AI 翻译,技术细节请以原文为准。 查看原文

5 stars 3 forks 质量 40 趋势 13

An intelligent RAG system that combines document search with web search using LLM-based tool calling.

概览

An intelligent RAG system that combines document search with web search using LLM-based tool calling. The system automatically decides when to search the web based on document context quality and question requirements. This project was built as part of the Blog Hands on — Agentic RAG (3/3) — Agentic Integrated with MCP Server You can read the other 2 parts here * Hands on — Agentic RAG (1/3) * Hands on — Agentic RAG (2/3) — Agentic ReRanking RAG - : LLM evaluates document context and decides when web search is needed - : Web search via Model Context Protocol servers - : Parallel retrieval with LLM-based ranking - : Prioritizes local documents, uses web as intelligent fallback 1. : Retrieves relevant chunks from ingested PDFs 2. : LLM receives document context via system prompt 3. : LLM decides whether to call search_web tool 4. : If needed, searches web via MCP server 5.

README

Agentic RAG with MCP Web Search

An intelligent RAG system that combines document search with web search using LLM-based tool calling. The system automatically decides when to search the web based on document context quality and question requirements.

This project was built as part of the Blog Hands on — Agentic RAG (3/3) — Agentic Integrated with MCP Server

You can read the other 2 parts here

Features

  • Smart Decision Making: LLM evaluates document context and decides when web search is needed
  • MCP Integration: Web search via Model Context Protocol servers
  • Multi-Candidate Retrieval: Parallel retrieval with LLM-based ranking
  • Document-First Approach: Prioritizes local documents, uses web as intelligent fallback

Quick Start

  1. Install dependencies:

    pip install -r requirements.txt
    
  2. Set environment variables:

    export OPENAI_API_KEY="your-openai-key"
    export MCP_ENDPOINT="http://localhost:8000"  # Optional
    

How It Works

  1. Document Search: Retrieves relevant chunks from ingested PDFs
  2. Context Evaluation: LLM receives document context via system prompt
  3. Tool Decision: LLM decides whether to call search_web tool
  4. Web Search: If needed, searches web via MCP server
  5. Answer Generation: Combines document and web contexts

Architecture

  • RAGOrchestrator: Main coordinator
  • WebSearchAgent: MCP server communication
  • RetrievalAgent: Multi-candidate document search
  • RankingAgent: LLM-based answer selection
  • Tool Calling: LLM decides when to search web

Read the blog for more details

Requirements

  • Python 3.8+
  • OpenAI API key
  • MCP server (optional, for web search)

License

MIT License

在 GitHub 查看完整 README

安装

This server does not publish a one-line install command.

Open the repository installation guide 新手?先看 mcpskill.org 教程 →