Skip to content

Commit 24fc041

Browse files
Fix bbox_tool validation error with explicit geometry format instructions
Addresses validation error where Claude was passing route geometry incorrectly to bounding_box_tool, causing input schema validation failures. Changes: - Added explicit instructions for extracting route LineString coordinates from directions_tool response as array of [lon, lat] pairs - SHORT routes: Clarified buffer_tool input format and how to get bbox from buffer polygon using bounding_box_tool - MEDIUM routes: Added explicit bounding_box_tool usage instructions with correct geometry format: {"geometry": [[lon1,lat1], [lon2,lat2], ...]} - VERY LONG routes: Changed to use proximity parameter instead of bbox to avoid coordinate extraction complexity - Added bbox format specification for category_search_tool: "minLon,minLat,maxLon,maxLat" This provides Claude with clear, unambiguous instructions about: 1. How to extract coordinates from directions response 2. Correct format for passing to buffer_tool and bounding_box_tool 3. How to use the resulting bbox with search tools Fixes MCP error -32602 validation failures on Leesburg to Herndon route. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 3e79a07 commit 24fc041

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

src/prompts/SearchAlongRoutePrompt.ts

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -85,29 +85,36 @@ Please follow these steps:
8585
8686
2. **Get the route**:
8787
- Use directions_tool with profile=${mode} to get the route geometry between the two points
88-
- Extract the route LineString geometry from the response
89-
- Note the total route distance
88+
- Extract the route LineString coordinates from the response (it will be an array of [lon, lat] pairs)
89+
- Note the total route distance in meters
9090
9191
3. **Create search corridor and find places** (choose approach based on route length):
9292
9393
**For SHORT routes (< 50km):** [RECOMMENDED - Most accurate]
94-
- Use buffer_tool on the full route geometry with distance=${buffer_meters} meters
95-
- Use category_search_tool or search_and_geocode_tool within the buffer's bounding box
96-
- Use point_in_polygon_tool to filter results to the corridor
94+
- Use buffer_tool on the route LineString coordinates with distance=${buffer_meters} meters
95+
* Pass the coordinates as: {"geometry": [[lon1,lat1], [lon2,lat2], ...], "distance": ${buffer_meters}, "units": "meters"}
96+
- The buffer result will be a Polygon
97+
- Use bounding_box_tool on the buffer polygon to get search bbox
98+
* Pass the polygon coordinates from the buffer result
99+
- Use category_search_tool with the bbox parameter (format: "minLon,minLat,maxLon,maxLat")
100+
- Use point_in_polygon_tool to filter results to the buffer corridor
97101
- This gives precise corridor filtering
98102
99103
**For MEDIUM routes (50-150km):** [PRAGMATIC - Balanced]
100-
- Calculate the route's bounding box (min/max lat/lon)
101-
- Use category_search_tool or search_and_geocode_tool with bbox parameter
102-
- Filter results by calculating distance to route (use distance_tool)
104+
- Use bounding_box_tool on the route LineString coordinates to get the route's bbox
105+
* Pass the route coordinates as: {"geometry": [[lon1,lat1], [lon2,lat2], ...]}
106+
- Use category_search_tool with the bbox parameter (format: "minLon,minLat,maxLon,maxLat")
107+
- Filter results by calculating distance to the closest route point (use distance_tool)
103108
- Keep only results within ${buffer_meters}m of the route
104109
- Note to user: "For this medium-length route, results are filtered to the general corridor"
105110
106111
**For VERY LONG routes (> 150km):** [SAMPLING - Most practical]
107-
- Sample 5-7 strategic points along the route (start, end, and evenly spaced middle points)
108-
- For each sample point, use category_search_tool with a small radius (5-10km)
109-
- Combine results from all sample points
110-
- Order by distance from start
112+
- Sample 5-7 strategic points evenly spaced along the route
113+
* Extract coordinates at indices: 0, len/6, 2*len/6, 3*len/6, 4*len/6, 5*len/6, len-1
114+
- For each sample point coordinate [lon, lat]:
115+
* Use category_search_tool with proximity parameter: "lon,lat" and limit results
116+
- Combine results from all sample points (remove duplicates if any)
117+
- Order by distance from start point
111118
- Note to user: "Due to the route length (X km), showing results near major points along the route rather than the full corridor"
112119
113120
**Why this three-tier approach:**

0 commit comments

Comments
 (0)