Skip to main content
Glama
mahdin75

GeoServer MCP Server

generate_map

Create custom map images by specifying layers, styles, bounding box, dimensions, and format using WMS GetMap functionality in the GeoServer MCP Server.

Instructions

Generate a map image using WMS GetMap.

Args:
    layers: List of layers to include (format: workspace:layer)
    styles: Optional styles to apply (one per layer)
    bbox: Bounding box [minx, miny, maxx, maxy]
    width: Image width in pixels
    height: Image height in pixels
    format: Image format (png, jpeg, etc.)

Returns:
    Dict with map information and URL

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
bboxNo
formatNopng
heightNo
layersYes
stylesNo
widthNo

Implementation Reference

  • The core handler function for the 'generate_map' MCP tool. Decorated with @mcp.tool() for registration. Constructs a WMS GetMap request URL using the provided layers, styles, bounding box, and rendering parameters, returning a dictionary with the map URL and parameters.
    @mcp.tool()
    def generate_map(
        layers: List[str],
        styles: Optional[List[str]] = None,
        bbox: Optional[List[float]] = None,
        width: int = 800,
        height: int = 600,
        format: str = "png"
    ) -> Dict[str, Any]:
        """Generate a map image using WMS GetMap.
        
        Args:
            layers: List of layers to include (format: workspace:layer)
            styles: Optional styles to apply (one per layer)
            bbox: Bounding box [minx, miny, maxx, maxy]
            width: Image width in pixels
            height: Image height in pixels
            format: Image format (png, jpeg, etc.)
        
        Returns:
            Dict with map information and URL
        """
        geo = get_geoserver()
        if geo is None:
            raise ValueError("Not connected to GeoServer")
        
        if not layers:
            raise ValueError("At least one layer must be specified")
        
        # Validate parameters
        if styles and len(styles) != len(layers):
            raise ValueError("Number of styles must match number of layers")
        
        if not bbox:
            bbox = [-180, -90, 180, 90]  # Default to global extent
        
        if len(bbox) != 4:
            raise ValueError("Bounding box must have 4 coordinates: [minx, miny, maxx, maxy]")
        
        # Valid formats
        valid_formats = ["png", "jpeg", "gif", "tiff", "pdf"]
        if format.lower() not in valid_formats:
            raise ValueError(f"Invalid format. Must be one of: {', '.join(valid_formats)}")
        
        try:
            # Construct WMS GetMap URL
            url = f"{geo.service_url}/wms"
            params = {
                "service": "WMS",
                "version": "1.3.0",
                "request": "GetMap",
                "format": f"image/{format}",
                "layers": ",".join(layers),
                "width": width,
                "height": height,
                "crs": "EPSG:4326",
                "bbox": ",".join(map(str, bbox))
            }
            
            # Add styles if provided
            if styles:
                params["styles"] = ",".join(styles)
                
            # Construct the full URL
            import urllib.parse
            query_string = urllib.parse.urlencode(params)
            map_url = f"{url}?{query_string}"
            
            return {
                "url": map_url,
                "width": width,
                "height": height,
                "format": format,
                "layers": layers,
                "styles": styles,
                "bbox": bbox
            }
        except Exception as e:
            logger.error(f"Error generating map: {str(e)}")
            raise ValueError(f"Failed to generate map: {str(e)}")
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions that the tool returns 'Dict with map information and URL', which hints at output format, but lacks details on authentication needs, rate limits, error conditions, or whether it's a read-only operation. For a tool that generates images (potentially resource-intensive), this is a significant gap in transparency.

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

Conciseness5/5

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

The description is well-structured and appropriately sized. It starts with a clear purpose statement, followed by a bullet-point list of parameters with brief explanations, and ends with return information. Every sentence earns its place, with no redundant or verbose content.

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?

Given the tool's complexity (6 parameters, no annotations, no output schema), the description is moderately complete. It covers parameter semantics effectively but lacks behavioral context (e.g., performance implications, error handling). Without an output schema, the return statement ('Dict with map information and URL') is vague, leaving the agent uncertain about the exact response structure.

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

Parameters4/5

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

The description adds substantial meaning beyond the input schema, which has 0% description coverage. It explains each parameter's purpose (e.g., 'layers: List of layers to include (format: workspace:layer)', 'bbox: Bounding box [minx, miny, maxx, maxy]'), including format hints and optionality. This compensates well for the schema's lack of descriptions, though it doesn't cover all nuances like default values or null handling.

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 tool's purpose: 'Generate a map image using WMS GetMap.' It specifies the verb ('generate') and resource ('map image'), and mentions the underlying protocol (WMS GetMap). However, it doesn't explicitly differentiate from sibling tools like 'query_features' or 'get_layer_info', which might also involve map-related operations.

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?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention sibling tools like 'query_features' (which might retrieve specific data) or 'get_layer_info' (which might provide metadata), leaving the agent to infer usage context. There are no explicit when/when-not instructions or named alternatives.

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