Skip to main content
Glama
mahdin75

GeoServer MCP Server

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

TableJSON Schema
NameRequiredDescriptionDefault
layerYes
workspaceYes

Implementation Reference

  • 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)}")
  • 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
  • The @mcp.tool() decorator registers the get_layer_info function as an MCP tool.
    @mcp.tool()
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. While 'Get detailed information' implies a read-only operation, the description doesn't address important behavioral aspects like authentication requirements, rate limits, error conditions, or what specific metadata is returned beyond 'Dict with layer metadata'.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured with clear sections for Args and Returns, and the core purpose is stated upfront. It's appropriately sized for a simple lookup tool, though the 'Returns' section could be more informative given the lack of output schema.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple read operation with 2 parameters and no annotations, the description is adequate but has clear gaps. It explains what the tool does and documents parameters, but doesn't provide enough behavioral context or output details. With no output schema, the vague 'Dict with layer metadata' return description is insufficient for understanding what information will be available.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description explicitly lists both parameters ('workspace' and 'layer') with brief explanations, which adds value beyond the schema's 0% description coverage. However, it doesn't provide format details, examples, or constraints for these parameters, so it only partially compensates for the schema's lack of descriptions.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('Get detailed information') and resource ('about a layer'), making the purpose immediately understandable. However, it doesn't differentiate from sibling tools like 'list_layers' or 'query_features' which might also provide layer information, so it doesn't reach the highest score.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided about when to use this tool versus alternatives. With siblings like 'list_layers' and 'query_features' that might overlap in functionality, the description offers no context about when this specific tool is appropriate versus those other options.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

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