fix: browser tools use subagent profile from context
Changed all browser tool `profile` parameters from defaulting to "default"
to defaulting to None. This allows `get_session()` to use the context
variable set by `set_active_profile()` in the subagent executor.
Before: Subagent calls browser_navigate() → profile="default" → tab group named "default"
After: Subagent calls browser_navigate() → profile=None → get_session() uses contextvar → tab group named "{agent_id}-{subagent_id}"
Fixes tab groups being named "default" instead of the subagent's name.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -29,7 +29,7 @@ def register_advanced_tools(mcp: FastMCP) -> None:
|
||||
selector: str | None = None,
|
||||
text: str | None = None,
|
||||
target_id: str | None = None,
|
||||
profile: str = "default",
|
||||
profile: str | None = None,
|
||||
timeout_ms: int = DEFAULT_TIMEOUT_MS,
|
||||
) -> dict:
|
||||
"""
|
||||
@@ -78,7 +78,7 @@ def register_advanced_tools(mcp: FastMCP) -> None:
|
||||
async def browser_evaluate(
|
||||
script: str,
|
||||
target_id: str | None = None,
|
||||
profile: str = "default",
|
||||
profile: str | None = None,
|
||||
) -> dict:
|
||||
"""
|
||||
Execute JavaScript in the browser context.
|
||||
@@ -106,7 +106,7 @@ def register_advanced_tools(mcp: FastMCP) -> None:
|
||||
async def browser_get_text(
|
||||
selector: str,
|
||||
target_id: str | None = None,
|
||||
profile: str = "default",
|
||||
profile: str | None = None,
|
||||
timeout_ms: int = DEFAULT_TIMEOUT_MS,
|
||||
) -> dict:
|
||||
"""
|
||||
@@ -148,7 +148,7 @@ def register_advanced_tools(mcp: FastMCP) -> None:
|
||||
selector: str,
|
||||
attribute: str,
|
||||
target_id: str | None = None,
|
||||
profile: str = "default",
|
||||
profile: str | None = None,
|
||||
timeout_ms: int = DEFAULT_TIMEOUT_MS,
|
||||
) -> dict:
|
||||
"""
|
||||
@@ -191,7 +191,7 @@ def register_advanced_tools(mcp: FastMCP) -> None:
|
||||
width: int,
|
||||
height: int,
|
||||
target_id: str | None = None,
|
||||
profile: str = "default",
|
||||
profile: str | None = None,
|
||||
) -> dict:
|
||||
"""
|
||||
Resize the browser viewport.
|
||||
@@ -226,7 +226,7 @@ def register_advanced_tools(mcp: FastMCP) -> None:
|
||||
selector: str,
|
||||
file_paths: list[str],
|
||||
target_id: str | None = None,
|
||||
profile: str = "default",
|
||||
profile: str | None = None,
|
||||
timeout_ms: int = DEFAULT_TIMEOUT_MS,
|
||||
) -> dict:
|
||||
"""
|
||||
@@ -282,7 +282,7 @@ def register_advanced_tools(mcp: FastMCP) -> None:
|
||||
action: Literal["accept", "dismiss"] = "accept",
|
||||
prompt_text: str | None = None,
|
||||
target_id: str | None = None,
|
||||
profile: str = "default",
|
||||
profile: str | None = None,
|
||||
timeout_ms: int = DEFAULT_TIMEOUT_MS,
|
||||
) -> dict:
|
||||
"""
|
||||
|
||||
@@ -197,7 +197,7 @@ def register_inspection_tools(mcp: FastMCP) -> None:
|
||||
@mcp.tool()
|
||||
async def browser_screenshot(
|
||||
target_id: str | None = None,
|
||||
profile: str = "default",
|
||||
profile: str | None = None,
|
||||
full_page: bool = False,
|
||||
selector: str | None = None,
|
||||
image_type: Literal["png", "jpeg"] = "png",
|
||||
@@ -278,7 +278,7 @@ def register_inspection_tools(mcp: FastMCP) -> None:
|
||||
@mcp.tool()
|
||||
async def browser_snapshot(
|
||||
target_id: str | None = None,
|
||||
profile: str = "default",
|
||||
profile: str | None = None,
|
||||
mode: Literal["aria", "cdp"] = "aria",
|
||||
) -> dict:
|
||||
"""
|
||||
@@ -347,7 +347,7 @@ def register_inspection_tools(mcp: FastMCP) -> None:
|
||||
@mcp.tool()
|
||||
async def browser_console(
|
||||
target_id: str | None = None,
|
||||
profile: str = "default",
|
||||
profile: str | None = None,
|
||||
level: str | None = None,
|
||||
) -> dict:
|
||||
"""
|
||||
@@ -380,7 +380,7 @@ def register_inspection_tools(mcp: FastMCP) -> None:
|
||||
@mcp.tool()
|
||||
async def browser_pdf(
|
||||
target_id: str | None = None,
|
||||
profile: str = "default",
|
||||
profile: str | None = None,
|
||||
path: str | None = None,
|
||||
) -> dict:
|
||||
"""
|
||||
|
||||
@@ -79,7 +79,7 @@ def register_interaction_tools(mcp: FastMCP) -> None:
|
||||
async def browser_click(
|
||||
selector: str,
|
||||
target_id: str | None = None,
|
||||
profile: str = "default",
|
||||
profile: str | None = None,
|
||||
button: Literal["left", "right", "middle"] = "left",
|
||||
double_click: bool = False,
|
||||
timeout_ms: int = DEFAULT_TIMEOUT_MS,
|
||||
@@ -143,7 +143,7 @@ def register_interaction_tools(mcp: FastMCP) -> None:
|
||||
x: float,
|
||||
y: float,
|
||||
target_id: str | None = None,
|
||||
profile: str = "default",
|
||||
profile: str | None = None,
|
||||
button: Literal["left", "right", "middle"] = "left",
|
||||
auto_snapshot: bool = True,
|
||||
) -> dict:
|
||||
@@ -192,7 +192,7 @@ def register_interaction_tools(mcp: FastMCP) -> None:
|
||||
selector: str,
|
||||
text: str,
|
||||
target_id: str | None = None,
|
||||
profile: str = "default",
|
||||
profile: str | None = None,
|
||||
delay_ms: int = 0,
|
||||
clear_first: bool = True,
|
||||
timeout_ms: int = DEFAULT_TIMEOUT_MS,
|
||||
@@ -250,7 +250,7 @@ def register_interaction_tools(mcp: FastMCP) -> None:
|
||||
selector: str,
|
||||
value: str,
|
||||
target_id: str | None = None,
|
||||
profile: str = "default",
|
||||
profile: str | None = None,
|
||||
timeout_ms: int = DEFAULT_TIMEOUT_MS,
|
||||
auto_snapshot: bool = True,
|
||||
) -> dict:
|
||||
@@ -302,7 +302,7 @@ def register_interaction_tools(mcp: FastMCP) -> None:
|
||||
key: str,
|
||||
selector: str | None = None,
|
||||
target_id: str | None = None,
|
||||
profile: str = "default",
|
||||
profile: str | None = None,
|
||||
timeout_ms: int = DEFAULT_TIMEOUT_MS,
|
||||
) -> dict:
|
||||
"""
|
||||
@@ -343,7 +343,7 @@ def register_interaction_tools(mcp: FastMCP) -> None:
|
||||
async def browser_hover(
|
||||
selector: str,
|
||||
target_id: str | None = None,
|
||||
profile: str = "default",
|
||||
profile: str | None = None,
|
||||
timeout_ms: int = DEFAULT_TIMEOUT_MS,
|
||||
) -> dict:
|
||||
"""
|
||||
@@ -381,7 +381,7 @@ def register_interaction_tools(mcp: FastMCP) -> None:
|
||||
selector: str,
|
||||
values: list[str],
|
||||
target_id: str | None = None,
|
||||
profile: str = "default",
|
||||
profile: str | None = None,
|
||||
timeout_ms: int = DEFAULT_TIMEOUT_MS,
|
||||
auto_snapshot: bool = True,
|
||||
) -> dict:
|
||||
@@ -436,7 +436,7 @@ def register_interaction_tools(mcp: FastMCP) -> None:
|
||||
amount: int = 500,
|
||||
selector: str | None = None,
|
||||
target_id: str | None = None,
|
||||
profile: str = "default",
|
||||
profile: str | None = None,
|
||||
auto_snapshot: bool = True,
|
||||
) -> dict:
|
||||
"""
|
||||
@@ -504,7 +504,7 @@ def register_interaction_tools(mcp: FastMCP) -> None:
|
||||
start_selector: str,
|
||||
end_selector: str,
|
||||
target_id: str | None = None,
|
||||
profile: str = "default",
|
||||
profile: str | None = None,
|
||||
timeout_ms: int = DEFAULT_TIMEOUT_MS,
|
||||
auto_snapshot: bool = True,
|
||||
) -> dict:
|
||||
|
||||
@@ -11,7 +11,7 @@ def register_lifecycle_tools(mcp: FastMCP) -> None:
|
||||
"""Register browser lifecycle management tools."""
|
||||
|
||||
@mcp.tool()
|
||||
async def browser_status(profile: str = "default") -> dict:
|
||||
async def browser_status(profile: str | None = None) -> dict:
|
||||
"""
|
||||
Get the current status of the browser.
|
||||
|
||||
@@ -26,7 +26,7 @@ def register_lifecycle_tools(mcp: FastMCP) -> None:
|
||||
|
||||
@mcp.tool()
|
||||
async def browser_start(
|
||||
profile: str = "default",
|
||||
profile: str | None = None,
|
||||
) -> dict:
|
||||
"""
|
||||
Start the browser with a persistent profile.
|
||||
@@ -45,7 +45,7 @@ def register_lifecycle_tools(mcp: FastMCP) -> None:
|
||||
return await session.start(headless=False, persistent=True)
|
||||
|
||||
@mcp.tool()
|
||||
async def browser_stop(profile: str = "default") -> dict:
|
||||
async def browser_stop(profile: str | None = None) -> dict:
|
||||
"""
|
||||
Stop the browser and close all tabs.
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ def register_navigation_tools(mcp: FastMCP) -> None:
|
||||
async def browser_navigate(
|
||||
url: str,
|
||||
target_id: str | None = None,
|
||||
profile: str = "default",
|
||||
profile: str | None = None,
|
||||
wait_until: str = "domcontentloaded",
|
||||
) -> dict:
|
||||
"""
|
||||
@@ -57,7 +57,7 @@ def register_navigation_tools(mcp: FastMCP) -> None:
|
||||
@mcp.tool()
|
||||
async def browser_go_back(
|
||||
target_id: str | None = None,
|
||||
profile: str = "default",
|
||||
profile: str | None = None,
|
||||
) -> dict:
|
||||
"""
|
||||
Navigate back in browser history.
|
||||
@@ -83,7 +83,7 @@ def register_navigation_tools(mcp: FastMCP) -> None:
|
||||
@mcp.tool()
|
||||
async def browser_go_forward(
|
||||
target_id: str | None = None,
|
||||
profile: str = "default",
|
||||
profile: str | None = None,
|
||||
) -> dict:
|
||||
"""
|
||||
Navigate forward in browser history.
|
||||
@@ -109,7 +109,7 @@ def register_navigation_tools(mcp: FastMCP) -> None:
|
||||
@mcp.tool()
|
||||
async def browser_reload(
|
||||
target_id: str | None = None,
|
||||
profile: str = "default",
|
||||
profile: str | None = None,
|
||||
) -> dict:
|
||||
"""
|
||||
Reload the current page.
|
||||
|
||||
@@ -15,7 +15,7 @@ def register_tab_tools(mcp: FastMCP) -> None:
|
||||
"""Register browser tab management tools."""
|
||||
|
||||
@mcp.tool()
|
||||
async def browser_tabs(profile: str = "default") -> dict:
|
||||
async def browser_tabs(profile: str | None = None) -> dict:
|
||||
"""
|
||||
List all open browser tabs with origin and age metadata.
|
||||
|
||||
@@ -54,7 +54,7 @@ def register_tab_tools(mcp: FastMCP) -> None:
|
||||
async def browser_open(
|
||||
url: str,
|
||||
background: bool = False,
|
||||
profile: str = "default",
|
||||
profile: str | None = None,
|
||||
wait_until: str = "load",
|
||||
) -> dict:
|
||||
"""
|
||||
@@ -87,7 +87,7 @@ def register_tab_tools(mcp: FastMCP) -> None:
|
||||
return {"ok": False, "error": f"Browser error: {e!s}"}
|
||||
|
||||
@mcp.tool()
|
||||
async def browser_close(target_id: str | None = None, profile: str = "default") -> dict:
|
||||
async def browser_close(target_id: str | None = None, profile: str | None = None) -> dict:
|
||||
"""
|
||||
Close a browser tab.
|
||||
|
||||
@@ -102,7 +102,7 @@ def register_tab_tools(mcp: FastMCP) -> None:
|
||||
return await session.close_tab(target_id)
|
||||
|
||||
@mcp.tool()
|
||||
async def browser_focus(target_id: str, profile: str = "default") -> dict:
|
||||
async def browser_focus(target_id: str, profile: str | None = None) -> dict:
|
||||
"""
|
||||
Focus a browser tab.
|
||||
|
||||
@@ -117,7 +117,7 @@ def register_tab_tools(mcp: FastMCP) -> None:
|
||||
return await session.focus_tab(target_id)
|
||||
|
||||
@mcp.tool()
|
||||
async def browser_close_all(keep_active: bool = True, profile: str = "default") -> dict:
|
||||
async def browser_close_all(keep_active: bool = True, profile: str | None = None) -> dict:
|
||||
"""
|
||||
Close all browser tabs, optionally keeping the active tab.
|
||||
|
||||
@@ -143,7 +143,7 @@ def register_tab_tools(mcp: FastMCP) -> None:
|
||||
return {"ok": True, "closed_count": closed, "remaining": len(session.pages)}
|
||||
|
||||
@mcp.tool()
|
||||
async def browser_close_finished(keep_active: bool = True, profile: str = "default") -> dict:
|
||||
async def browser_close_finished(keep_active: bool = True, profile: str | None = None) -> dict:
|
||||
"""
|
||||
Close all agent-opened and popup tabs that you are done with.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user