# MCP Cache and Site Data Management Test Examples

This document provides examples of how to use the new cache and site data management tools through the MCP interface.

## Prerequisites

1. Ensure cremotedaemon is running
2. Ensure Chrome/Chromium is running with remote debugging enabled
3. Configure your MCP client to use the cremote MCP server

## Example 1: Basic Cache Disable/Enable Workflow

```yaml
# Navigate to a test page
web_navigate_cremotemcp:
  url: "https://httpbin.org/cache/60"
  screenshot: true

# Disable cache for testing
web_disable_cache_cremotemcp:
  timeout: 10

# Reload page to test without cache
web_navigate_cremotemcp:
  url: "https://httpbin.org/cache/60"

# Re-enable cache
web_enable_cache_cremotemcp:
  timeout: 10
```

## Example 2: Performance Testing Workflow

```yaml
# Clear cache before performance test
web_clear_cache_cremotemcp:
  timeout: 15

# Disable cache for cold load test
web_disable_cache_cremotemcp:
  timeout: 10

# Navigate and measure performance
web_navigate_cremotemcp:
  url: "https://example.com"
  screenshot: true

# Get performance metrics
web_performance_metrics_cremotemcp: {}

# Enable cache for warm load test
web_enable_cache_cremotemcp:
  timeout: 10

# Navigate again and compare
web_navigate_cremotemcp:
  url: "https://example.com"

# Get performance metrics again
web_performance_metrics_cremotemcp: {}
```

## Example 3: Multi-Tab Cache Management

```yaml
# Open first tab and disable cache
web_manage_tabs_cremotemcp:
  action: "open"

web_disable_cache_cremotemcp:
  tab: "tab-1"
  timeout: 10

# Open second tab and keep cache enabled
web_manage_tabs_cremotemcp:
  action: "open"

# Navigate both tabs to same URL
web_navigate_cremotemcp:
  url: "https://httpbin.org/cache/60"
  tab: "tab-1"

web_navigate_cremotemcp:
  url: "https://httpbin.org/cache/60"
  tab: "tab-2"
```

## Example 4: Development Workflow

```yaml
# Disable cache for development
web_disable_cache_cremotemcp:
  timeout: 10

# Navigate to development site
web_navigate_cremotemcp:
  url: "http://localhost:3000"

# Interact with page
web_interact_cremotemcp:
  action: "click"
  selector: "#refresh-button"

# Take screenshot for documentation
web_screenshot_enhanced_cremotemcp:
  output: "/tmp/dev-screenshot.png"
  full_page: true
```

## Error Handling

The cache management tools will return appropriate error messages if:
- The daemon is not running
- Chrome/Chromium is not accessible
- The specified tab doesn't exist
- Network operations timeout

Example error response:
```json
{
  "error": "failed to disable cache: tab not found: tab-123",
  "isError": true
}
```

## Best Practices

1. **Always set appropriate timeouts** for cache operations (5-15 seconds recommended)
2. **Clear cache before performance tests** to ensure consistent baseline measurements
3. **Disable cache during development** to see changes immediately
4. **Re-enable cache after testing** to restore normal browsing behavior
5. **Use specific tab IDs** when working with multiple tabs to avoid confusion

## Example 5: Authentication Testing Workflow

```yaml
# Clear all site data before testing login
web_clear_all_site_data_cremotemcp:
  timeout: 15

# Navigate to login page
web_navigate_cremotemcp:
  url: "https://example.com/login"

# Fill login form
web_form_fill_bulk_cremotemcp:
  fields:
    username: "testuser"
    password: "testpass"

# Submit and verify login
web_interact_cremotemcp:
  action: "click"
  selector: "#login-button"

# Clear cookies to test logout behavior
web_clear_cookies_cremotemcp:
  timeout: 10

# Refresh page to verify logout
web_navigate_cremotemcp:
  url: "https://example.com/dashboard"
```

## Example 6: Storage Testing Workflow

```yaml
# Clear storage before testing
web_clear_storage_cremotemcp:
  timeout: 10

# Navigate to application
web_navigate_cremotemcp:
  url: "https://example.com/app"

# Interact with app to create storage data
web_interact_cremotemcp:
  action: "click"
  selector: "#save-data-button"

# Clear storage to test data persistence
web_clear_storage_cremotemcp:
  timeout: 10

# Refresh to test if data is gone
web_navigate_cremotemcp:
  url: "https://example.com/app"
```

## Integration with Other Tools

Cache and site data management works seamlessly with other cremote MCP tools:

- Use with `web_performance_metrics_cremotemcp` for performance testing
- Combine with `web_navigate_cremotemcp` for controlled page loading
- Use with `web_screenshot_enhanced_cremotemcp` for visual testing
- Integrate with `web_interact_cremotemcp` for user interaction testing
- Use with `web_form_fill_bulk_cremotemcp` for authentication testing
- Combine with `web_extract_cremotemcp` tools for data verification after clearing
