CrewAI

CrewAI logo

Framework for orchestrating AI agent teams. Equip your CrewAI agents with Scrapfly web scraping capabilities for autonomous data collection and research tasks.

AI Agent Framework Python Official Website

Prerequisites

Before getting started, make sure you have the following:

  • Python 3.10+ installed
  • crewai and crewai-tools packages installed
  • Your Scrapfly API key (only if not using OAuth2)

Setup Instructions

CrewAI supports MCP tools through the tools integration. Follow these steps to equip your agent crew with Scrapfly capabilities.

  1. Install Required Packages

    Install CrewAI and the tools package with MCP support:

    Tip: Virtual Environment

    Use a virtual environment to manage dependencies:

  2. Initialize Scrapfly MCP Tools

    Select your preferred authentication method:

    How it works: Your application displays an OAuth2 URL in the console. Open it in your browser to authorize - happens once, then managed automatically. See project-scoped setup for team collaboration.
    Sign up for free to get your API key.
  3. Create Agents with Scrapfly Tools

    Build a CrewAI agent equipped with web scraping capabilities:

    Pro Tip: The agent will automatically call scraping_instruction_enhanced to get required parameters before scraping!
  4. Build a Multi-Agent Crew

    Create a team of agents that collaborate on web scraping and data analysis:

Example Prompts

Competitive Intelligence Crew
Multi-agent team scraping competitor websites, analyzing pricing, and generating reports
Content Aggregation Workflow
Agents scraping news sites, summarizing articles, and categorizing content
Market Research Team
Crew collecting product data, customer reviews, and market trends from multiple sources
Research Assistant Crew
Agents scraping academic papers, extracting citations, and building knowledge graphs

Troubleshooting

Problem: ModuleNotFoundError: No module named 'crewai_tools'

Solution:

  • Install the package: pip install crewai-tools
  • Verify Python environment: which python
  • Try upgrading: pip install --upgrade crewai crewai-tools
  • Check Python version is 3.10+: python --version

Problem: MCPTool cannot execute npx command

Solution:

  • Ensure Node.js 18+ is installed: node --version
  • Verify npx is in PATH: npx --version
  • Restart terminal after installing Node.js
  • Try full path: command="/usr/local/bin/npx"

Problem: OAuth2 browser window cannot open in server/CI environment

Solution:

  • Use API key authentication for production deployments
  • Store API key in environment variable: SCRAPFLY_API_KEY
  • Load from environment: args=["mcp-remote", f"https://mcp.scrapfly.io/mcp?key={os.getenv('SCRAPFLY_API_KEY')}"]

Problem: Agent does not call Scrapfly tools when assigned scraping tasks

Solution:

  • Verify tools loaded: print([tool.name for tool in scrapfly_tools])
  • Check agent has tools assigned: tools=scrapfly_tools in Agent creation
  • Use explicit task descriptions mentioning "scrape" or "web data"
  • Enable verbose mode: verbose=True to see agent reasoning

Problem: Crew execution hangs or times out during scraping

Solution:

  • Check network connectivity to https://mcp.scrapfly.io/mcp
  • Verify target URLs are accessible
  • Increase task timeout if scraping large pages
  • Enable verbose mode to see where execution stalls

Next Steps

Summary