create_workspace
Generate a new workspace in GeoServer to organize and manage geospatial data. The tool allows users to define a workspace name, enabling structured access and configuration of spatial resources.
Instructions
Create a new workspace in GeoServer.
Args:
workspace: Name of the workspace to create
Returns:
Dict with status and result information
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| workspace | Yes |
Implementation Reference
- src/geoserver_mcp/main.py:133-170 (handler)The core handler function for the 'create_workspace' tool, decorated with @mcp.tool() for registration. It checks if the workspace exists, creates it via GeoServer REST API if not, and returns status information.@mcp.tool() def create_workspace(workspace: str) -> Dict[str, Any]: """Create a new workspace in GeoServer. Args: workspace: Name of the workspace to create Returns: Dict with status and result information """ geo = get_geoserver() if geo is None: raise ValueError("Not connected to GeoServer") if not workspace: raise ValueError("Workspace name is required") try: # Check if workspace already exists existing_workspaces = geo.get_workspaces() if workspace in existing_workspaces: return { "status": "info", "workspace": workspace, "message": f"Workspace '{workspace}' already exists" } # Use the actual GeoServer REST API to create a workspace geo.create_workspace(workspace) return { "status": "success", "workspace": workspace, "message": f"Workspace '{workspace}' created successfully" } except Exception as e: logger.error(f"Error creating workspace: {str(e)}") raise ValueError(f"Failed to create workspace: {str(e)}")