Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions components/settings/components/model-selection-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ const models = [
badgeVariant: "default" as const,
},
{
id: "Grok-3",
name: "Grok-3",
description: "Fast and efficient model for most everyday tasks and queries.",
id: "Grok-4",
name: "Grok-4",
description: "Fast and efficient model for most everyday tasks and queries. (Updated to Grok-4)",
icon: Zap,
badge: "Fast",
badgeVariant: "secondary" as const,
Expand Down
24 changes: 12 additions & 12 deletions lib/agents/tools/geospatial.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
})();
Comment on lines +253 to 260
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 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:

What are the available tool names in the Mapbox MCP server version 1.0.0?

💡 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 exist

These must be mapped to the correct Mapbox MCP server tool names. For example, 'directions' and 'distance' likely correspond to DirectionsTool or MatrixTool, 'search' corresponds to POISearchTool or CategorySearchTool, 'reverse' and 'geocode' correspond to ReverseGeocodeTool or ForwardGeocodeTool, etc.

🤖 Prompt for AI Agents
In lib/agents/tools/geospatial.tsx around lines 253 to 260, the case arms map to
non-existent MCP tool names and will fail at runtime; replace the incorrect
names with the actual Mapbox MCP tool names: map 'directions' ->
prefer('DirectionsTool'), map 'distance' -> prefer('MatrixTool') (or
DirectionsTool if matrix isn't available in your usage), map 'search' ->
prefer('POISearchTool') (or 'CategorySearchTool' if you need category-based
search), map 'map' -> prefer('StaticMapTool'), and map both 'reverse' and
'geocode' -> prefer('ReverseGeocodeTool') or use 'ForwardGeocodeTool' for
forward geocoding; update each return to use those exact tool names so they
match the MCP server.


// 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

Verify 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 geospatialTool that might need updates for the new schema:


🏁 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=tsx

Length 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=tsx

Length 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 -80

Length 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 5

Length 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 3

Length 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 mapbox_mcp/hooks.ts:

  • Lines 267 & 269 (geocode_location): Remove unsupported maxResults parameter
  • Line 268 (search_nearby_places): Remove unsupported includeMapPreview parameter
  • Line 270 (generate_map_link): Verify expected arguments (no usage examples found in hooks)

Compare against verified implementations in mapbox_mcp/hooks.ts lines 164–206 where these tools are called successfully with different argument sets.

🤖 Prompt for AI Agents
In lib/agents/tools/geospatial.tsx around lines 265 to 272 the constructed
argument objects mismatch the MCP tool schemas: remove the unsupported
maxResults property from the geocode case (line ~267/269), remove
includeMapPreview from the search case (line ~268), and adjust/confirm the map
case (generate_map_link) to match the expected argument set (it likely only
needs location or other specific fields) — update those return objects to
exactly match the call shapes used in mapbox_mcp/hooks.ts (lines 164–206) so
each tool call passes only supported keys.


Expand Down
2 changes: 1 addition & 1 deletion lib/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export function getModel() {
})
// Optionally, add a check for credit status or skip xAI if credits are exhausted
try {
return xai('grok-4-fast-non-reasoning')
return xai('grok-4')
} catch (error) {
console.warn('xAI API unavailable, falling back to OpenAI:')
}
Expand Down
Loading