Update utils/huggingface_mcp_llamaindex.py
Browse files
utils/huggingface_mcp_llamaindex.py
CHANGED
@@ -2,16 +2,16 @@ from llama_index.tools.mcp import BasicMCPClient
|
|
2 |
from dotenv import load_dotenv
|
3 |
import os
|
4 |
load_dotenv()
|
5 |
-
|
6 |
async def connect_and_get_tools():
|
7 |
# Connect to an MCP server using different transports
|
8 |
-
http_client = BasicMCPClient("https://huggingface.co/mcp", headers={"Authorization": f"Bearer {
|
9 |
|
10 |
# List available tools
|
11 |
tools = await http_client.list_tools()
|
12 |
return tools
|
13 |
|
14 |
async def call_tool(tool_name, tool_args):
|
15 |
-
http_client = BasicMCPClient("https://huggingface.co/mcp", headers={"Authorization": f"Bearer {
|
16 |
result = await http_client.call_tool(tool_name, tool_args)
|
17 |
return result
|
|
|
2 |
from dotenv import load_dotenv
|
3 |
import os
|
4 |
load_dotenv()
|
5 |
+
HF_TOKEN = os.getenv("HF_TOKEN")
|
6 |
async def connect_and_get_tools():
|
7 |
# Connect to an MCP server using different transports
|
8 |
+
http_client = BasicMCPClient("https://huggingface.co/mcp", headers={"Authorization": f"Bearer {HF_TOKEN}"})
|
9 |
|
10 |
# List available tools
|
11 |
tools = await http_client.list_tools()
|
12 |
return tools
|
13 |
|
14 |
async def call_tool(tool_name, tool_args):
|
15 |
+
http_client = BasicMCPClient("https://huggingface.co/mcp", headers={"Authorization": f"Bearer {HF_TOKEN}"})
|
16 |
result = await http_client.call_tool(tool_name, tool_args)
|
17 |
return result
|