delete_resource
Remove specific resources like workspaces, layers, or styles from GeoServer by specifying the resource type, workspace, and name.
Instructions
Delete a resource from GeoServer.
Args:
resource_type: Type of resource to delete (workspace, layer, style, etc.)
workspace: The workspace containing the resource
name: The name of the resource
Returns:
Dict with status and result information
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | ||
| resource_type | Yes | ||
| workspace | Yes |
Implementation Reference
- src/geoserver_mcp/main.py:260-306 (handler)Implementation of the delete_resource tool handler, including registration via @mcp.tool() decorator. Handles deletion of various GeoServer resources (workspace, layer, datastore, style, coverage) using the GeoServer REST API.@mcp.tool() def delete_resource(resource_type: str, workspace: str, name: str) -> Dict[str, Any]: """Delete a resource from GeoServer. Args: resource_type: Type of resource to delete (workspace, layer, style, etc.) workspace: The workspace containing the resource name: The name of the resource Returns: Dict with status and result information """ geo = get_geoserver() if geo is None: raise ValueError("Not connected to GeoServer") if not resource_type or not name: raise ValueError("Resource type and name are required") # Validate resource type valid_types = ["workspace", "layer", "datastore", "style", "coverage"] if resource_type.lower() not in valid_types: raise ValueError(f"Invalid resource type. Must be one of: {', '.join(valid_types)}") try: # Use the appropriate GeoServer REST API method based on resource_type if resource_type.lower() == "workspace": geo.delete_workspace(name) elif resource_type.lower() == "layer": geo.delete_layer(name, workspace) elif resource_type.lower() == "datastore": geo.delete_datastore(name, workspace) elif resource_type.lower() == "style": geo.delete_style(name, workspace) elif resource_type.lower() == "coverage": geo.delete_coverage(name, workspace) return { "status": "success", "type": resource_type, "name": name, "workspace": workspace if workspace else "global", "message": f"{resource_type.capitalize()} '{name}' deleted successfully" } except Exception as e: logger.error(f"Error deleting resource: {str(e)}") raise ValueError(f"Failed to delete resource: {str(e)}")