> 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/llamaindex-ji-cheng.md).

# LlamaIndex 集成

将 Thordata MCP Server 连接到 LlamaIndex Agent，用于实时网页搜索、抓取、结构化数据获取和 RAG 工作流。

将LlamaIndex代理连接到ThorData MCP服务器，即可将实时网络搜索、抓取和结构化数据检索添加到您的RAG和索引管ThorData MCP服务器，即可将实时网络搜索、抓取和结构化数据检索添加到您的RAG和索引管道中。

**托管 MCP**

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

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

{% step %}
**安装LlamaIndex MCP工具包**

```
pip install llama-index-tools-mcp
```

{% endstep %}

{% step %}
**配置您的MCP服务器**

```
import asyncio
from llama_index.tools.mcp import BasicMCPClient

async def main():
http_client = BasicMCPClient("https://mcp.thordata.com/API_TOKEN/mcp")

# List tools
tools = await http_client.list_tools()
print("Tools:", tools)

# Call a tool
result = await http_client.call_tool("scrape_as_markdown", {"url":"https://docs.llamaindex.ai/en/stable/examples/tools/mcp/"})
print("Result:", result)

asyncio.run(main())

```

{% endstep %}

{% step %}
**测试一下是否有效**

* 使用手动工具运行您的LlamaIndex脚本
* 你应该能在Markdown中看到请求的URL
  {% endstep %}

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

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