This project is a modular backend framework designed to handle intelligent content extraction and question answering using Large Language Models (LLMs) and a two-step MCP (Model Context Protocol) tool-based pipeline.
This project enables users to ask questions on any topic. Instead of relying solely on an LLM’s static knowledge, the system dynamically scrapes relevant web content, processes it using specialized tools (MCP), and passes the results back to the LLM for a more accurate and grounded response.
- Tool-driven LLM architecture using OpenAI or Groq LLMs
- Web scraping through a two-step process (via Firecrawl API or equivalent)
- Modular tool system for easy extensibility
- SSE-based communication between FastAPI backend and MCP service
- Dockerized setup with Docker Compose for seamless development
- User Query: A user sends a question to the FastAPI backend.
- LLM Decision: The LLM evaluates the query and determines if a tool is needed.
- MCP Tool Execution:
- If needed, the tool is invoked via an SSE (Server-Sent Events) channel from the MCP server.
- The tool processes the request (e.g., crawling the web or extracting in-depth internal links).
- LLM Response:
- The tool’s output is returned to the LLM.
- The LLM integrates this result into the final response and returns it to the user.
noble_backend/
│
├── routes/
│ ├── doitr/
│ │ ├── client.py
│ │ └── config.py
│ ├── MCP/
│ │ ├── crawler.py
│ │ ├── crawler2.py
│ │ └── main.py # FastMCP server
│ ├── utils/
│ │ ├── logger.py
│ │ └── OpenAI.py
│ ├── client.py # SSE client for FastAPI to MCP connection
│ ├── web_search.py # Tool handler
│
├── main.py # FastAPI server entry
├── Dockerfile
├── docker-compose.yml
├── pyproject.toml
├── .env
└── README.mdEnsure you have the following installed:
- Docker
- Docker Compose
- A
.envfile with required secrets (OpenAI/Groq keys, Firecrawl key, etc.)
OPENAI_API_KEY=your_openai_key
FIRECRAWL_API_KEY=your_firecrawl_key
SERPER_API_KEY=your_serperapi_keyTo start the backend and MCP servers, run:
docker-compose up --buildFirst navigate to routes\MCP then
python main.pyThe above command runs the MCp server
for starting the fastapi server navigate to nobel_backend
uvicorn main:app --reloadThe above command starts the fastapi server
- ✅ Start the FastMCP service on port
3001 - ✅ Start the FastAPI backend service on port
8000
- FastAPI Backend: http://localhost:8000
- MCP Server (SSE Endpoint): http://localhost:3001/sse
- 🌀 FastAPI uses a lifespan hook to initialize the
MCPClient. - 🔗
MCPClientconnects to the MCP server at startup and fetches available tools. - 🧩 Tools are modular and easy to register or extend.
- 🔄 Communication between FastAPI and MCP server happens via SSE (Server-Sent Events) for real-time processing.
Question: "Explain Quantum Computing in simple terms with examples from recent articles"
- 🧠 LLM decides a web search tool is required.
- 🕸️
crawler.pyperforms top-level scraping of relevant links and summaries. - 🔍
crawler2.pyfetches deeper in-depth data from the internal links. - 📤 The results are fed back to the LLM.
- 🧾 LLM constructs a well-grounded, real-time response using fresh data.
| Tech | Usage |
|---|---|
| FastAPI | Main backend server |
| Python Asyncio | Concurrency for SSE + tool execution |
| Docker | Containerization for consistent deployment |
| SSE | Real-time FastAPI ↔ MCP server communication |
| LLMs | OpenAI / Groq via langchain_groq |
| Firecrawl | Web crawling API for scraping and retrieval |
