Commit 2f63f77
Fix schema validation: add missing country property (#81)
* [reverse-geocode] Add compact parameter to reduce response verbosity
Adds optional 'compact' parameter (default: true) to reverse_geocode_tool
that significantly reduces response size while maintaining valid GeoJSON
structure and all useful information.
Changes:
- Added 'compact' boolean parameter to input schema (default: true)
- Implemented compactGeoJsonResponse() that:
- Removes verbose 'attribution' field
- Flattens nested 'context' object to simple properties
- Removes internal mapbox_ids and metadata
- Keeps all useful location data (name, address, coordinates, hierarchy)
- Updated execute() to use compact format for structuredContent
- Both json_string and formatted_text formats use compact data
Benefits:
- ~90% reduction in response size (100+ lines → ~20 lines)
- Valid GeoJSON maintained (type: FeatureCollection + features: [])
- All useful information preserved (name, address, coordinates, hierarchy)
- Easier for AI agents to parse (flatter structure)
- Backward compatible (set compact: false for full response)
Example compact output:
{
"type": "FeatureCollection",
"features": [{
"type": "Feature",
"geometry": { "type": "Point", "coordinates": [-76.998, 36.003] },
"properties": {
"name": "620 Mardre Road",
"full_address": "620 Mardre Road, Windsor, NC 27983, US",
"feature_type": "address",
"coordinates": { "longitude": -76.998, "latitude": 36.003 },
"address": "620 Mardre Road",
"postcode": "27983",
"place": "Windsor",
"district": "Bertie County",
"region": "North Carolina",
"country": "United States"
}
}]
}
Tests:
- Added test for compact format (default behavior)
- Updated existing test to use compact: false
- All 393 tests passing
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
* [tools] Add compact parameter to search_and_geocode_tool
Adds compact parameter (default: true) to search_and_geocode_tool to reduce
response size by ~90% while maintaining valid GeoJSON structure.
- Removes attribution, external_ids, mapbox_id, metadata
- Flattens nested context object into direct properties
- Keeps essential fields: name, address, coordinates, poi_category, brand, maki
- Maintains valid GeoJSON structure for use in geojson.io and other tools
- Backward compatible with compact: false for full verbose response
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
* [tools] Add compact parameter to category_search_tool
Adds compact parameter (default: true) to category_search_tool to reduce
response size by ~90% while maintaining valid GeoJSON structure.
- Removes attribution, external_ids, mapbox_id, metadata
- Flattens nested context object into direct properties
- Keeps essential fields: name, address, coordinates, poi_category, brand, maki
- Maintains valid GeoJSON structure for use in geojson.io and other tools
- Backward compatible with compact: false for full verbose response
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
* Fix schema validation: add missing country property
Mapbox Search Box API returns 'country' as a top-level property in
feature.properties, but the output schema didn't include it.
This causes validation warning when using the MCP server:
✗ Validation Error: data.features[0].properties should NOT have
additional properties
Changes:
1. Added country: z.string().optional() to SearchBoxFeaturePropertiesSchema
2. Added .passthrough() to allow future API additions without breaking
The API returns both:
- properties.country: "France" (top-level, for convenience)
- properties.context.country.name: "France" (nested, full context)
Now schema accepts both structures without validation warnings.
Testing:
✓ All 31 tests pass
✓ Validated against real API responses
---------
Co-authored-by: Claude Sonnet 4.5 <[email protected]>1 parent f3f439b commit 2f63f77
File tree
1 file changed
+107
-101
lines changed- src/tools/search-and-geocode-tool
1 file changed
+107
-101
lines changedLines changed: 107 additions & 101 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
13 | 14 | | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
19 | 20 | | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
88 | 56 | | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
94 | 76 | | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
101 | 95 | | |
102 | | - | |
103 | | - | |
104 | | - | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
105 | 102 | | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
114 | 120 | | |
115 | 121 | | |
116 | 122 | | |
| |||
0 commit comments