Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions webEvalAgent/mcp_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

# MCP imports
from mcp.server.fastmcp import FastMCP, Context
from mcp.types import TextContent
from mcp.types import TextContent, ImageContent
# Removing the problematic import
# from mcp.server.tool import Tool, register_tool

Expand Down Expand Up @@ -54,7 +54,7 @@ class BrowserTools(str, Enum):
print("Error: No API key provided. Please set the OPERATIVE_API_KEY environment variable.")

@mcp.tool(name=BrowserTools.WEB_EVAL_AGENT)
async def web_eval_agent(url: str, task: str, ctx: Context, headless_browser: bool = False) -> list[TextContent]:
async def web_eval_agent(url: str, task: str, ctx: Context, headless_browser: bool = False) -> list[list[TextContent | ImageContent]]:
"""Evaluate the user experience / interface of a web application.

This tool allows the AI to assess the quality of user experience and interface design
Expand Down Expand Up @@ -84,7 +84,7 @@ async def web_eval_agent(url: str, task: str, ctx: Context, headless_browser: bo
error_message_str = "❌ Error: API Key validation failed when running the tool.\n"
error_message_str += " Reason: Free tier limit reached.\n"
error_message_str += " 👉 Please subscribe at https://operative.sh to continue."
return [TextContent(type="text", text=error_message_str)]
return [[TextContent(type="text", text=error_message_str)]]
try:
# Generate a new tool_call_id for this specific tool call
tool_call_id = str(uuid.uuid4())
Expand All @@ -95,10 +95,10 @@ async def web_eval_agent(url: str, task: str, ctx: Context, headless_browser: bo
)
except Exception as e:
tb = traceback.format_exc()
return [TextContent(
return [[TextContent(
type="text",
text=f"Error executing web_eval_agent: {str(e)}\n\nTraceback:\n{tb}"
)]
)]]

@mcp.tool(name=BrowserTools.SETUP_BROWSER_STATE)
async def setup_browser_state(url: str = None, ctx: Context = None) -> list[TextContent]:
Expand Down
10 changes: 5 additions & 5 deletions webEvalAgent/src/tool_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def get_browser_manager() -> PlaywrightBrowserManager:
"""
return PlaywrightBrowserManager.get_instance()

async def handle_web_evaluation(arguments: Dict[str, Any], ctx: Context, api_key: str) -> list[TextContent]:
async def handle_web_evaluation(arguments: Dict[str, Any], ctx: Context, api_key: str) -> list[list[TextContent | ImageContent]]:
"""Handle web_eval_agent tool calls

This function evaluates the user experience of a web application by using
Expand Down Expand Up @@ -86,16 +86,16 @@ async def handle_web_evaluation(arguments: Dict[str, Any], ctx: Context, api_key
send_log(f"Added https:// protocol to URL: {url}", "🔗")

if not url or not isinstance(url, str):
return [TextContent(
return [[TextContent(
type="text",
text="Error: 'url' must be a non-empty string containing the web application URL to evaluate."
)]
)]]

if not task or not isinstance(task, str):
return [TextContent(
return [[TextContent(
type="text",
text="Error: 'task' must be a non-empty string describing the UX/UI aspect to test."
)]
)]]

# Send initial status to dashboard
send_log(f"🚀 Received web evaluation task: {task}", "🚀")
Expand Down