maps_bicycling_by_coordinates
Plan bicycle routes between coordinates using Amap data, calculating distance, duration, and turn-by-turn navigation while considering road conditions.
Instructions
Plans a bicycle route between two coordinates.
Args:
origin_coordinates (str): Starting point coordinates in the format "longitude,latitude" (e.g. "116.434307,39.90909")
destination_coordinates (str): Ending point coordinates in the format "longitude,latitude" (e.g. "116.434307,39.90909")
Returns:
Dict[str, Any]: Route information including distance, duration, and turn-by-turn instructions.
Considers bridges, one-way streets, and road closures. Supports routes up to 500km.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| origin_coordinates | Yes | ||
| destination_coordinates | Yes |
Implementation Reference
- amap_mcp_server/server.py:199-251 (handler)The handler function that implements the core logic for planning a bicycle route between two coordinates by calling the Amap Maps API v4 direction bicycling endpoint. It handles the HTTP request, parses the JSON response, structures the paths and steps data, and manages errors.def maps_bicycling_by_coordinates(origin_coordinates: str, destination_coordinates: str) -> Dict[str, Any]: """Plans a bicycle route between two coordinates. Args: origin_coordinates (str): Starting point coordinates in the format "longitude,latitude" (e.g. "116.434307,39.90909") destination_coordinates (str): Ending point coordinates in the format "longitude,latitude" (e.g. "116.434307,39.90909") Returns: Dict[str, Any]: Route information including distance, duration, and turn-by-turn instructions. Considers bridges, one-way streets, and road closures. Supports routes up to 500km. """ try: response = requests.get( "https://restapi.amap.com/v4/direction/bicycling", params={ "key": AMAP_MAPS_API_KEY, "origin": origin_coordinates, "destination": destination_coordinates } ) response.raise_for_status() data = response.json() if data.get("errcode") != 0: return {"error": f"Direction bicycling failed: {data.get('info') or data.get('infocode')}"} paths = [] for path in data["data"]["paths"]: steps = [] for step in path["steps"]: steps.append({ "instruction": step.get("instruction"), "road": step.get("road"), "distance": step.get("distance"), "orientation": step.get("orientation"), "duration": step.get("duration") }) paths.append({ "distance": path.get("distance"), "duration": path.get("duration"), "steps": steps }) return { "data": { "origin": data["data"]["origin"], "destination": data["data"]["destination"], "paths": paths } } except requests.exceptions.RequestException as e: return {"error": f"Request failed: {str(e)}"}
- amap_mcp_server/server.py:198-198 (registration)The @mcp.tool() decorator registers the maps_bicycling_by_coordinates function as an MCP tool with FastMCP, automatically generating the tool schema from the function signature and docstring.@mcp.tool()
- amap_mcp_server/server.py:200-208 (schema)The docstring provides the detailed description used by FastMCP to generate the JSON schema for the tool's input parameters and output format."""Plans a bicycle route between two coordinates. Args: origin_coordinates (str): Starting point coordinates in the format "longitude,latitude" (e.g. "116.434307,39.90909") destination_coordinates (str): Ending point coordinates in the format "longitude,latitude" (e.g. "116.434307,39.90909") Returns: Dict[str, Any]: Route information including distance, duration, and turn-by-turn instructions. Considers bridges, one-way streets, and road closures. Supports routes up to 500km.
- amap_mcp_server/server.py:179-179 (helper)Usage of maps_bicycling_by_coordinates within the maps_bicycling_by_address tool to handle coordinate-based routing after geocoding addresses.route_result = maps_bicycling_by_coordinates(origin_location, destination_location)