Deep Research Agent MCP Server
An AI-powered deep research agent that automates the full research pipeline from web search to structured executive reports using a 4-tool pipeline (search, fetch, cluster, report).
README
๐ Deep Research Agent MCP Server
An AI-powered deep research agent built with Python, FastMCP, and Streamlit.
Search โ Fetch โ Cluster โ Report. Fully automated. Fully open source.
</div>
๐ Overview
Deep Research Agent is a Python MCP server that automates the full research pipeline from web search to a structured executive report in under 10 seconds. It uses a 4-tool pipeline, powered by the Tavily Search API for retrieval and a pure-Python TF-IDF + K-Means engine for semantic clustering. The frontend is a sleek Streamlit chat interface that shows every step live.
๐ก Built as a portfolio project demonstrating: FastMCP tool design, async web scraping, NLP clustering without heavy ML dependencies, and full-stack Python app architecture.
โจ Features
- ๐ Multi-angle web search: 3 query variations per topic for broader coverage
- ๐ Async URL fetching: parallel page retrieval with smart HTML cleaning
- ๐งน Text denoising: strips HTML entities, SVG labels, nav boilerplate, repeated patterns
- ๐ง Semantic clustering: pure-Python TF-IDF + K-Means, zero ML framework required
- ๐ท๏ธ Auto cluster labeling: 13 topic categories (Quantum, Biotech, Climate, AI, Policy...)
- ๐ Structured reports: markdown or JSON output with sources, keywords, evidence
- โฌ๏ธ One-click download: export
.mdreport directly from the UI - โก Fast: full pipeline typically completes in 6โ12 seconds
๐๏ธ Architecture
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Streamlit Frontend โ
โ app.py โ Chat UI โ
โ Live step cards ยท Download button โ
โโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ FastMCP Client (protocol-aware)
โโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ FastMCP Server (server.py) โ
โ โ
โ ๐ search_web ๐ fetch_and_chunk โ
โ Tavily API httpx + HTML parser โ
โ โ
โ ๐ง cluster_findings ๐ generate_report โ
โ TF-IDF + K-Means Markdown / JSON โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ ๏ธ Tech Stack
| Layer | Technology |
|---|---|
| ๐ Language | Python 3.12+ |
| ๐ MCP Framework | FastMCP 3.x |
| ๐ฅ๏ธ Frontend | Streamlit |
| ๐ Search | Tavily Search API |
| ๐ HTTP Client | httpx (async) |
| ๐ง Clustering | Pure-Python TF-IDF + K-Means |
| โ๏ธ Config | python-dotenv |
๐ Quick Start
1๏ธโฃ Clone the repository
git clone https://github.com/yourusername/deep-research-agent.git
cd deep-research-agent
2๏ธโฃ Install dependencies
pip install -r requirements.txt
3๏ธโฃ Configure environment
cp .env.example .env
Edit .env and add your Tavily API key:
TAVILY_API_KEY=tvly-your-key-here
MCP_HOST=localhost
MCP_PORT=8000
TAVILY_SEARCH_DEPTH=advanced
๐ Get a free Tavily API key at app.tavily.com
4๏ธโฃ Start the MCP server
# Terminal 1
python server.py
You should see:
๐ Deep Research Agent MCP Server
Host : localhost
Port : 8000
Tools: search_web, fetch_and_chunk, cluster_findings, generate_report
Tavily key: โ set
5๏ธโฃ Launch the Streamlit UI
# Terminal 2
streamlit run app.py
Open http://localhost:8501 and start researching! ๐
๐ง MCP Tools Reference
๐ search_web(query, max_results)
- Searches the web via Tavily API and returns ranked results with scores.
search_web(
query="AI energy crisis 2026",
max_results=8, # 1โ15
include_domains=None, # e.g. [".edu", ".gov"]
exclude_domains=None
)
๐ fetch_and_chunk(urls, chunk_size)
- Fetches pages asynchronously and splits content into overlapping text chunks.
fetch_and_chunk(
urls=["https://example.com/article"],
chunk_size=400, # words per chunk
chunk_overlap=50, # overlap between chunks
max_chunks_per_url=6
)
๐ง cluster_findings(chunks, n_clusters)
- Groups chunks into semantic themes using TF-IDF vectorization + K-Means clustering.
cluster_findings(
chunks=[...], # from fetch_and_chunk
n_clusters=4, # 2โ6 themes
top_terms_per_cluster=8
)
๐ generate_report(topic, clusters)
- Synthesizes all clusters into a structured research report.
generate_report(
topic="AI energy crisis 2026",
clusters=[...], # from cluster_findings
format="markdown", # or "json"
include_sources=True
)
๐ Research Pipeline
๐ User enters topic
โ
โผ
๐ search_web() ร 3 queries โโโโโโโโโโโบ 24 ranked sources
โ
โผ
๐ fetch_and_chunk() on top 5 URLs โโโโบ 20โ30 text chunks
โ
โผ
๐ง cluster_findings() โโโโโโโโโโโโโโโโโบ 4 semantic themes
โ
โผ
๐ generate_report() โโโโโโโโโโโโโโโโโโบ Structured .md report
โ
โผ
โฌ๏ธ Download / Display in UI
๐ Project Structure
deep-research-agent/
โ
โโโ ๐ server.py # FastMCP server โ all 4 tools
โโโ ๐ฅ๏ธ app.py # Streamlit frontend
โโโ ๐ requirements.txt # Python dependencies
โโโ ๐ .env.example # Environment variable template
โโโ ๐ README.md # This file
โ๏ธ Configuration
| Variable | Default | Description |
|---|---|---|
TAVILY_API_KEY |
(required) | Your Tavily search API key |
MCP_HOST |
localhost |
MCP server host |
MCP_PORT |
8000 |
MCP server port |
TAVILY_SEARCH_DEPTH |
advanced |
basic (faster) or advanced (thorough) |
๐ค Contributing
- Contributions are welcome and appreciated! Here's how to get involved:
๐ Reporting Bugs
- Check the Issues page to see if it's already reported
- Open a new issue with:
- A clear title and description
- Steps to reproduce
- Expected vs actual behaviour
- Your Python version and OS
๐ก Suggesting Features
Open an issue with the enhancement label and describe:
- The problem you're trying to solve
- Your proposed solution
- Why would it benefit other users
๐ง Submitting Pull Requests
- Fork the repository
- Create a feature branch
git checkout -b feature/your-feature-name - Make your changes with clear, descriptive commits
git commit -m "feat: add BM25 ranking to cluster_findings" - Test your changes thoroughly
- Push to your fork
git push origin feature/your-feature-name - Open a Pull Request with a clear description of what you changed and why
๐ Code Style
- Follow PEP 8 for Python code
- Use type hints wherever possible
- Add docstrings to all new functions
- Keep functions focused โ one responsibility per function
๐ฑ Good First Issues
- Looking for a place to start? Check issues tagged
good first issue: - Adding more cluster label categories to
_infer_cluster_label() - Improving the HTML cleaning regex patterns
- Adding a progress bar to the Streamlit UI
- Supporting additional output formats (PDF, DOCX)
- Writing unit tests for the clustering functions
๐ License
MIT License
Copyright (c) 2026 Deep Research Agent Contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including, without limitation, the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT, OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
๐ Acknowledgements
- FastMCP โ Python MCP server framework
- Tavily โ AI-optimised search API
- Streamlit โ Python web app framework
- httpx โ Async HTTP client
<div align="center">
- Made with โค๏ธ and Python ยท Star โญ this repo if you found it useful!
</div>
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.