Skip to main content
Glama
mahdin75

GeoServer MCP Server

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
NameRequiredDescriptionDefault
workspaceYes

Implementation Reference

  • 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)}")
Install Server

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/mahdin75/geoserver-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server