list_workspaces
Retrieve available workspaces in GeoServer to manage and organize geospatial data effectively through the MCP server.
Instructions
List available workspaces in GeoServer.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/geoserver_mcp/main.py:118-131 (handler)The core handler function for the 'list_workspaces' MCP tool. It connects to GeoServer via get_geoserver(), retrieves the list of workspaces using geo.get_workspaces(), and returns them as a List[str]. Includes error handling with logging and raises ValueError on failure. The @mcp.tool() decorator registers this function as an MCP tool.@mcp.tool() def list_workspaces() -> List[str]: """List available workspaces in GeoServer.""" geo = get_geoserver() if geo is None: raise ValueError("Not connected to GeoServer") try: # Use the actual GeoServer REST API to list workspaces workspaces = geo.get_workspaces() return workspaces except Exception as e: logger.error(f"Error listing workspaces: {str(e)}") raise ValueError(f"Failed to list workspaces: {str(e)}")