get_layer_info
Retrieve comprehensive metadata for a specific layer in GeoServer by providing the workspace and layer name. Returns a dictionary with detailed layer information for analysis or integration.
Instructions
Get detailed information about a layer.
Args:
workspace: The workspace containing the layer
layer: The name of the layer
Returns:
Dict with layer metadata
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| layer | Yes | ||
| workspace | Yes |
Input Schema (JSON Schema)
{
"properties": {
"layer": {
"title": "Layer",
"type": "string"
},
"workspace": {
"title": "Workspace",
"type": "string"
}
},
"required": [
"workspace",
"layer"
],
"title": "get_layer_infoArguments",
"type": "object"
}
Implementation Reference
- src/geoserver_mcp/main.py:172-197 (handler)The primary handler function implementing the logic for the 'get_layer_info' tool. It connects to GeoServer, validates inputs, and fetches layer metadata using the Geoserver client library.@mcp.tool() def get_layer_info(workspace: str, layer: str) -> Dict[str, Any]: """Get detailed information about a layer. Args: workspace: The workspace containing the layer layer: The name of the layer Returns: Dict with layer metadata """ geo = get_geoserver() if geo is None: raise ValueError("Not connected to GeoServer") if not workspace or not layer: raise ValueError("Both workspace and layer name are required") try: # Use the actual GeoServer REST API to get layer information layer_info = geo.get_layer(layer, workspace) return layer_info except Exception as e: logger.error(f"Error getting layer info: {str(e)}") raise ValueError(f"Failed to get layer info: {str(e)}")
- src/geoserver_mcp/main.py:32-45 (helper)Helper utility function that initializes and returns the GeoServer client connection, used by the get_layer_info handler and other tools.def get_geoserver(): """Get the GeoServer connection using environment variables or command-line arguments.""" url = os.environ.get("GEOSERVER_URL", "http://localhost:8080/geoserver") username = os.environ.get("GEOSERVER_USER", "admin") password = os.environ.get("GEOSERVER_PASSWORD", "geoserver") try: geo = Geoserver(url, username=username, password=password) logger.info(f"Connected to GeoServer at {url}") return geo except Exception as e: logger.error(f"Failed to connect to GeoServer: {str(e)}") return None
- src/geoserver_mcp/main.py:172-172 (registration)The @mcp.tool() decorator registers the get_layer_info function as an MCP tool.@mcp.tool()