Add commands for dealing with cache and site data, cookies, etc

This commit is contained in:
Josh at WLTechBlog
2025-09-30 08:00:30 -05:00
parent 74d99db629
commit 72d4a5653d
10 changed files with 1553 additions and 1 deletions

View File

@@ -920,6 +920,120 @@ Returns file management results:
}
```
### 28. `web_disable_cache_cremotemcp` *(New in Phase 6)*
Disable browser cache for a tab.
**Parameters:**
- `tab` (optional): Tab ID (uses current tab if not specified)
- `timeout` (optional): Timeout in seconds (default: 5)
**Example Usage:**
```
# Disable cache for current tab
web_disable_cache_cremotemcp:
timeout: 10
# Disable cache for specific tab
web_disable_cache_cremotemcp:
tab: "tab-123"
timeout: 5
```
### 29. `web_enable_cache_cremotemcp` *(New in Phase 6)*
Enable browser cache for a tab.
**Parameters:**
- `tab` (optional): Tab ID (uses current tab if not specified)
- `timeout` (optional): Timeout in seconds (default: 5)
**Example Usage:**
```
# Enable cache for current tab
web_enable_cache_cremotemcp:
timeout: 10
# Enable cache for specific tab
web_enable_cache_cremotemcp:
tab: "tab-123"
timeout: 5
```
### 30. `web_clear_cache_cremotemcp` *(New in Phase 6)*
Clear browser cache for a tab.
**Parameters:**
- `tab` (optional): Tab ID (uses current tab if not specified)
- `timeout` (optional): Timeout in seconds (default: 5)
**Example Usage:**
```
# Clear cache for current tab
web_clear_cache_cremotemcp:
timeout: 10
# Clear cache for specific tab
web_clear_cache_cremotemcp:
tab: "tab-123"
timeout: 5
```
### 31. `web_clear_all_site_data_cremotemcp` *(New in Phase 6)*
Clear all site data including cookies, storage, cache, etc. for a tab.
**Parameters:**
- `tab` (optional): Tab ID (uses current tab if not specified)
- `timeout` (optional): Timeout in seconds (default: 5)
**Example Usage:**
```
# Clear all site data for current tab
web_clear_all_site_data_cremotemcp:
timeout: 15
# Clear all site data for specific tab
web_clear_all_site_data_cremotemcp:
tab: "tab-123"
timeout: 10
```
### 32. `web_clear_cookies_cremotemcp` *(New in Phase 6)*
Clear cookies for a tab.
**Parameters:**
- `tab` (optional): Tab ID (uses current tab if not specified)
- `timeout` (optional): Timeout in seconds (default: 5)
**Example Usage:**
```
# Clear cookies for current tab
web_clear_cookies_cremotemcp:
timeout: 10
# Clear cookies for specific tab
web_clear_cookies_cremotemcp:
tab: "tab-123"
timeout: 5
```
### 33. `web_clear_storage_cremotemcp` *(New in Phase 6)*
Clear web storage (localStorage, sessionStorage, IndexedDB, etc.) for a tab.
**Parameters:**
- `tab` (optional): Tab ID (uses current tab if not specified)
- `timeout` (optional): Timeout in seconds (default: 5)
**Example Usage:**
```
# Clear storage for current tab
web_clear_storage_cremotemcp:
timeout: 10
# Clear storage for specific tab
web_clear_storage_cremotemcp:
tab: "tab-123"
timeout: 5
```
## Common Usage Patterns
### 1. Basic Web Navigation

View File

@@ -533,9 +533,87 @@ Manage files (cleanup, list, get info).
Operations: `cleanup` (remove old files), `list` (list files), `info` (get file details).
#### 28. `web_disable_cache_cremotemcp`
Disable browser cache for a tab.
```json
{
"name": "web_disable_cache_cremotemcp",
"arguments": {
"tab": "tab-123",
"timeout": 5
}
}
```
#### 29. `web_enable_cache_cremotemcp`
Enable browser cache for a tab.
```json
{
"name": "web_enable_cache_cremotemcp",
"arguments": {
"tab": "tab-123",
"timeout": 5
}
}
```
#### 30. `web_clear_cache_cremotemcp`
Clear browser cache for a tab.
```json
{
"name": "web_clear_cache_cremotemcp",
"arguments": {
"tab": "tab-123",
"timeout": 5
}
}
```
#### 31. `web_clear_all_site_data_cremotemcp`
Clear all site data including cookies, storage, cache, etc. for a tab.
```json
{
"name": "web_clear_all_site_data_cremotemcp",
"arguments": {
"tab": "tab-123",
"timeout": 10
}
}
```
#### 32. `web_clear_cookies_cremotemcp`
Clear cookies for a tab.
```json
{
"name": "web_clear_cookies_cremotemcp",
"arguments": {
"tab": "tab-123",
"timeout": 5
}
}
```
#### 33. `web_clear_storage_cremotemcp`
Clear web storage (localStorage, sessionStorage, IndexedDB, etc.) for a tab.
```json
{
"name": "web_clear_storage_cremotemcp",
"arguments": {
"tab": "tab-123",
"timeout": 5
}
}
```
## 🎉 Complete Enhancement Summary
All 5 phases of the MCP enhancement plan have been successfully implemented, delivering a comprehensive web automation platform with **27 tools** organized across the following capabilities:
All 6 phases of the MCP enhancement plan have been successfully implemented, delivering a comprehensive web automation platform with **33 tools** organized across the following capabilities:
### ✅ Phase 1: Element State and Checking (2 tools)
**Enables conditional logic without timing issues**
@@ -579,6 +657,17 @@ All 5 phases of the MCP enhancement plan have been successfully implemented, del
**Benefits**: Better debugging with targeted screenshots, improved file handling workflows, automatic resource management, enhanced visual debugging capabilities.
### ✅ Phase 6: Browser Cache and Site Data Management (6 tools)
**Enables comprehensive cache and site data control for testing and privacy**
- `web_disable_cache_cremotemcp`: Disable browser cache for a tab
- `web_enable_cache_cremotemcp`: Enable browser cache for a tab
- `web_clear_cache_cremotemcp`: Clear browser cache for a tab
- `web_clear_all_site_data_cremotemcp`: Clear all site data (cookies, storage, cache, etc.)
- `web_clear_cookies_cremotemcp`: Clear cookies for a tab
- `web_clear_storage_cremotemcp`: Clear web storage (localStorage, sessionStorage, IndexedDB, etc.)
**Benefits**: Essential for testing scenarios requiring fresh page loads, performance testing without cached resources, debugging cache-related issues, ensuring consistent test environments, privacy testing, authentication testing, and complete site data cleanup.
## Key Benefits for LLM Agents
### 🚀 **Efficiency Gains**

View File

@@ -2168,6 +2168,278 @@ func main() {
}, nil
})
// Cache management tools
mcpServer.AddTool(mcp.Tool{
Name: "web_disable_cache_cremotemcp",
Description: "Disable browser cache for a tab",
InputSchema: mcp.ToolInputSchema{
Type: "object",
Properties: map[string]any{
"tab": map[string]any{
"type": "string",
"description": "Tab ID (optional, uses current tab)",
},
"timeout": map[string]any{
"type": "integer",
"description": "Timeout in seconds (default: 5)",
"default": 5,
},
},
},
}, func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
// Convert arguments to map
params, ok := request.Params.Arguments.(map[string]any)
if !ok {
return nil, fmt.Errorf("invalid arguments format")
}
tab := getStringParam(params, "tab", "")
timeout := getIntParam(params, "timeout", 5)
err := cremoteServer.client.DisableCache(tab, timeout)
if err != nil {
return &mcp.CallToolResult{
Content: []mcp.Content{
mcp.NewTextContent(fmt.Sprintf("Error disabling cache: %v", err)),
},
IsError: true,
}, nil
}
return &mcp.CallToolResult{
Content: []mcp.Content{
mcp.NewTextContent("Cache disabled successfully"),
},
IsError: false,
}, nil
})
mcpServer.AddTool(mcp.Tool{
Name: "web_enable_cache_cremotemcp",
Description: "Enable browser cache for a tab",
InputSchema: mcp.ToolInputSchema{
Type: "object",
Properties: map[string]any{
"tab": map[string]any{
"type": "string",
"description": "Tab ID (optional, uses current tab)",
},
"timeout": map[string]any{
"type": "integer",
"description": "Timeout in seconds (default: 5)",
"default": 5,
},
},
},
}, func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
// Convert arguments to map
params, ok := request.Params.Arguments.(map[string]any)
if !ok {
return nil, fmt.Errorf("invalid arguments format")
}
tab := getStringParam(params, "tab", "")
timeout := getIntParam(params, "timeout", 5)
err := cremoteServer.client.EnableCache(tab, timeout)
if err != nil {
return &mcp.CallToolResult{
Content: []mcp.Content{
mcp.NewTextContent(fmt.Sprintf("Error enabling cache: %v", err)),
},
IsError: true,
}, nil
}
return &mcp.CallToolResult{
Content: []mcp.Content{
mcp.NewTextContent("Cache enabled successfully"),
},
IsError: false,
}, nil
})
mcpServer.AddTool(mcp.Tool{
Name: "web_clear_cache_cremotemcp",
Description: "Clear browser cache for a tab",
InputSchema: mcp.ToolInputSchema{
Type: "object",
Properties: map[string]any{
"tab": map[string]any{
"type": "string",
"description": "Tab ID (optional, uses current tab)",
},
"timeout": map[string]any{
"type": "integer",
"description": "Timeout in seconds (default: 5)",
"default": 5,
},
},
},
}, func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
// Convert arguments to map
params, ok := request.Params.Arguments.(map[string]any)
if !ok {
return nil, fmt.Errorf("invalid arguments format")
}
tab := getStringParam(params, "tab", "")
timeout := getIntParam(params, "timeout", 5)
err := cremoteServer.client.ClearCache(tab, timeout)
if err != nil {
return &mcp.CallToolResult{
Content: []mcp.Content{
mcp.NewTextContent(fmt.Sprintf("Error clearing cache: %v", err)),
},
IsError: true,
}, nil
}
return &mcp.CallToolResult{
Content: []mcp.Content{
mcp.NewTextContent("Cache cleared successfully"),
},
IsError: false,
}, nil
})
// Site data management tools
mcpServer.AddTool(mcp.Tool{
Name: "web_clear_all_site_data_cremotemcp",
Description: "Clear all site data including cookies, storage, cache, etc. for a tab",
InputSchema: mcp.ToolInputSchema{
Type: "object",
Properties: map[string]any{
"tab": map[string]any{
"type": "string",
"description": "Tab ID (optional, uses current tab)",
},
"timeout": map[string]any{
"type": "integer",
"description": "Timeout in seconds (default: 5)",
"default": 5,
},
},
},
}, func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
// Convert arguments to map
params, ok := request.Params.Arguments.(map[string]any)
if !ok {
return nil, fmt.Errorf("invalid arguments format")
}
tab := getStringParam(params, "tab", "")
timeout := getIntParam(params, "timeout", 5)
err := cremoteServer.client.ClearAllSiteData(tab, timeout)
if err != nil {
return &mcp.CallToolResult{
Content: []mcp.Content{
mcp.NewTextContent(fmt.Sprintf("Error clearing all site data: %v", err)),
},
IsError: true,
}, nil
}
return &mcp.CallToolResult{
Content: []mcp.Content{
mcp.NewTextContent("All site data cleared successfully"),
},
IsError: false,
}, nil
})
mcpServer.AddTool(mcp.Tool{
Name: "web_clear_cookies_cremotemcp",
Description: "Clear cookies for a tab",
InputSchema: mcp.ToolInputSchema{
Type: "object",
Properties: map[string]any{
"tab": map[string]any{
"type": "string",
"description": "Tab ID (optional, uses current tab)",
},
"timeout": map[string]any{
"type": "integer",
"description": "Timeout in seconds (default: 5)",
"default": 5,
},
},
},
}, func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
// Convert arguments to map
params, ok := request.Params.Arguments.(map[string]any)
if !ok {
return nil, fmt.Errorf("invalid arguments format")
}
tab := getStringParam(params, "tab", "")
timeout := getIntParam(params, "timeout", 5)
err := cremoteServer.client.ClearCookies(tab, timeout)
if err != nil {
return &mcp.CallToolResult{
Content: []mcp.Content{
mcp.NewTextContent(fmt.Sprintf("Error clearing cookies: %v", err)),
},
IsError: true,
}, nil
}
return &mcp.CallToolResult{
Content: []mcp.Content{
mcp.NewTextContent("Cookies cleared successfully"),
},
IsError: false,
}, nil
})
mcpServer.AddTool(mcp.Tool{
Name: "web_clear_storage_cremotemcp",
Description: "Clear web storage (localStorage, sessionStorage, IndexedDB, etc.) for a tab",
InputSchema: mcp.ToolInputSchema{
Type: "object",
Properties: map[string]any{
"tab": map[string]any{
"type": "string",
"description": "Tab ID (optional, uses current tab)",
},
"timeout": map[string]any{
"type": "integer",
"description": "Timeout in seconds (default: 5)",
"default": 5,
},
},
},
}, func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
// Convert arguments to map
params, ok := request.Params.Arguments.(map[string]any)
if !ok {
return nil, fmt.Errorf("invalid arguments format")
}
tab := getStringParam(params, "tab", "")
timeout := getIntParam(params, "timeout", 5)
err := cremoteServer.client.ClearStorage(tab, timeout)
if err != nil {
return &mcp.CallToolResult{
Content: []mcp.Content{
mcp.NewTextContent(fmt.Sprintf("Error clearing storage: %v", err)),
},
IsError: true,
}, nil
}
return &mcp.CallToolResult{
Content: []mcp.Content{
mcp.NewTextContent("Storage cleared successfully"),
},
IsError: false,
}, nil
})
// Start the server
log.Printf("Cremote MCP server ready")
if err := server.ServeStdio(mcpServer); err != nil {