LlamaIndex
LlamaIndex: BasicMCPClient พร้อม headers จากนั้น McpToolSpec จะแปลงเครื่องมือเป็นเครื่องมือของ LlamaIndex
- คีย์ API (Bearer)
- ลงชื่อเข้าใช้ด้วย OAuth
โค้ดไคลเอนต์
แนะนำimport asyncio, os
from llama_index.tools.mcp import BasicMCPClient, McpToolSpec
async def main():
client = BasicMCPClient("https://aicharged.io/api/v1/mcp", headers={"Authorization": f"Bearer {os.environ['AICHARGED_API_KEY']}"})
tools = await McpToolSpec(client=client).to_tool_list_async()
print([tool.metadata.name for tool in tools])
asyncio.run(main())
ติดตั้งแพ็กเกจ
pip install llama-index-tools-mcp