This is an intelligent multi-agent system that combines two specialized AI agents to provide comprehensive, well-researched responses to your queries. The system uses LangGraph for orchestration and MCP (Model Context Protocol) to connect with Firecrawl's web scraping capabilities.
The system operates through a sequential two-agent workflow:
🔍 Researcher Agent: When you ask a question, the Researcher Agent springs into action first. It uses Firecrawl tools (search, scrape, and crawl) to gather information from the web. This agent is configured with a temperature of 0 to ensure factual, precise research. It searches multiple sources, extracts key facts, and compiles comprehensive data about your query.
✍️ Writer Agent: Once the research is complete, the Writer Agent takes over. It receives all the research data collected by the Researcher and transforms it into a polished, engaging, and well-structured response. This agent uses a higher temperature (0.7) to be more creative and articulate in its writing style.
📝 Final Output: The system delivers a comprehensive answer that combines thorough web research with professional writing quality.
Example Flow:
Your Question → Researcher (gathers web data) → Writer (crafts response) → Final Answer
You need three API keys to run this system:
Groq API Key (Free tier available)
Firecrawl API Key (Required for web scraping)
Node.js & NPM (Required)
Install all required Python packages using pip:
pip install mcp pip install langchain-mcp-adapters pip install langgraph pip install langchain-groq pip install langchain-core pip install python-dotenv pip install pydantic
Or use a single command:
pip install mcp langchain-mcp-adapters langgraph langchain-groq langchain-core python-dotenv pydantic
The Firecrawl MCP server will be automatically installed when first run via:
npx firecrawl-mcp
Create a .env file in your project directory with your API keys:
GROQ_API_KEY=your_groq_api_key_here FIRECRAWL_API_KEY=your_firecrawl_api_key_here
Important: Never share or commit your .env file to version control!
Run the pip install command mentioned above to install all Python packages.
Open terminal/command prompt and check:
node --version npm --version
If both commands return version numbers, you're good to go!
Save the provided Python code to a file, for example: multi_agent_system.py
Open your terminal/command prompt in the project directory and run:
python multi_agent_system.py
Once running, you'll see:
============================================================
🤖 MULTI-AGENT SYSTEM INITIALIZED
============================================================
Agent 1: 🔍 RESEARCHER (Uses Firecrawl tools)
Agent 2: ✍️  WRITER (Synthesizes research)
============================================================
Available tools for Researcher: ['firecrawl_search', 'firecrawl_scrape', 'firecrawl_crawl']
------------------------------------------------------------
👤 You: 
Now you can type your questions!
👤 You: What are the latest trends in AI agents for 2024?
============================================================
🚀 MULTI-AGENT WORKFLOW STARTED
============================================================
🔍 [RESEARCHER AGENT] Working...
   (Searches the web, gathers data from multiple sources)
✍️  [WRITER AGENT] Working...
   (Synthesizes research into polished content)
============================================================
📝 FINAL OUTPUT
============================================================
Based on current research, AI agents in 2024 are experiencing
several breakthrough trends...
(comprehensive, well-written response)
Type any of these commands:
quitexitqError: "insufficient_quota"
Error: "tool call validation failed"
Error: "command not found: npx"
Error: "FIRECRAWL_API_KEY not found"
Slow Response Times
✅ Sequential Multi-Agent Workflow: Automatic coordination between Researcher and Writer agents
✅ Real-time Web Research: Uses Firecrawl to search, scrape, and crawl websites
✅ Intelligent Tool Selection: Researcher automatically chooses the best Firecrawl tool
✅ Quality Writing: Writer agent transforms raw data into polished responses
✅ Visual Feedback: Clear indicators showing which agent is currently working
✅ Error Handling: Graceful error messages if something goes wrong
✅ Conversation Loop: Ask multiple questions in one session
Framework: LangGraph (state machine for multi-agent orchestration)
LLM Provider: Groq (llama-3.3-70b-versatile model)
Tool Integration: MCP (Model Context Protocol) for Firecrawl
State Management: Custom state graph with message passing between agents
Async Support: Full asynchronous execution for better performance
You can easily modify the system:
If you encounter issues:
.env fileThis multi-agent system is built using open-source libraries and is free to use for personal and commercial projects. Ensure you comply with the terms of service for Groq and Firecrawl APIs.