Skip to main content
Glama

find_ev_charging_stations

Locate nearby electric vehicle charging stations by specifying coordinates, radius, and connector types. Filter results by minimum power delivery to plan trips or identify optimal 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
connector_typesNo
latitudeYes
longitudeYes
min_powerNo
radiusNo

Implementation Reference

  • The handler function decorated with @mcp.tool() that implements the logic for finding EV charging stations. It constructs a bounding box from lat/lon/radius, queries the Overpass API for charging stations, extracts connector info from tags, filters by connector_types and min_power, computes haversine distances, and returns a sorted list of stations with 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) }

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