> For the complete documentation index, see [llms.txt](https://doc.thordata.com/doc/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://doc.thordata.com/doc/scraping/serp-api/integration/mcp-integration/crewai-integration.md).

# CrewAI Integration

Connect CrewAI multi-agent teams to Thordata MCP Server using hosted or self-hosted modes for real-time web search and structured data tasks.

Integrate Thordata MCP Server with CrewAI to give AI agents access to real-time SERP data and structured search results.

Connect your CrewAI multi-agent team to the ThorData MCP server to access real-time web data using either a hosted endpoint or a self-hosted mode.

#### Hosted MCP

{% stepper %}
{% step %}
**Get your API token**

* Go to [SERP API-API Token](https://dashboard.thordata.com/serp-api/get-started) to create an API Token;
* Copy your API Token (format as: `sk_7qBRe***************************`）
  {% endstep %}

{% step %}
**Configure your MCP server**

```
from crewai import Agent, Task, Crew
from crewai_tools import MCPServerAdapter
import os


server_params = {
    "url": "https://mcp.thordata.net/API_TOKEN/mcp",
    "transport": "http"
}

try:
    with MCPServerAdapter(server_params) as mcp_tools:
        print(f"Available tools: {[tool.name for tool in mcp_tools]}")
        
        my_agent = Agent(
            role="Web Scraping Specialist",
            goal="Extract data from websites using ThorData tools",
            backstory="I am an expert at web scraping and data extraction using MCP tools.",
            tools=mcp_tools,
            verbose=True,
            llm="gpt-4o-mini",
        )
        
        task = Task(
            description="Search for flights from New York to San Francisco and provide a summary of what you found. Use the search_engine tool to find flight information and return the results in a clear format.",
            expected_output="A clear summary of available flights from New York to San Francisco, including key details like airlines, times, and prices if available.",
            agent=my_agent
        )
        
        crew = Crew(
            agents=[my_agent],
            tasks=[task],
            verbose=True
        )
        
        result = crew.kickoff()
        print("\n=== RESULT ===")
        print(result)
        
except Exception as e:
    print(f"Error connecting to MCP server: {e}")
```

{% endstep %}

{% step %}
**Testing to see if it works.**

* Run the CrewAI script and execute the flight search task.
* The agent will use the ThorData tool to search for flight information.
* You should see results containing flight details.
  {% endstep %}

{% step %}
**Monitor usage**

View your API usage in the [ThorData SERP API usage logs](https://dashboard.thordata.com/serp-api/get-started).
{% endstep %}
{% endstepper %}
