bump
This commit is contained in:
195
mcp/main.go
195
mcp/main.go
@@ -5624,6 +5624,201 @@ func main() {
|
||||
}, nil
|
||||
})
|
||||
|
||||
// Register web_extract_divi_structure tool
|
||||
mcpServer.AddTool(mcp.Tool{
|
||||
Name: "web_extract_divi_structure_cremotemcp",
|
||||
Description: "Extract Divi page structure from rendered HTML using CSS classes and DOM analysis. Returns approximated structure (60-70% accuracy) including sections, rows, columns, and modules. Cannot access original Divi shortcode/JSON or builder settings.",
|
||||
InputSchema: mcp.ToolInputSchema{
|
||||
Type: "object",
|
||||
Properties: map[string]any{
|
||||
"tab": map[string]any{
|
||||
"type": "string",
|
||||
"description": "Tab ID (optional, uses current tab)",
|
||||
},
|
||||
"url": map[string]any{
|
||||
"type": "string",
|
||||
"description": "Optional URL to navigate to before extraction",
|
||||
},
|
||||
"clear_cache": map[string]any{
|
||||
"type": "boolean",
|
||||
"description": "Clear browser cache before operation (default: false)",
|
||||
"default": false,
|
||||
},
|
||||
"timeout": map[string]any{
|
||||
"type": "integer",
|
||||
"description": "Timeout in seconds (default: 30)",
|
||||
"default": 30,
|
||||
},
|
||||
},
|
||||
},
|
||||
}, func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
|
||||
params, ok := request.Params.Arguments.(map[string]any)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("invalid arguments format")
|
||||
}
|
||||
|
||||
timeout := getIntParam(params, "timeout", 30)
|
||||
|
||||
// Handle optional navigation and cache clearing
|
||||
tab, err := handleOptionalNavigation(cremoteServer, params, timeout)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
result, err := cremoteServer.client.ExtractDiviStructure(tab, timeout)
|
||||
if err != nil {
|
||||
return &mcp.CallToolResult{
|
||||
Content: []mcp.Content{
|
||||
mcp.NewTextContent(fmt.Sprintf("Failed to extract Divi structure: %v", err)),
|
||||
},
|
||||
IsError: true,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Format results as JSON
|
||||
resultJSON, err := json.MarshalIndent(result, "", " ")
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to marshal results: %w", err)
|
||||
}
|
||||
|
||||
return &mcp.CallToolResult{
|
||||
Content: []mcp.Content{
|
||||
mcp.NewTextContent(string(resultJSON)),
|
||||
},
|
||||
IsError: false,
|
||||
}, nil
|
||||
})
|
||||
|
||||
// Register web_extract_divi_images tool
|
||||
mcpServer.AddTool(mcp.Tool{
|
||||
Name: "web_extract_divi_images_cremotemcp",
|
||||
Description: "Extract all images from a Divi page with metadata including URLs, dimensions, alt text, and context. Returns 100% of visible images.",
|
||||
InputSchema: mcp.ToolInputSchema{
|
||||
Type: "object",
|
||||
Properties: map[string]any{
|
||||
"tab": map[string]any{
|
||||
"type": "string",
|
||||
"description": "Tab ID (optional, uses current tab)",
|
||||
},
|
||||
"url": map[string]any{
|
||||
"type": "string",
|
||||
"description": "Optional URL to navigate to before extraction",
|
||||
},
|
||||
"clear_cache": map[string]any{
|
||||
"type": "boolean",
|
||||
"description": "Clear browser cache before operation (default: false)",
|
||||
"default": false,
|
||||
},
|
||||
"timeout": map[string]any{
|
||||
"type": "integer",
|
||||
"description": "Timeout in seconds (default: 30)",
|
||||
"default": 30,
|
||||
},
|
||||
},
|
||||
},
|
||||
}, func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
|
||||
params, ok := request.Params.Arguments.(map[string]any)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("invalid arguments format")
|
||||
}
|
||||
|
||||
timeout := getIntParam(params, "timeout", 30)
|
||||
|
||||
// Handle optional navigation and cache clearing
|
||||
tab, err := handleOptionalNavigation(cremoteServer, params, timeout)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
result, err := cremoteServer.client.ExtractDiviImages(tab, timeout)
|
||||
if err != nil {
|
||||
return &mcp.CallToolResult{
|
||||
Content: []mcp.Content{
|
||||
mcp.NewTextContent(fmt.Sprintf("Failed to extract Divi images: %v", err)),
|
||||
},
|
||||
IsError: true,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Format results as JSON
|
||||
resultJSON, err := json.MarshalIndent(result, "", " ")
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to marshal results: %w", err)
|
||||
}
|
||||
|
||||
return &mcp.CallToolResult{
|
||||
Content: []mcp.Content{
|
||||
mcp.NewTextContent(string(resultJSON)),
|
||||
},
|
||||
IsError: false,
|
||||
}, nil
|
||||
})
|
||||
|
||||
// Register web_extract_divi_content tool
|
||||
mcpServer.AddTool(mcp.Tool{
|
||||
Name: "web_extract_divi_content_cremotemcp",
|
||||
Description: "Extract text content and module data from Divi pages including module types, content, and styling. Returns 90-100% of visible content.",
|
||||
InputSchema: mcp.ToolInputSchema{
|
||||
Type: "object",
|
||||
Properties: map[string]any{
|
||||
"tab": map[string]any{
|
||||
"type": "string",
|
||||
"description": "Tab ID (optional, uses current tab)",
|
||||
},
|
||||
"url": map[string]any{
|
||||
"type": "string",
|
||||
"description": "Optional URL to navigate to before extraction",
|
||||
},
|
||||
"clear_cache": map[string]any{
|
||||
"type": "boolean",
|
||||
"description": "Clear browser cache before operation (default: false)",
|
||||
"default": false,
|
||||
},
|
||||
"timeout": map[string]any{
|
||||
"type": "integer",
|
||||
"description": "Timeout in seconds (default: 30)",
|
||||
"default": 30,
|
||||
},
|
||||
},
|
||||
},
|
||||
}, func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
|
||||
params, ok := request.Params.Arguments.(map[string]any)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("invalid arguments format")
|
||||
}
|
||||
|
||||
timeout := getIntParam(params, "timeout", 30)
|
||||
|
||||
// Handle optional navigation and cache clearing
|
||||
tab, err := handleOptionalNavigation(cremoteServer, params, timeout)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
result, err := cremoteServer.client.ExtractDiviContent(tab, timeout)
|
||||
if err != nil {
|
||||
return &mcp.CallToolResult{
|
||||
Content: []mcp.Content{
|
||||
mcp.NewTextContent(fmt.Sprintf("Failed to extract Divi content: %v", err)),
|
||||
},
|
||||
IsError: true,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Format results as JSON
|
||||
resultJSON, err := json.MarshalIndent(result, "", " ")
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to marshal results: %w", err)
|
||||
}
|
||||
|
||||
return &mcp.CallToolResult{
|
||||
Content: []mcp.Content{
|
||||
mcp.NewTextContent(string(resultJSON)),
|
||||
},
|
||||
IsError: false,
|
||||
}, nil
|
||||
})
|
||||
|
||||
// Start the server
|
||||
log.Printf("Cremote MCP server ready")
|
||||
if err := server.ServeStdio(mcpServer); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user