Skip to main content
Glama
jagan-shanmugam

OpenStreetMap MCP Server

find_ev_charging_stations

Locate nearby electric vehicle charging stations by entering coordinates and filtering by connector type or power requirements to plan trips and find charging stops.

Instructions

Locate electric vehicle charging stations near a specific location.

This specialized search tool identifies EV charging infrastructure within a specified distance from a location. Results can be filtered by connector type (Tesla, CCS, CHAdeMO, etc.) and minimum power delivery. Essential for EV owners planning trips or evaluating potential charging stops.

Args: latitude: Center point latitude (decimal degrees) longitude: Center point longitude (decimal degrees) radius: Search radius in meters (defaults to 5000m/5km) connector_types: Optional list of specific connector types to filter by (e.g., ["type2", "ccs", "tesla"]) min_power: Minimum charging power in kW

Returns: List of charging stations with: - Location name and operator - Available connector types - Charging speeds - Number of charging points - Access restrictions - Other relevant metadata

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
latitudeYes
longitudeYes
radiusNo
connector_typesNo
min_powerNo

Implementation Reference

  • The handler function decorated with @mcp.tool() that implements the find_ev_charging_stations tool. It queries the Overpass API for OSM charging stations within a bounding box derived from the center coordinates and radius, processes and filters the results based on connector types and minimum power, calculates haversine distances, and returns a structured dictionary with station details.
    async def find_ev_charging_stations(
        latitude: float,
        longitude: float,
        ctx: Context,
        radius: float = 5000,
        connector_types: List[str] = None,
        min_power: float = None
    ) -> Dict[str, Any]:
        """
        Locate electric vehicle charging stations near a specific location.
        
        This specialized search tool identifies EV charging infrastructure within a specified
        distance from a location. Results can be filtered by connector type (Tesla, CCS, CHAdeMO, etc.)
        and minimum power delivery. Essential for EV owners planning trips or evaluating potential
        charging stops.
        
        Args:
            latitude: Center point latitude (decimal degrees)
            longitude: Center point longitude (decimal degrees)
            radius: Search radius in meters (defaults to 5000m/5km)
            connector_types: Optional list of specific connector types to filter by
                            (e.g., ["type2", "ccs", "tesla"])
            min_power: Minimum charging power in kW
            
        Returns:
            List of charging stations with:
            - Location name and operator
            - Available connector types
            - Charging speeds
            - Number of charging points
            - Access restrictions
            - Other relevant metadata
        """
        osm_client = ctx.request_context.lifespan_context.osm_client
        
        # Convert radius to bounding box
        lat_delta = radius / 111000
        lon_delta = radius / (111000 * math.cos(math.radians(latitude)))
        
        bbox = (
            longitude - lon_delta,
            latitude - lat_delta,
            longitude + lon_delta,
            latitude + lat_delta
        )
        
        # Build Overpass query for EV charging stations
        overpass_url = "https://overpass-api.de/api/interpreter"
        
        query = f"""
        [out:json];
        (
            node["amenity"="charging_station"]({{bbox}});
            way["amenity"="charging_station"]({{bbox}});
        );
        out body;
        """
        
        query = query.replace("{bbox}", f"{bbox[1]},{bbox[0]},{bbox[3]},{bbox[2]}")
        
        async with aiohttp.ClientSession() as session:
            async with session.post(overpass_url, data={"data": query}) as response:
                if response.status == 200:
                    data = await response.json()
                    stations = data.get("elements", [])
                else:
                    raise Exception(f"Failed to find charging stations: {response.status}")
        
        # Process and filter results
        results = []
        for station in stations:
            tags = station.get("tags", {})
            
            # Get coordinates based on feature type
            coords = {}
            if station.get("type") == "node":
                coords = {
                    "latitude": station.get("lat"),
                    "longitude": station.get("lon")
                }
            elif "center" in station:
                coords = {
                    "latitude": station.get("center", {}).get("lat"),
                    "longitude": station.get("center", {}).get("lon")
                }
            
            # Skip if no valid coordinates
            if not coords:
                continue
            
            # Extract connector information
            connectors = []
            for key, value in tags.items():
                if key.startswith("socket:"):
                    connector_type = key.split(":", 1)[1]
                    connectors.append({
                        "type": connector_type,
                        "count": value if value.isdigit() else 1
                    })
            
            # Filter by connector type if specified
            if connector_types:
                has_matching_connector = False
                for connector in connectors:
                    if connector["type"] in connector_types:
                        has_matching_connector = True
                        break
                if not has_matching_connector:
                    continue
            
            # Extract power information
            power = None
            if "maxpower" in tags:
                try:
                    power = float(tags["maxpower"])
                except ValueError:
                    pass
            
            # Filter by minimum power if specified
            if min_power is not None and (power is None or power < min_power):
                continue
            
            # Calculate distance from search point
            from math import radians, sin, cos, sqrt, asin
            
            def haversine(lat1, lon1, lat2, lon2):
                R = 6371000  # Earth radius in meters
                dLat = radians(lat2 - lat1)
                dLon = radians(lon2 - lon1)
                a = sin(dLat/2)**2 + cos(radians(lat1)) * cos(radians(lat2)) * sin(dLon/2)**2
                c = 2 * asin(sqrt(a))
                return R * c
            
            distance = haversine(latitude, longitude, coords["latitude"], coords["longitude"])
            
            results.append({
                "id": station.get("id"),
                "name": tags.get("name", "Unnamed Charging Station"),
                "operator": tags.get("operator", "Unknown"),
                "coordinates": coords,
                "distance": round(distance, 1),
                "connectors": connectors,
                "capacity": tags.get("capacity", "Unknown"),
                "power": power,
                "fee": tags.get("fee", "Unknown"),
                "access": tags.get("access", "public"),
                "opening_hours": tags.get("opening_hours", "Unknown"),
                "address": {
                    "street": tags.get("addr:street", ""),
                    "housenumber": tags.get("addr:housenumber", ""),
                    "city": tags.get("addr:city", ""),
                    "postcode": tags.get("addr:postcode", "")
                },
                "tags": tags
            })
        
        # Sort by distance
        results.sort(key=lambda x: x["distance"])
        
        return {
            "query": {
                "latitude": latitude,
                "longitude": longitude,
                "radius": radius,
                "connector_types": connector_types,
                "min_power": min_power
            },
            "stations": results,
            "count": len(results)
        }
