-
-
Notifications
You must be signed in to change notification settings - Fork 7
Fix: Grok 4 compatibility for Mapbox MCP and model selection #358
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -250,24 +250,24 @@ Uses the Mapbox Search Box Text Search API endpoint to power searching for and g | |
| const prefer = (...cands: string[]) => cands.find(n => names.has(n)); | ||
|
|
||
| switch (queryType) { | ||
| case 'directions': return prefer('directions_tool') | ||
| case 'distance': return prefer('matrix_tool'); | ||
| case 'search': return prefer( 'isochrone_tool','category_search_tool') || 'poi_search_tool'; | ||
| case 'map': return prefer('static_map_image_tool') | ||
| case 'reverse': return prefer('reverse_geocode_tool'); | ||
| case 'geocode': return prefer('forward_geocode_tool'); | ||
| case 'directions': return prefer('calculate_distance') | ||
| case 'distance': return prefer('calculate_distance'); | ||
| case 'search': return prefer('search_nearby_places'); | ||
| case 'map': return prefer('generate_map_link') | ||
| case 'reverse': return prefer('geocode_location'); | ||
| case 'geocode': return prefer('geocode_location'); | ||
| } | ||
| })(); | ||
|
|
||
| // Build arguments | ||
| const toolArgs = (() => { | ||
| switch (queryType) { | ||
| case 'directions': return { waypoints: [params.origin, params.destination], includeMapPreview: includeMap, profile: params.mode }; | ||
| case 'distance': return { places: [params.origin, params.destination], includeMapPreview: includeMap, mode: params.mode || 'driving' }; | ||
| case 'reverse': return { searchText: `${params.coordinates.latitude},${params.coordinates.longitude}`, includeMapPreview: includeMap, maxResults: params.maxResults || 5 }; | ||
| case 'search': return { searchText: params.query, includeMapPreview: includeMap, maxResults: params.maxResults || 5, ...(params.coordinates && { proximity: `${params.coordinates.latitude},${params.coordinates.longitude}` }), ...(params.radius && { radius: params.radius }) }; | ||
| case 'geocode': | ||
| case 'map': return { searchText: params.location, includeMapPreview: includeMap, maxResults: queryType === 'geocode' ? params.maxResults || 5 : undefined }; | ||
| case 'directions': return { from: params.origin, to: params.destination, profile: params.mode, includeRouteMap: includeMap }; | ||
| case 'distance': return { from: params.origin, to: params.destination, profile: params.mode || 'driving', includeRouteMap: includeMap }; | ||
| case 'reverse': return { query: `${params.coordinates.latitude},${params.coordinates.longitude}`, includeMapPreview: includeMap, maxResults: params.maxResults || 5 }; | ||
| case 'search': return { location: params.location, query: params.query, radius: params.radius || 1000, limit: params.maxResults || 5, includeMapPreview: includeMap }; | ||
| case 'geocode': return { query: params.location, includeMapPreview: includeMap, maxResults: params.maxResults || 5 }; | ||
| case 'map': return { location: params.location, includeMapPreview: includeMap }; | ||
| } | ||
| })(); | ||
|
Comment on lines
+265
to
272
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chainVerify argument schemas match the new MCP server interface. The argument construction has been updated significantly to align with the new MCP tool interfaces. Each query type now provides tailored arguments with appropriate defaults. However, please verify that these argument names and structures match the expected input schema for the new MCP server tools. Run the following script to check if there are any callers of 🏁 Script executed: #!/bin/bash
# Find all usages of geospatialTool to verify they're compatible with new schema
ast-grep --pattern 'geospatialTool($$$)'
# Also search for files that import geospatialTool
rg -n -B 2 -A 10 "import.*geospatialTool" --type=ts --type=tsxLength of output: 261 🏁 Script executed: #!/bin/bash
# Find the geospatialTool function definition
rg -n -A 30 "export.*function.*geospatialTool|const.*geospatialTool.*=" lib/agents/tools/geospatial.tsx --type=ts --type=tsx
# Find where geospatialQueryTool is called/invoked
rg -n -B 3 -A 3 "geospatialQueryTool\(" --type=ts --type=tsxLength of output: 55 🏁 Script executed: #!/bin/bash
# Find the geospatialTool function definition - search all tsx/ts files without type flag
rg -n -A 35 "export.*function.*geospatialTool|const.*geospatialTool.*=" -g "*.tsx" -g "*.ts"
# Find where geospatialQueryTool is called/invoked
rg -n -B 3 -A 3 "geospatialQueryTool\(" -g "*.tsx" -g "*.ts"
# Also check the full context around the argument construction in geospatial.tsx
cat lib/agents/tools/geospatial.tsx | head -300 | tail -80Length of output: 7112 🏁 Script executed: #!/bin/bash
# Search for MCP server definitions, schemas, or configuration files
find . -type f \( -name "*schema*" -o -name "*mcp*" -o -name "*.md" \) -not -path "*/node_modules/*" | head -20
# Search for mapbox-related configuration or types
rg -n "mapbox|MCP|mcp" -g "*.json" -g "*.ts" -g "*.tsx" --max-count=5 | grep -i "schema\|tool\|interface" | head -30
# Check if there are any test files that might reveal expected argument schemas
find . -path "*/test*" -o -path "*/__tests__/*" | grep -i "geospatial\|mcp" | head -10
# Search for any inline schema or type definitions for tool arguments
rg -n "calculate_distance|search_nearby_places|geocode_location|generate_map_link" -g "*.ts" -g "*.tsx" -B 5 -A 5Length of output: 9285 🏁 Script executed: #!/bin/bash
# Check mapbox_mcp_config.json for schema definitions
cat mapbox_mcp_config.json
# Search for generate_map_link usage
rg -n "generate_map_link" -g "*.ts" -g "*.tsx" -B 3 -A 3Length of output: 2012 Fix argument schema mismatches with MCP tool calls. The argument construction includes parameters that don't match the verified tool call patterns in
Compare against verified implementations in 🤖 Prompt for AI Agents |
||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
Tool name mappings updated correctly for new MCP server.
The tool name mappings have been updated to match the new MCP server identifiers. The logic correctly handles multiple query types mapping to the same underlying MCP tool (e.g., both 'directions' and 'distance' use 'calculate_distance', both 'reverse' and 'geocode' use 'geocode_location').
To confirm these tool names match the MCP server's current interface, verify the available tools by checking the server's tool listing output at lines 122-126 during runtime, or consult the Mapbox MCP server documentation.
🌐 Web query:
💡 Result:
The Mapbox MCP Server exposes these tools: MatrixTool, StaticMapTool, POISearchTool, CategorySearchTool, ForwardGeocodeTool, ReverseGeocodeTool, DirectionsTool, and IsochroneTool. [1][2]
Sources:
[1] Mapbox mcp-server README (GitHub).
[2] Mapbox MCP Server docs — Tools list.
Tool name mappings are incorrect and will cause runtime failures.
The tool names in lines 253-258 do not exist in the Mapbox MCP server. The Mapbox MCP Server exposes these tools: MatrixTool, StaticMapTool, POISearchTool, CategorySearchTool, ForwardGeocodeTool, ReverseGeocodeTool, DirectionsTool, and IsochroneTool.
The code references non-existent tool names:
'calculate_distance'- does not exist'search_nearby_places'- does not exist'generate_map_link'- does not exist'geocode_location'- does not existThese must be mapped to the correct Mapbox MCP server tool names. For example, 'directions' and 'distance' likely correspond to
DirectionsToolorMatrixTool, 'search' corresponds toPOISearchToolorCategorySearchTool, 'reverse' and 'geocode' correspond toReverseGeocodeToolorForwardGeocodeTool, etc.🤖 Prompt for AI Agents