Skip to main content
Glama

snap_geometry

Aligns one geometry to another within a specified tolerance to correct positional inaccuracies in spatial data.

Instructions

Snap one geometry to another using shapely.ops.snap. Args: geometry1: WKT string of the geometry to be snapped. geometry2: WKT string of the reference geometry. tolerance: Distance tolerance for snapping. Returns: Dictionary with status, message, and snapped geometry as WKT.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
geometry1Yes
geometry2Yes
toleranceYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The core handler function for the 'snap_geometry' tool. It is registered via the @gis_mcp.tool() decorator and implements snapping two geometries using Shapely's snap operation with the given tolerance. Includes input validation implicitly through type hints and docstring, and returns WKT geometry or error.
    @gis_mcp.tool()
    def snap_geometry(geometry1: str, geometry2: str, tolerance: float) -> Dict[str, Any]:
        """
        Snap one geometry to another using shapely.ops.snap.
        Args:
            geometry1: WKT string of the geometry to be snapped.
            geometry2: WKT string of the reference geometry.
            tolerance: Distance tolerance for snapping.
        Returns:
            Dictionary with status, message, and snapped geometry as WKT.
        """
        try:
            from shapely import wkt
            from shapely.ops import snap
            geom1 = wkt.loads(geometry1)
            geom2 = wkt.loads(geometry2)
            snapped = snap(geom1, geom2, tolerance)
            return {
                "status": "success",
                "geometry": snapped.wkt,
                "message": "Geometry snapped successfully"
            }
        except Exception as e:
            logger.error(f"Error in snap_geometry: {str(e)}")
            return {"status": "error", "message": str(e)}
  • MCP resource that lists 'snap_geometry' among available Shapely utility operations, serving as a discovery mechanism for the tool.
    @gis_mcp.resource("gis://operations/shapely_util")
    def get_shapely_util_operations() -> Dict[str, List[str]]:
        """List available Shapely utility/advanced operations."""
        return {
            "operations": [
                "snap_geometry",
                "nearest_point_on_geometry",
                "normalize_geometry",
                "geometry_to_geojson",
                "geojson_to_geometry"
            ]
        }
  • Error logging specific to snap_geometry, but minor.
    logger.error(f"Error in snap_geometry: {str(e)}")
    return {"status": "error", "message": str(e)}
Behavior3/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 the underlying library (shapely.ops.snap) and describes the return format, which adds useful context beyond basic parameters. However, it doesn't cover important behavioral aspects such as error handling (e.g., invalid WKT strings), performance implications, or how snapping affects geometry properties (e.g., topology). This leaves gaps for a mutation-like operation.

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 and appropriately sized. It front-loads the core purpose in the first sentence, followed by a clear breakdown of args and returns. There's no wasted text, and each section earns its place. A minor deduction is made because the title is null, slightly reducing overall structure, but the description itself is efficient.

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

Completeness4/5

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

Given the tool's moderate complexity (3 parameters, no annotations, but with an output schema), the description is reasonably complete. It explains the purpose, parameters, and return format, and the output schema handles return values. However, it lacks details on error cases, performance, or integration with sibling tools, which would be beneficial for full contextual understanding in a geometry-heavy server.

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 schema description coverage is 0%, so the description must compensate. It provides clear semantics for all three parameters: 'geometry1' as 'WKT string of the geometry to be snapped', 'geometry2' as 'WKT string of the reference geometry', and 'tolerance' as 'Distance tolerance for snapping'. This adds meaningful context beyond the bare schema types. However, it doesn't specify units for tolerance or examples of valid WKT formats, preventing a perfect score.

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: 'Snap one geometry to another using shapely.ops.snap.' It specifies the verb ('snap') and resource ('geometry'), and mentions the library (shapely.ops.snap) for context. However, it doesn't explicitly differentiate this tool from its many sibling geometry tools (e.g., 'nearest_point_on_geometry', 'translate_geometry'), which would require a 5.

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 lacks context about typical use cases (e.g., aligning geometries for spatial analysis), prerequisites, or comparisons to sibling tools like 'nearest_point_on_geometry' or 'translate_geometry'. The only implicit usage hint is the function name, but this is insufficient for clear decision-making.

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

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/gis-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server