Spaces:
Sleeping
Sleeping
Download test_failure_analysis/agent.py from VAH6002/Test_Failure_Analysis_Agent: direct link, hf CLI and curl.
- Browser
- Download file 1.84 kB
-
https://huggingface.co/spaces/VAH6002/Test_Failure_Analysis_Agent/resolve/main/test_failure_analysis/agent.py
- Command line
-
hf download hf://spaces/VAH6002/Test_Failure_Analysis_Agent/test_failure_analysis/agent.py
-
curl -L -o agent.py https://huggingface.co/spaces/VAH6002/Test_Failure_Analysis_Agent/resolve/main/test_failure_analysis/agent.py
1.84 kB
| import asyncio | |
| import sys | |
| import json | |
| from pathlib import Path | |
| from google.adk.agents import LlmAgent | |
| from google.adk.tools.mcp_tool.mcp_toolset import MCPToolset, StdioServerParameters | |
| try: | |
| from test_failure_analysis.tfa_prompt import TFA_MCP_PROMPT | |
| except ImportError: | |
| from tfa_prompt import TFA_MCP_PROMPT | |
| # Fix for Windows subprocess support | |
| if sys.platform == "win32": | |
| asyncio.set_event_loop_policy(asyncio.WindowsProactorEventLoopPolicy()) | |
| # Load JSON config | |
| CONFIG_PATH = Path(__file__).resolve().parent / "mcp_config.json" | |
| with open(CONFIG_PATH, "r") as f: | |
| mcp_config = json.load(f)["mcpServers"] | |
| # # Create a list of MCPToolset instances for each server | |
| # toolsets = [] | |
| # for name, config in mcp_config.items(): | |
| # print(f"Adding MCP Server: {name}") | |
| # toolsets.append( | |
| # MCPToolset( | |
| # connection_params=StdioServerParameters( | |
| # command=config["command"], | |
| # args=config["args"] | |
| # ) | |
| # ) | |
| # ) | |
| # Create a list of MCPToolset instances for each server | |
| toolsets = [] | |
| for name, config in mcp_config.items(): | |
| print(f"Adding MCP Server: {name}") | |
| try: | |
| toolset = MCPToolset( | |
| connection_params=StdioServerParameters( | |
| server_params={ | |
| "command": "python", | |
| "args": ["sponge_mcp_server.py"] | |
| } | |
| ) | |
| ) | |
| print(f"→ Toolset created for {name}: {toolset}") | |
| toolsets.append(toolset) | |
| except Exception as e: | |
| print(f"✗ Failed to create toolset for {name}: {e}") | |
| continue | |
| # Build the root agent with all MCP servers | |
| root_agent = LlmAgent( | |
| model="gemini-2.5-flash", | |
| name="test_failure_analysis_agent", | |
| instruction=TFA_MCP_PROMPT, | |
| tools=toolsets # Multiple MCP servers | |
| ) | |