-
Notifications
You must be signed in to change notification settings - Fork 36
/
Copy pathclient.py
35 lines (27 loc) · 880 Bytes
/
client.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import asyncio
import json
import logging
import os
import shutil
from contextlib import AsyncExitStack
from typing import Any
import httpx
from dotenv import load_dotenv
from mcp import ClientSession, StdioServerParameters
from mcp.client.sse import sse_client
logging.basicConfig(
level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s"
)
async def main():
async with sse_client(
url = "http://localhost:8000/sse",
) as streams:
async with ClientSession(*streams) as session:
await session.initialize()
# List available tools
tools = await session.list_tools()
print(tools)
# Call the browser_use tool
result = await session.call_tool("browser_use", {"url": "https://example.com", "action": "save the title"})
print(result)
asyncio.run(main())