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