Behavior3/5

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

With no annotations provided, the description carries full burden. It describes the search behavior (distance-based, filterable) and output format, but doesn't disclose rate limits, authentication requirements, data freshness, or error conditions. The behavioral description is adequate but lacks operational details.

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 with purpose statement, specialized context, and organized parameter/return sections. Every sentence earns its place: the first states purpose, second explains specialization, third gives usage context, then clear parameter explanations, and finally output format. No wasted words.

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?

For a 5-parameter search tool with no annotations and no output schema, the description provides good coverage: clear purpose, usage context, detailed parameter semantics, and return value structure. The main gap is lack of operational constraints (rate limits, auth) that would be helpful given the specialized nature.

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

Parameters5/5

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

With 0% schema description coverage, the description fully compensates by explaining all 5 parameters in detail. It provides meaning beyond schema titles: clarifies latitude/longitude as 'center point', radius defaults and units, connector_types with examples, and min_power units. This adds substantial value beyond the bare schema.

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

Purpose5/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 as 'Locate electric vehicle charging stations near a specific location' with specific verb ('locate') and resource ('EV charging stations'). It distinguishes from siblings by focusing on EV infrastructure rather than general places, schools, parking, or routing.

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

Usage Guidelines4/5

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

The description provides clear context ('Essential for EV owners planning trips or evaluating potential charging stops') that indicates when to use this tool. However, it doesn't explicitly state when NOT to use it or name specific alternatives among the sibling tools (like find_nearby_places for general POIs).

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/jagan-shanmugam/open-streetmap-mcp'

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