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

# LlamaIndex 集成

將LlamaIndex代理連接到TalorData MCP服務器，即可將實时網絡搜索、抓取和結構化數據檢索添加到您的RAG和索引筦道中。

### 託管 MCP

{% stepper %}
{% step %}

#### 獲取您的 API 令牌

* 前往 [SERP API-API Token](https://dashboard.talordata.com/scraping/serp-api/api-token/) 創建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.talordata.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 %}

#### 監控使用情况

在 TalorData [**SERP API-使用記錄**](https://dashboard.talordata.com/scraping/serp-api/history) 中查看您的 API 使用情况。

{% endstep %}
{% endstepper %}
