> 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/zh/pa-qu/serp-api/ji-cheng/mcp-ji-cheng/crewai-ji-cheng.md).

# CrewAI 集成

使用托管或自托管模式将 CrewAI 多 Agent 团队连接到 Thordata MCP Server，以执行实时网页搜索和结构化数据任务。

將CrewAI多智能體團隊連接到ThorData MCP服務器，可以使用託管端點或自託管模式進行實时Web數據訪問。

**託管 MCP**

{% stepper %}
{% step %}
**獲取您的 API 令牌**

* 前往 [SERP API-API Token](https://dashboard.thordata.com/serp-api/get-started) 創建API Token
* 複製您的API Token（格式如下：`sk_7qBRe***************************`）
  {% endstep %}

{% step %}
**配寘您的 MCP 服務器**

```
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 %}
**測試一下是否有效**

* 運行CrewAI腳本並執行航班搜索任務
* 代理將使用ThorData工具搜索航班信息
* 您應該會看到包含班機詳情的結果。
  {% endstep %}

{% step %}
**監控使用情况**

在 ThorData [**SERP API-使用記錄**](https://dashboard.thordata.com/serp-api/get-started) 中查看您的 API 使用情况。
{% endstep %}
{% endstepper %}
