list_layers
Retrieve a list of layers in GeoServer, optionally filtered by workspace. Returns detailed layer information for geospatial data management and analysis.
Instructions
List layers in GeoServer, optionally filtered by workspace.
Args:
workspace: Optional workspace to filter layers
Returns:
List of layer information dictionaries
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| workspace | No |
Implementation Reference
- src/geoserver_mcp/main.py:198-222 (handler)The handler function for the 'list_layers' MCP tool. It connects to GeoServer via the Geoserver client, lists layers (optionally filtered by workspace), and returns a list of layer dictionaries. The @mcp.tool() decorator registers it as an MCP tool.@mcp.tool() def list_layers(workspace: Optional[str] = None) -> List[Dict[str, Any]]: """List layers in GeoServer, optionally filtered by workspace. Args: workspace: Optional workspace to filter layers Returns: List of layer information dictionaries """ geo = get_geoserver() if geo is None: raise ValueError("Not connected to GeoServer") try: # Use the actual GeoServer REST API to list layers if workspace: layers = geo.get_layers(workspace) else: layers = geo.get_layers() return layers except Exception as e: logger.error(f"Error listing layers: {str(e)}") raise ValueError(f"Failed to list layers: {str(e)}")