crew_research
README.md
# ๐ค MCP Multi-Agent Deep Researcher
[](https://python.org)
[](https://python-poetry.org/)
[](https://fastapi.tiangolo.com/)
[](https://ollama.ai/)
[](LICENSE)
A powerful multi-agent research system built on the **Model Context Protocol (MCP)**, using **CrewAI** for agent orchestration, **LinkUp** for deep web search, and **phi3** model (via Ollama) for local AI processing. Features both API access and a beautiful web interface for easy research tasks.
## ๐ Features
- ๐ง **Multi-Agent System**: Three specialized AI agents working together
- **Web Searcher**: Deep web search using LinkUp API
- **Research Analyst**: Information synthesis and verification
- **Technical Writer**: Clear, structured content creation
- ๐ **Beautiful Web Interface**: Modern, responsive frontend for easy interaction
- ๐ **API Access**: RESTful API with FastAPI and automatic documentation
- ๐ **Local AI Processing**: Uses Ollama with phi3 model - no external AI API needed
- ๐ก **MCP Protocol**: Full Model Context Protocol compliance for integration
- ๐ **One-Command Launch**: Start everything with a single command
## ๐ฏ Quick Start
**Get started in 3 simple steps:**
```bash
# 1. Clone the repository
git clone https://github.com/anubhav-77-dev/MCP-Multi-Agent-Deep-Researcher.git
cd MCP-Multi-Agent-Deep-Researcher
# 2. Run the setup script
python3 setup.py
# 3. Launch everything!
python3 launcher.py
```
That's it! The system will automatically open in your browser at `http://localhost:3000/frontend.html`
## ๐ธ Screenshots
### Web Interface

### API Documentation

## ๐๏ธ Architecture
## Architecture
The system implements a three-agent workflow:
1. **Web Searcher**: Uses LinkUp API to find relevant information from multiple sources
2. **Research Analyst**: Synthesizes and verifies the information, focusing on depth and clarity
3. **Technical Writer**: Produces a clear, comprehensive markdown answer
```mermaid
graph TD
A[Web Interface] --> B[FastAPI Backend]
B --> C[MCP Server]
C --> D[CrewAI Orchestrator]
D --> E[Web Searcher Agent]
D --> F[Research Analyst Agent]
D --> G[Technical Writer Agent]
E --> H[LinkUp API]
F --> I[Ollama + phi3]
G --> I
H --> J[Web Search Results]
I --> K[AI Analysis & Writing]
J --> F
K --> L[Final Research Output]
```
## ๐ Prerequisites
- **Python 3.10+**
- **[Poetry](https://python-poetry.org/)** for dependency management
- **[Ollama](https://ollama.ai/)** for local AI processing
- **LinkUp API Key** (get free tier at [LinkUp.so](https://linkup.so/))
## ๐ Installation & Setup
### Option 1: Automated Setup (Recommended)
```bash
# Clone the repository
git clone https://github.com/anubhav-77-dev/MCP-Multi-Agent-Deep-Researcher.git
cd MCP-Multi-Agent-Deep-Researcher
# Run automated setup (checks dependencies, installs packages, configures environment)
python3 setup.py
# Launch the application (starts both frontend and backend)
python3 launcher.py
```
### Option 2: Manual Setup
<details>
<summary>Click to expand manual setup instructions</summary>
#### 1. Install Dependencies
```bash
# Install Poetry (if not already installed)
curl -sSL https://install.python-poetry.org | python3 -
# Install project dependencies
poetry install
```
#### 2. Install & Configure Ollama
```bash
# Install Ollama (visit https://ollama.ai/ for OS-specific instructions)
# On macOS:
brew install ollama
# Start Ollama service
ollama serve
# Pull the phi3 model (in a new terminal)
ollama pull phi3:latest
# Verify installation
ollama list
```
#### 3. Configure Environment
```bash
# Copy environment template
cp .env.example .env
# Edit .env file and add your LinkUp API key
nano .env
```
Required environment variables:
```env
LINKUP_API_KEY=your_linkup_api_key_here
OLLAMA_BASE_URL=http://localhost:11434
MODEL_NAME=phi3:latest
```
#### 4. Start the Services
```bash
# Option A: Use the launcher (recommended)
python3 launcher.py
# Option B: Start services manually
# Terminal 1 - Backend API
poetry run python Multi-Agent-deep-researcher-mcp-windows-linux/http_server.py
# Terminal 2 - Frontend
python3 -m http.server 3000
# Terminal 3 - MCP Server (optional, for MCP client integration)
poetry run python Multi-Agent-deep-researcher-mcp-windows-linux/server.py
```
</details>
### ๐ Get Your LinkUp API Key
1. Visit [LinkUp.so](https://linkup.so/)
2. Sign up for a free account
3. Get your API key from the dashboard
4. Add it to your `.env` file
## ๐ฎ Usage
### Web Interface (Easiest)
1. **Launch the application**: `python3 launcher.py`
2. **Open your browser** to `http://localhost:3000/frontend.html` (opens automatically)
3. **Enter your research query** or try the example queries
4. **Choose your mode**:
- ๐ **Quick Search**: Fast web search with LinkUp API
- ๐ง **Full Research**: Complete multi-agent analysis workflow
5. **View results** with formatted output, copy/download options
### API Access
#### Quick Search
```bash
curl -X POST http://localhost:8080/search \
-H "Content-Type: application/json" \
-d '{"query": "latest AI trends 2024"}'
```
#### Full Research
```bash
curl -X POST http://localhost:8080/research \
-H "Content-Type: application/json" \
-d '{"query": "comprehensive analysis of quantum computing applications"}'
```
#### Health Check
```bash
curl http://localhost:8080/health
```
### MCP Client Integration
For integration with MCP-compatible clients, add this configuration:
```json
{
"mcpServers": {
"crew_research": {
"command": "poetry",
"args": ["run", "python", "Multi-Agent-deep-researcher-mcp-windows-linux/server.py"],
"env": {
"LINKUP_API_KEY": "your_linkup_api_key_here"
}
}
}
}
```
### Available Endpoints
| Endpoint | Method | Description |
|----------|--------|-------------|
| `/health` | GET | Health check |
| `/search` | POST | Quick web search |
| `/research` | POST | Full multi-agent research |
| `/docs` | GET | Interactive API documentation |
## ๐ Project Structure
```
MCP-Multi-Agent-Deep-Researcher/
โโโ ๐ launcher.py # Single-command launcher
โโโ ๐ frontend.html # Web interface
โโโ โ๏ธ setup.py # Automated setup script
โโโ ๐ start.sh # Shell launcher script
โโโ ๐ QUICKSTART.md # Quick start guide
โโโ ๐ง Makefile # Development commands
โโโ ๐ฆ pyproject.toml # Poetry dependencies
โโโ ๐ .env.example # Environment template
โโโ โ๏ธ mcp.config.json # MCP client configuration
โโโ Multi-Agent-deep-researcher-mcp-windows-linux/
โโโ ๐ฅ๏ธ server.py # MCP protocol server
โโโ ๐ http_server.py # FastAPI REST server
โโโ ๐งช test_research.py # Testing utilities
โโโ agents/ # Multi-agent system
โโโ ๐ค research_crew.py # CrewAI orchestration
โโโ tools/ # Agent tools
โโโ ๐ linkup_search.py # Web search integration
โโโ ๐ง ollama_tool.py # Local AI integration
```
## ๐ฏ Example Queries
Try these sample research queries:
### Quick Search Examples
- "What are the latest AI trends in 2024?"
- "Current developments in renewable energy"
- "Recent breakthroughs in quantum computing"
### Full Research Examples
- "Comprehensive analysis of the environmental impact of cryptocurrency mining"
- "How does quantum computing work and what are its real-world applications?"
- "The future of autonomous vehicles: technology, challenges, and timeline"
- "Impact of artificial intelligence on healthcare: opportunities and risks"
## Agentic Workflow
The system uses CrewAI to orchestrate three specialized agents:
### 1. Web Searcher Agent
- **Role**: Web Research Specialist
- **Goal**: Find comprehensive and relevant information using LinkUp API
- **Tools**: LinkUp Search Tool
- **Output**: Detailed summary of web search results with sources
### 2. Research Analyst Agent
- **Role**: Research Analyst
- **Goal**: Analyze and synthesize information to provide comprehensive insights
- **Input**: Web search results
- **Output**: Structured analysis with key insights and verified information
### 3. Technical Writer Agent
- **Role**: Technical Writer
- **Goal**: Create clear, comprehensive, and well-structured written content
- **Input**: Research analysis
- **Output**: Comprehensive, well-formatted markdown document
## Configuration
### Environment Variables
- `LINKUP_API_KEY`: Your LinkUp API key for web search functionality
- `OLLAMA_BASE_URL`: Base URL for Ollama API (default: http://localhost:11434)
- `MODEL_NAME`: Ollama model to use (default: phi3)
### Customizing Agents
You can customize the agents by modifying `agents/research_crew.py`:
- Adjust agent roles, goals, and backstories
- Modify task descriptions and expected outputs
- Add or remove tools for specific agents
- Change the process flow (sequential, hierarchical, etc.)
## ๐ Troubleshooting
### Common Issues & Solutions
<details>
<summary><strong>๐ซ "Address already in use" error</strong></summary>
```bash
# Kill existing processes
pkill -f "python.*http_server"
pkill -f "http.server"
# Or restart with different ports
python3 launcher.py
```
</details>
<details>
<summary><strong>๐ Ollama connection failed</strong></summary>
```bash
# Check if Ollama is running
ollama serve
# Verify model is available
ollama list
# Pull model if missing
ollama pull phi3:latest
# Check Ollama is accessible
curl http://localhost:11434/api/tags
```
</details>
<details>
<summary><strong>๐ LinkUp API errors</strong></summary>
1. Verify API key in `.env` file
2. Check LinkUp dashboard for usage limits
3. Test API key:
```bash
curl -H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"q": "test"}' \
https://api.linkup.so/v1/search
```
</details>
<details>
<summary><strong>๐งฉ Dependencies issues</strong></summary>
```bash
# Reinstall dependencies
poetry install --no-cache
# Or use pip fallback
pip install -r requirements.txt
# Check Python version
python3 --version # Should be 3.10+
```
</details>
<details>
<summary><strong>๐ CORS/Frontend issues</strong></summary>
- Make sure both servers are running
- Check browser console for errors
- Try accessing backend directly: `http://localhost:8080/health`
- Clear browser cache and reload
</details>
### Getting Help
1. **Check logs**: The launcher shows detailed logs for both servers
2. **Run diagnostics**: `python3 setup.py` to verify setup
3. **Test components**: `python3 simple_test.py` for individual tests
4. **Enable debug mode**: Set `logging.basicConfig(level=logging.DEBUG)` in server files
## ๐ ๏ธ Development
### Quick Commands
```bash
# Start everything
make start # or make launch, make demo
# Development setup
make dev-setup # Install deps + setup + verify
# Run tests
make test # Basic functionality test
make quick-test # Quick search test
# Maintenance
make clean # Clean cache files
make verify # Verify installation
```
### Adding Custom Agents
1. **Create new agent** in `agents/research_crew.py`:
```python
custom_agent = Agent(
role='Custom Specialist',
goal='Your specific goal',
backstory='Agent background',
tools=[your_tools]
)
```
2. **Add to crew workflow**:
```python
custom_task = Task(
description="Task description",
agent=custom_agent,
expected_output="Expected result format"
)
```
### Adding New Tools
1. **Create tool file** in `agents/tools/`:
```python
class CustomTool(BaseTool):
name = "Custom Tool"
description = "Tool description"
def _run(self, query: str) -> str:
# Tool implementation
return result
```
2. **Register with agents** in `research_crew.py`
### Environment Configuration
| Variable | Description | Default |
|----------|-------------|---------|
| `LINKUP_API_KEY` | LinkUp search API key | Required |
| `OLLAMA_BASE_URL` | Ollama server URL | `http://localhost:11434` |
| `MODEL_NAME` | Ollama model name | `phi3:latest` |
| `OPENAI_API_KEY` | Set to `ollama` for local use | `ollama` |
| `OPENAI_API_BASE` | Ollama OpenAI-compatible endpoint | `http://localhost:11434/v1` |
## ๐ค Contributing
We welcome contributions! Here's how to get started:
### Development Setup
```bash
# Fork and clone the repo
git clone https://github.com/anubhav-77-dev/MCP-Multi-Agent-Deep-Researcher.git
cd MCP-Multi-Agent-Deep-Researcher
# Install development dependencies
poetry install --with dev
# Run pre-commit setup
pre-commit install
```
### Contribution Guidelines
1. ๐ด Fork the repository
2. ๐ฟ Create a feature branch: `git checkout -b feature/amazing-feature`
3. โจ Make your changes with clear, commented code
4. ๐งช Add tests for new functionality
5. โ
Run tests: `make test`
6. ๐ Update documentation as needed
7. ๐ Submit a pull request
### Areas for Contribution
- ๐ง New agent tools and integrations
- ๐จ Frontend UI/UX improvements
- ๐ Documentation and examples
- ๐งช Test coverage expansion
- ๐ Bug fixes and performance improvements
- ๐ Internationalization
## ๐ Performance & Scaling
- **Quick Search**: ~2-5 seconds (LinkUp API dependent)
- **Full Research**: ~30-60 seconds (depends on query complexity)
- **Concurrent Users**: Supports multiple simultaneous requests
- **Memory Usage**: ~500MB-1GB (Ollama model dependent)
- **Disk Space**: ~3GB (including phi3 model)
## ๐ Security & Privacy
- โ
**Local AI Processing**: No data sent to external AI services
- โ
**API Key Security**: LinkUp API key stored locally only
- โ
**No Data Persistence**: Research queries not stored by default
- โ
**CORS Protection**: Configurable origin restrictions
- โ ๏ธ **Web Search**: Queries sent to LinkUp API (see their privacy policy)
## ๐ License
This project is licensed under the **MIT License** - see the [LICENSE](LICENSE) file for details.
## ๐ Acknowledgments
Built with amazing open-source technologies:
- ๐ค **[CrewAI](https://crewai.com/)** - Multi-agent orchestration framework
- ๐ **[LinkUp](https://linkup.so/)** - Deep web search API
- ๐ง **[Ollama](https://ollama.ai/)** - Local LLM serving platform
- โก **[FastAPI](https://fastapi.tiangolo.com/)** - Modern Python web framework
- ๐ญ **[Model Context Protocol](https://modelcontextprotocol.io/)** - AI integration standard
- ๐ฆ **[Poetry](https://python-poetry.org/)** - Python dependency management
## โญ Star History
[](https://star-history.com/#anubhav-77-dev/MCP-Multi-Agent-Deep-Researcher&Date)
---
<div align="center">
**Made with โค๏ธ for the AI research community**
[๐ Star this repo](https://github.com/anubhav-77-dev/MCP-Multi-Agent-Deep-Researcher) โข [๐ Report Bug](https://github.com/anubhav-77-dev/MCP-Multi-Agent-Deep-Researcher/issues) โข [๐ก Request Feature](https://github.com/anubhav-77-dev/MCP-Multi-Agent-Deep-Researcher/issues)
</div>