Skip to content

Commit 6f12fb3

Browse files
committed
feat: add playwright tool for browser use in local environment; agent in sandbox can use it directly
1 parent 359d8e8 commit 6f12fb3

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
from google.adk.tools.mcp_tool.mcp_toolset import MCPToolset, StdioConnectionParams, StdioServerParameters
2+
import subprocess
3+
from veadk.utils.logger import get_logger
4+
5+
logger = get_logger(__name__)
6+
7+
def check_env():
8+
try:
9+
result = subprocess.run(
10+
["npx", "-v"], capture_output=True, text=True, check=True
11+
)
12+
version = result.stdout.strip()
13+
logger.info(f"Check `npx` command done, version: {version}")
14+
except Exception as e:
15+
raise Exception(
16+
"Check `npx` command failed. Please install `npx` command manually."
17+
) from e
18+
19+
check_env()
20+
21+
playwright_tools = MCPToolset(
22+
connection_params=StdioConnectionParams(
23+
server_params=StdioServerParameters(
24+
command='npx',
25+
args=[
26+
"-y",
27+
"@playwright/mcp@latest",
28+
],
29+
),
30+
timeout=30
31+
),
32+
# tool_filter=['browser_navigate', 'browser_screenshot', 'browser_fill', 'browser_click']
33+
)

0 commit comments

Comments
 (0)