create_style
Generate SLD styles for GeoServer by specifying a style name and SLD XML content. Optional workspace inclusion allows for organized style management within GeoServer.
Instructions
Create a new SLD style in GeoServer.
Args:
name: Name for the style
sld: SLD XML content
workspace: Optional workspace for the style
Returns:
Dict with status and style information
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | ||
| sld | Yes | ||
| workspace | No |
Implementation Reference
- src/geoserver_mcp/main.py:452-492 (handler)MCP tool handler implementation for 'create_style'. Decorated with @mcp.tool(), connects to GeoServer, validates inputs, calls the underlying Geoserver client to create the style, and returns success status.@mcp.tool() def create_style(name: str, sld: str, workspace: Optional[str] = None) -> Dict[str, Any]: """Create a new SLD style in GeoServer. Args: name: Name for the style sld: SLD XML content workspace: Optional workspace for the style Returns: Dict with status and style information """ geo = get_geoserver() if geo is None: raise ValueError("Not connected to GeoServer") if not name: raise ValueError("Style name is required") if not sld: raise ValueError("SLD content is required") try: # Use the actual GeoServer REST API to create a style if workspace: geo.create_style(name, sld, workspace) message = f"Style '{name}' created in workspace '{workspace}'" else: geo.create_style(name, sld) message = f"Global style '{name}' created" return { "status": "success", "name": name, "workspace": workspace if workspace else "global", "message": message } except Exception as e: logger.error(f"Error creating style: {str(e)}") raise ValueError(f"Failed to create style: {str(e)}")