mcp iframe updates

This commit is contained in:
Josh at WLTechBlog
2025-08-16 07:13:33 -05:00
parent cf34368901
commit e1f2c45c3a
11 changed files with 239 additions and 13 deletions

View File

@@ -112,17 +112,21 @@ Switch iframe context for subsequent operations.
- `action` (required): One of "enter", "exit"
- `selector` (optional): Iframe CSS selector (required for "enter" action)
- `tab` (optional): Specific tab ID to use
- `timeout` (optional): Timeout in seconds (default: 5)
**Example Usage:**
```
web_iframe_cremotemcp:
action: "enter"
selector: "iframe#payment-form"
timeout: 10
web_iframe_cremotemcp:
action: "exit"
```
**Note:** The timeout parameter is particularly important for iframe operations as they can hang if the iframe takes time to load or if the selector doesn't match any elements.
### 7. `file_upload_cremotemcp`
Upload files from the client to the container for use in form uploads.

View File

@@ -750,7 +750,7 @@ func (s *MCPServer) handleIframe(params map[string]interface{}) (ToolResult, err
if selector == "" {
return ToolResult{}, fmt.Errorf("selector parameter is required for enter action")
}
err = s.client.SwitchToIframe(tab, selector)
err = s.client.SwitchToIframe(tab, selector, 5) // Default 5 second timeout
s.iframeMode = true
data = map[string]string{"action": "entered", "selector": selector}

View File

@@ -636,7 +636,7 @@ func (s *MCPServer) handleIframe(params map[string]interface{}) (ToolResult, err
if selector == "" {
return ToolResult{}, fmt.Errorf("selector parameter is required for enter action")
}
err = s.client.SwitchToIframe(tab, selector)
err = s.client.SwitchToIframe(tab, selector, 5) // Default 5 second timeout
s.iframeMode = true
data = map[string]string{"action": "entered", "selector": selector}

Binary file not shown.

Binary file not shown.

View File

@@ -538,6 +538,11 @@ func main() {
"type": "string",
"description": "Tab ID (optional)",
},
"timeout": map[string]any{
"type": "integer",
"description": "Timeout in seconds",
"default": 5,
},
},
Required: []string{"action"},
},
@@ -551,6 +556,7 @@ func main() {
action := getStringParam(params, "action", "")
selector := getStringParam(params, "selector", "")
tab := getStringParam(params, "tab", cremoteServer.currentTab)
timeout := getIntParam(params, "timeout", 5)
if action == "" {
return nil, fmt.Errorf("action parameter is required")
@@ -567,7 +573,7 @@ func main() {
if selector == "" {
return nil, fmt.Errorf("selector parameter is required for enter action")
}
err = cremoteServer.client.SwitchToIframe(tab, selector)
err = cremoteServer.client.SwitchToIframe(tab, selector, timeout)
cremoteServer.iframeMode = true
message = fmt.Sprintf("Entered iframe: %s", selector)