Skip to main content
Glama

get_available_crs

Retrieve coordinate reference systems for geospatial analysis, enabling accurate coordinate transformations and spatial measurements in GIS operations.

Instructions

Get list of available CRS.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function for the 'get_available_crs' MCP tool. It fetches a list of available CRS from PyProj's EPSG database (limited to first 100 for performance), extracts name and type for each, with fallback to well-known CRS if none found.
    @gis_mcp.tool()
    def get_available_crs() -> Dict[str, Any]:
        """Get list of available CRS."""
        try:
            import pyproj
            from pyproj.database import get_codes
            from pyproj.enums import PJType
            
            crs_list = []
            # Get a sample of common EPSG codes (limit to avoid huge lists)
            epsg_codes = list(get_codes("EPSG", PJType.CRS))[:100]  # Limit to first 100 for performance
            
            for code in epsg_codes:
                try:
                    # Directly create CRS and get info without calling the tool function
                    crs_obj = pyproj.CRS.from_epsg(int(code))
                    crs_list.append({
                        "auth_name": "EPSG",
                        "code": str(code),
                        "name": crs_obj.name,
                        "type": crs_obj.type_name
                    })
                except Exception as ex:
                    # Skip invalid CRS codes
                    logger.debug(f"Skipping EPSG:{code}: {str(ex)}")
                    continue
            
            if not crs_list:
                # Fallback: return some well-known CRS
                well_known_crs = [
                    {"auth_name": "EPSG", "code": "4326", "name": "WGS 84", "type": "Geographic 2D CRS"},
                    {"auth_name": "EPSG", "code": "3857", "name": "WGS 84 / Pseudo-Mercator", "type": "Projected CRS"},
                    {"auth_name": "EPSG", "code": "4269", "name": "NAD83", "type": "Geographic 2D CRS"},
                ]
                crs_list = well_known_crs
            
            return {
                "status": "success",
                "crs_list": crs_list,
                "message": "Available CRS list retrieved successfully"
            }
        except Exception as e:
            logger.error(f"Error getting available CRS: {str(e)}")
            raise ValueError(f"Failed to get available CRS: {str(e)}")

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