适用于 LlamaIndex 的 MCP 工具
将 MultitaskAI 作为 带有 McpToolSpec 的 BasicMCPClient 连接到 Python 中的 LlamaIndex 智能体,使用 一个 API 密钥 登录后,LlamaIndex 就能用自然语言调用所有工具。
4 步完成连接
将 MultitaskAI 作为 带有 McpToolSpec 的 BasicMCPClient 添加到 Python 中的 LlamaIndex 智能体。只需一分钟,所有工具都会随之可用。
在你的 MultitaskAI 账户中创建 API 密钥。
使用 pip install llama-index-tools-mcp 安装 MCP 工具包。
创建下方的客户端,用你的密钥替换 YOUR_API_KEY,然后将这些工具传递给 FunctionAgent。
运行智能体,并询问它可以使用哪些 MultitaskAI 工具。
agent.py
from llama_index.tools.mcp import BasicMCPClient, McpToolSpec
mcp_client = BasicMCPClient(
"https://mcp.multitaskai.com",
headers={"Authorization": "Bearer YOUR_API_KEY"},
)
mcp_tool_spec = McpToolSpec(client=mcp_client)
tools = await mcp_tool_spec.to_tool_list_async()API 密钥
LlamaIndex 会在 Authorization 标头中发送你的 MultitaskAI API 密钥。在你的账户中创建密钥,并用它替代 YOUR_API_KEY。
完整的 LlamaIndex 指南涵盖每个步骤、端点、登录方式以及如何检查连接。
按类别查看 MCP 工具
每个工具都适用于 LlamaIndex。选择一个类别,了解它能做什么。