data_science_agent / utils /huggingface_mcp_llamaindex.py
bpHigh's picture
Add proper planning with mcp support
a604df6
raw
history blame
662 Bytes
from llama_index.tools.mcp import BasicMCPClient
from dotenv import load_dotenv
import os
load_dotenv()
async def connect_and_get_tools():
# Connect to an MCP server using different transports
http_client = BasicMCPClient("https://huggingface.co/mcp", headers={"Authorization": f"Bearer {os.getenv('HF_TOKEN')}"})
# List available tools
tools = await http_client.list_tools()
return tools
async def call_tool(tool_name, tool_args):
http_client = BasicMCPClient("https://huggingface.co/mcp", headers={"Authorization": f"Bearer {os.getenv('HF_TOKEN')}"})
result = await http_client.call_tool(tool_name, tool_args)
return result