Spaces:
Sleeping
Sleeping
Download agent/tools/PlaywrightMCP.py from dimadem/final_agent: direct link, hf CLI and curl.
- Browser
- Download file 759 Bytes
-
https://huggingface.co/spaces/dimadem/final_agent/resolve/main/agent/tools/PlaywrightMCP.py
- Command line
-
hf download hf://spaces/dimadem/final_agent/agent/tools/PlaywrightMCP.py
-
curl -L -o PlaywrightMCP.py https://huggingface.co/spaces/dimadem/final_agent/resolve/main/agent/tools/PlaywrightMCP.py
759 Bytes
| import os | |
| from mcp import StdioServerParameters | |
| from smolagents import MCPClient | |
| class PlaywrightMCP: | |
| def __init__(self): | |
| self.client = None | |
| self.tools = [] | |
| def init(self): | |
| server_parameters = StdioServerParameters( | |
| command="npx", | |
| args=["@playwright/mcp@latest"], | |
| env=os.environ, | |
| ) | |
| self.client = MCPClient(server_parameters) | |
| self.tools = self.client.get_tools() | |
| return self.tools | |
| def get_tools(self): | |
| if not self.tools: | |
| return self.init() | |
| return self.tools | |
| def disconnect(self): | |
| if self.client: | |
| self.client.disconnect() | |
| self.client = None | |
| self.tools = [] |