Skip to main content
Glama

adbscan

Perform adaptive DBSCAN clustering on geospatial data from shapefiles to identify spatial patterns and groupings in geographic coordinates.

Instructions

Adaptive DBSCAN clustering (requires coordinates, no dependent_var).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
shapefile_pathYes
dependent_varNo
target_crsNoEPSG:4326
distance_thresholdNo
epsNo
min_samplesNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Implementation of the adbscan MCP tool handler using esda.adbscan.ADBSCAN for adaptive density-based clustering on shapefile coordinates.
    @gis_mcp.tool()
    def adbscan(shapefile_path: str, dependent_var: str = None, target_crs: str = "EPSG:4326",
                distance_threshold: float = 100000, eps: float = 0.1, min_samples: int = 5) -> Dict[str, Any]:
        """Adaptive DBSCAN clustering (requires coordinates, no dependent_var)."""
        if not os.path.exists(shapefile_path):
            return {"status": "error", "message": f"Shapefile not found: {shapefile_path}"}
        gdf = gpd.read_file(shapefile_path)
        gdf = gdf.to_crs(target_crs)
    
        coords = np.array(list(gdf.geometry.apply(lambda g: (g.x, g.y))))
        import esda
        # ADBSCAN constructor - check actual signature to avoid parameter conflicts
        # Try different calling patterns based on actual API
        try:
            # First try: eps and min_samples as keyword arguments
            stat = esda.adbscan.ADBSCAN(coords, eps=eps, min_samples=min_samples)
        except TypeError as e:
            if "multiple values for argument 'eps'" in str(e):
                # eps might be positional - try as positional argument
                try:
                    stat = esda.adbscan.ADBSCAN(coords, eps, min_samples)
                except Exception:
                    # Last resort: try with just coords and keyword args without eps
                    stat = esda.adbscan.ADBSCAN(coords, min_samples=min_samples)
            else:
                raise
    
        preview = gdf[['geometry']].head(5).copy()
        preview['geometry'] = preview['geometry'].apply(lambda g: g.wkt)
    
        # ADBSCAN attributes - check for available attributes
        labels_val = None
        if hasattr(stat, "labels_"):
            labels_val = stat.labels_.tolist() if hasattr(stat.labels_, "tolist") else list(stat.labels_)
        elif hasattr(stat, "labels"):
            labels_val = stat.labels.tolist() if hasattr(stat.labels, "tolist") else list(stat.labels)
        
        core_indices_val = None
        if hasattr(stat, "core_sample_indices_"):
            core_indices_val = stat.core_sample_indices_.tolist() if hasattr(stat.core_sample_indices_, "tolist") else list(stat.core_sample_indices_)
        elif hasattr(stat, "core_sample_indices"):
            core_indices_val = stat.core_sample_indices.tolist() if hasattr(stat.core_sample_indices, "tolist") else list(stat.core_sample_indices)
        
        components_val = None
        if hasattr(stat, "components_"):
            components_val = stat.components_.tolist() if hasattr(stat.components_, "tolist") else list(stat.components_)
        elif hasattr(stat, "components"):
            components_val = stat.components.tolist() if hasattr(stat.components, "tolist") else list(stat.components)
        
        return {
            "status": "success",
            "message": f"A-DBSCAN clustering completed successfully (eps={eps}, min_samples={min_samples})",
            "result": {
                "labels": labels_val,
                "core_sample_indices": core_indices_val,
                "components": components_val,
                "data_preview": preview.to_dict(orient="records")
            }
        }
  • Resource endpoint listing available ESDA operations, including adbscan, for discovery.
    @gis_mcp.resource("gis://operations/esda")
    def get_spatial_operations() -> Dict[str, List[str]]:
        """List available spatial analysis operations. This is for esda library. They are using pysal library."""
        return {
            "operations": [
                "getis_ord_g",
                "morans_i",
                "gearys_c",
                "gamma_statistic",
                "moran_local",
                "getis_ord_g_local",
                "join_counts",
                "join_counts_local",
                "adbscan"
            ]
        }
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 the adaptive nature of DBSCAN and the requirement for coordinates, but doesn't describe what the tool actually does behaviorally: whether it modifies data, creates new files, requires specific permissions, has performance characteristics, or what the clustering output looks like. For a 6-parameter tool with no annotation coverage, this is a significant gap.

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 extremely concise at just 8 words, front-loaded with the core purpose, and every word earns its place. There's zero waste or redundancy in the phrasing.

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

Completeness2/5

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

Given the complexity of a 6-parameter clustering tool with no annotations, 0% schema description coverage, and an output schema (which helps but doesn't compensate for missing behavioral context), the description is incomplete. It doesn't explain what adaptive DBSCAN means, how parameters interact, what the tool produces, or when to use it versus alternatives. The presence of an output schema is helpful but doesn't address the fundamental gaps.

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

Parameters2/5

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

With 0% schema description coverage for all 6 parameters, the description must compensate but only mentions 'coordinates' (implied by shapefile_path) and 'no dependent_var'. It doesn't explain what any of the parameters mean, their purposes, or how they affect the clustering. The description adds minimal value beyond what's implied by the tool name.

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 performs 'Adaptive DBSCAN clustering' and specifies it requires coordinates and no dependent variable. This is a specific verb+resource combination that distinguishes it from many sibling tools focused on geometric operations, raster processing, or statistical analysis. However, it doesn't explicitly differentiate from potential clustering alternatives in the sibling list.

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

Usage Guidelines3/5

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

The description provides implied usage guidance by stating 'requires coordinates, no dependent_var', which suggests when this tool is appropriate (for coordinate-based clustering without dependent variables). However, it doesn't explicitly state when to use this versus other clustering or spatial analysis tools in the sibling list, nor does it provide exclusion criteria 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

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