@cyanheads/geonames-mcp-server 0.0.0-stage → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +439 -0
- package/CLAUDE.md +439 -0
- package/Dockerfile +177 -0
- package/LICENSE +201 -0
- package/README.md +344 -2
- package/changelog/0.1.x/0.1.0.md +9 -0
- package/changelog/0.1.x/0.1.1.md +22 -0
- package/changelog/0.1.x/0.1.2.md +26 -0
- package/changelog/template.md +151 -0
- package/dist/config/server-config.d.ts +13 -0
- package/dist/config/server-config.d.ts.map +1 -0
- package/dist/config/server-config.js +21 -0
- package/dist/config/server-config.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +30 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp-server/tools/definitions/find-postal-codes.tool.d.ts +96 -0
- package/dist/mcp-server/tools/definitions/find-postal-codes.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/find-postal-codes.tool.js +274 -0
- package/dist/mcp-server/tools/definitions/find-postal-codes.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/get-children.tool.d.ts +90 -0
- package/dist/mcp-server/tools/definitions/get-children.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/get-children.tool.js +287 -0
- package/dist/mcp-server/tools/definitions/get-children.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/get-countries.tool.d.ts +90 -0
- package/dist/mcp-server/tools/definitions/get-countries.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/get-countries.tool.js +217 -0
- package/dist/mcp-server/tools/definitions/get-countries.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/get-hierarchy.tool.d.ts +64 -0
- package/dist/mcp-server/tools/definitions/get-hierarchy.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/get-hierarchy.tool.js +168 -0
- package/dist/mcp-server/tools/definitions/get-hierarchy.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/get-place.tool.d.ts +108 -0
- package/dist/mcp-server/tools/definitions/get-place.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/get-place.tool.js +300 -0
- package/dist/mcp-server/tools/definitions/get-place.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/index.d.ts +760 -0
- package/dist/mcp-server/tools/definitions/index.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/index.js +23 -0
- package/dist/mcp-server/tools/definitions/index.js.map +1 -0
- package/dist/mcp-server/tools/definitions/list-reference.tool.d.ts +103 -0
- package/dist/mcp-server/tools/definitions/list-reference.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/list-reference.tool.js +233 -0
- package/dist/mcp-server/tools/definitions/list-reference.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/reverse-geocode.tool.d.ts +142 -0
- package/dist/mcp-server/tools/definitions/reverse-geocode.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/reverse-geocode.tool.js +421 -0
- package/dist/mcp-server/tools/definitions/reverse-geocode.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/search-places.tool.d.ts +145 -0
- package/dist/mcp-server/tools/definitions/search-places.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/search-places.tool.js +385 -0
- package/dist/mcp-server/tools/definitions/search-places.tool.js.map +1 -0
- package/dist/mcp-server/tools/shared-inputs.d.ts +140 -0
- package/dist/mcp-server/tools/shared-inputs.d.ts.map +1 -0
- package/dist/mcp-server/tools/shared-inputs.js +240 -0
- package/dist/mcp-server/tools/shared-inputs.js.map +1 -0
- package/dist/services/geonames/country-codes.d.ts +26 -0
- package/dist/services/geonames/country-codes.d.ts.map +1 -0
- package/dist/services/geonames/country-codes.js +284 -0
- package/dist/services/geonames/country-codes.js.map +1 -0
- package/dist/services/geonames/feature-codes.d.ts +27 -0
- package/dist/services/geonames/feature-codes.d.ts.map +1 -0
- package/dist/services/geonames/feature-codes.js +723 -0
- package/dist/services/geonames/feature-codes.js.map +1 -0
- package/dist/services/geonames/geonames-service.d.ts +103 -0
- package/dist/services/geonames/geonames-service.d.ts.map +1 -0
- package/dist/services/geonames/geonames-service.js +561 -0
- package/dist/services/geonames/geonames-service.js.map +1 -0
- package/dist/services/geonames/response-cache.d.ts +24 -0
- package/dist/services/geonames/response-cache.d.ts.map +1 -0
- package/dist/services/geonames/response-cache.js +44 -0
- package/dist/services/geonames/response-cache.js.map +1 -0
- package/dist/services/geonames/response-parsers.d.ts +38 -0
- package/dist/services/geonames/response-parsers.d.ts.map +1 -0
- package/dist/services/geonames/response-parsers.js +369 -0
- package/dist/services/geonames/response-parsers.js.map +1 -0
- package/dist/services/geonames/types.d.ts +226 -0
- package/dist/services/geonames/types.d.ts.map +1 -0
- package/dist/services/geonames/types.js +10 -0
- package/dist/services/geonames/types.js.map +1 -0
- package/dist/services/geonames/upstream-errors.d.ts +54 -0
- package/dist/services/geonames/upstream-errors.d.ts.map +1 -0
- package/dist/services/geonames/upstream-errors.js +187 -0
- package/dist/services/geonames/upstream-errors.js.map +1 -0
- package/dist/utils/inline-text.d.ts +25 -0
- package/dist/utils/inline-text.d.ts.map +1 -0
- package/dist/utils/inline-text.js +60 -0
- package/dist/utils/inline-text.js.map +1 -0
- package/package.json +108 -4
- package/server.json +120 -0
|
@@ -0,0 +1,421 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview geonames_reverse_geocode — a coordinate's country and admin subdivisions
|
|
3
|
+
* (`countrySubdivisionJSON`), the ocean when no country contains it (`oceanJSON`), the
|
|
4
|
+
* nearest populated places or features (`findNearbyPlaceNameJSON` / `findNearbyJSON`),
|
|
5
|
+
* and optionally its timezone (`timezoneJSON`). The legs run in parallel inside a 30 s
|
|
6
|
+
* budget and fail together.
|
|
7
|
+
* @module mcp-server/tools/definitions/reverse-geocode.tool
|
|
8
|
+
*/
|
|
9
|
+
import { tool, z } from '@cyanheads/mcp-ts-core';
|
|
10
|
+
import { JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
|
|
11
|
+
import { blankAsUnset, citiesInput, featureClassesInput, featureCodesInput, featureFilterMismatch, geonamesUsernameInput, latInput, lngInput, USERNAME_ALIASES, } from '../shared-inputs.js';
|
|
12
|
+
import { getFeatureCode } from '../../../services/geonames/feature-codes.js';
|
|
13
|
+
import { getGeoNamesService } from '../../../services/geonames/geonames-service.js';
|
|
14
|
+
import { inlineText, tableCell } from '../../../utils/inline-text.js';
|
|
15
|
+
/** Wall-clock budget for the whole call, inside a 60 s client timeout. */
|
|
16
|
+
const TOOL_BUDGET_MS = 30_000;
|
|
17
|
+
/** Ceiling on the ocean follow-up's ladder; it also gets no more than what the budget has left. */
|
|
18
|
+
const OCEAN_BUDGET_MS = 10_000;
|
|
19
|
+
/** The most nearby rows one call returns. */
|
|
20
|
+
const MAX_NEARBY = 50;
|
|
21
|
+
/** GeoNames' free-tier ceiling on the nearby radius (status 24 beyond). */
|
|
22
|
+
const MAX_RADIUS_KM = 300;
|
|
23
|
+
/**
|
|
24
|
+
* Ceiling on the containment buffer: room for harbors, estuaries, and the 12-nautical-mile
|
|
25
|
+
* territorial sea, and well below the 300 km GeoNames rejects with status 24.
|
|
26
|
+
*/
|
|
27
|
+
const MAX_COASTAL_BUFFER_KM = 50;
|
|
28
|
+
const NEARBY_KINDS = ['populated_places', 'features', 'none'];
|
|
29
|
+
const NEARBY_TITLES = {
|
|
30
|
+
populated_places: 'Nearest populated places',
|
|
31
|
+
features: 'Nearest features',
|
|
32
|
+
none: 'Nearby lookup skipped (nearbyLimit 0)',
|
|
33
|
+
};
|
|
34
|
+
/** A nearby row as this tool returns it: no country label or id, no first-level code. */
|
|
35
|
+
const toNearby = ({ adminCode1: _adminCode, countryGeonameId: _countryId, countryName: _countryName, featureClassName: _className, iso3166_2: _iso, ...row }) => row;
|
|
36
|
+
/** The timezone block without its country name (the containment already names the country). */
|
|
37
|
+
const toTimezone = ({ countryName: _countryName, ...timezone }) => timezone;
|
|
38
|
+
const orNotAvailable = (value) => value === undefined ? 'Not available' : tableCell(String(value));
|
|
39
|
+
export const reverseGeocodeTool = tool('geonames_reverse_geocode', {
|
|
40
|
+
title: 'Reverse geocode with GeoNames',
|
|
41
|
+
description: "Resolve a latitude/longitude to the country and admin subdivisions that contain it (down to ADM5, each with its geonameId and ISO 3166-2 code where one exists), or the ocean or sea when the point is offshore, plus the nearest populated places with distances; these include neighborhood sections (PPLX) and historical places (PPLH), marked by featureCode. Set featureClasses or featureCodes to list the nearest features of that type instead (peaks, lakes, airports), cities to keep only places above a population tier, and includeTimezone for the IANA timezone with local time, sunrise, and sunset (offshore points get only GeoNames' UTC-offset estimate). A harbor, pier, or shoreline point can fall just outside every country outline and resolve to the sea; coastalBufferKm (up to 50) matches the nearest country within that distance instead. Costs 1 GeoNames credit for containment, with or without the buffer, plus 3 for nearest populated places or 4 for nearest features (nearbyLimit 0 skips them), 1 for the ocean when no country contains the point or lies within the buffer, and 1 for the timezone.",
|
|
42
|
+
annotations: { readOnlyHint: true, idempotentHint: true, openWorldHint: true },
|
|
43
|
+
input: z.object({
|
|
44
|
+
lat: latInput,
|
|
45
|
+
lng: lngInput,
|
|
46
|
+
nearbyLimit: blankAsUnset(z.number().int().min(0).max(MAX_NEARBY).default(5)).describe('How many nearest places or features to list, 0 to 50. Default 5. 0 skips the nearby lookup and its 3 or 4 credits.'),
|
|
47
|
+
radiusKm: blankAsUnset(z.number().positive().max(MAX_RADIUS_KM).default(20)).describe("Radius in kilometres for the nearby lookup, above 0 and at most 300 (GeoNames' free-tier limit). Default 20."),
|
|
48
|
+
cities: citiesInput.describe("Keep only nearby populated places with a population of at least 1,000 (cities1000), 5,000 (cities5000), or 15,000 (cities15000), plus seats of admin divisions: GeoNames' cities tiers. Not combinable with featureClasses or featureCodes."),
|
|
49
|
+
featureClasses: featureClassesInput.describe('List the nearest features of these GeoNames classes instead of populated places: A admin divisions, H water, L areas, P populated places, R roads, S spots and buildings, T terrain, U undersea, V vegetation. A list or a comma-separated string; case-insensitive. With featureCodes too, the two lists intersect: list exactly the classes of those codes, or pass featureCodes alone. Not combinable with cities.'),
|
|
50
|
+
featureCodes: featureCodesInput.describe("List the nearest features with these GeoNames codes instead of populated places (MT mountain, PK peak, LK lake, AIRP airport), up to 20, as a list or a comma-separated string. Case-insensitive; a class prefix (T.MT) is dropped. Each code implies its class; with featureClasses too, the two lists intersect, so featureClasses must list exactly these codes' classes. geonames_list_reference topic feature_codes lists every code. Not combinable with cities."),
|
|
51
|
+
includeTimezone: blankAsUnset(z.boolean().default(false)).describe('Also return the timezone: IANA id, UTC offsets, local time, sunrise, and sunset (1 more credit). Default false.'),
|
|
52
|
+
coastalBufferKm: blankAsUnset(z.number().min(0).max(MAX_COASTAL_BUFFER_KM).default(0)).describe("When no country contains the point, match the nearest country within this many kilometres, 0 to 50. Default 0: exact containment only. Set it for a harbor, pier, or shoreline point, which can fall just outside a country's outline as GeoNames maps it and otherwise resolves to the sea; a match carries country.distanceInKm. The nearby and timezone lookups keep the exact point. No extra credit."),
|
|
53
|
+
geonamesUsername: geonamesUsernameInput,
|
|
54
|
+
}),
|
|
55
|
+
inputAliases: USERNAME_ALIASES,
|
|
56
|
+
output: z.object({
|
|
57
|
+
lat: z.number().describe('The latitude that was looked up.'),
|
|
58
|
+
lng: z.number().describe('The longitude that was looked up.'),
|
|
59
|
+
country: z
|
|
60
|
+
.object({
|
|
61
|
+
countryCode: z.string().describe('ISO 3166-1 alpha-2 country code.'),
|
|
62
|
+
countryName: z
|
|
63
|
+
.string()
|
|
64
|
+
.optional()
|
|
65
|
+
.describe('Country name. Absent when GeoNames sent none.'),
|
|
66
|
+
distanceInKm: z
|
|
67
|
+
.number()
|
|
68
|
+
.optional()
|
|
69
|
+
.describe('Kilometres from the point to this country as GeoNames maps it, to the metre. Present only when no country contains the point and this one was matched within coastalBufferKm.'),
|
|
70
|
+
})
|
|
71
|
+
.optional()
|
|
72
|
+
.describe('The country containing the point, or with coastalBufferKm the nearest country within that distance (then distanceInKm is set); absent offshore and in unmapped areas.'),
|
|
73
|
+
adminLevels: z
|
|
74
|
+
.array(z
|
|
75
|
+
.object({
|
|
76
|
+
level: z.number().describe('Admin level: 1 for the first-order division, up to 5.'),
|
|
77
|
+
code: z.string().optional().describe('Admin code at this level.'),
|
|
78
|
+
name: z.string().optional().describe('Name of the division.'),
|
|
79
|
+
geonameId: z
|
|
80
|
+
.number()
|
|
81
|
+
.optional()
|
|
82
|
+
.describe('GeoNames feature id of the division: pass it to geonames_get_place.'),
|
|
83
|
+
isoCode: z
|
|
84
|
+
.string()
|
|
85
|
+
.optional()
|
|
86
|
+
.describe('ISO 3166-2 code of the division, subdivision part only (IDF, not FR-IDF), where one exists.'),
|
|
87
|
+
})
|
|
88
|
+
.describe('One admin division containing the point, or for a country matched within coastalBufferKm, the one nearest it.'))
|
|
89
|
+
.describe('Admin divisions containing the point, first level first; for a country matched within coastalBufferKm, the divisions of its part nearest the point. Empty offshore, and where GeoNames records no subdivision of the country.'),
|
|
90
|
+
ocean: z
|
|
91
|
+
.object({
|
|
92
|
+
name: z.string().describe('Name of the ocean or sea.'),
|
|
93
|
+
geonameId: z
|
|
94
|
+
.number()
|
|
95
|
+
.optional()
|
|
96
|
+
.describe('GeoNames feature id of the water body. Absent when GeoNames has none.'),
|
|
97
|
+
})
|
|
98
|
+
.optional()
|
|
99
|
+
.describe('The ocean or sea at the point; present only when no country contains it or lies within coastalBufferKm.'),
|
|
100
|
+
nearbyKind: z
|
|
101
|
+
.enum(NEARBY_KINDS)
|
|
102
|
+
.describe('What nearby lists: populated_places, features (featureClasses or featureCodes was set), or none (nearbyLimit 0).'),
|
|
103
|
+
nearby: z
|
|
104
|
+
.array(z
|
|
105
|
+
.object({
|
|
106
|
+
geonameId: z
|
|
107
|
+
.number()
|
|
108
|
+
.describe('GeoNames feature id: pass it to geonames_get_place or geonames_get_hierarchy.'),
|
|
109
|
+
name: z.string().describe('Name of the place or feature, as GeoNames displays it.'),
|
|
110
|
+
toponymName: z
|
|
111
|
+
.string()
|
|
112
|
+
.describe("GeoNames' main name for the feature, often the local-language form."),
|
|
113
|
+
featureClass: z
|
|
114
|
+
.string()
|
|
115
|
+
.optional()
|
|
116
|
+
.describe('One-letter feature class (P populated place, T terrain, H water, …).'),
|
|
117
|
+
featureCode: z
|
|
118
|
+
.string()
|
|
119
|
+
.optional()
|
|
120
|
+
.describe('Feature code, such as PPL (populated place), PPLX (section), PPLH (historical place), or MT (mountain).'),
|
|
121
|
+
featureName: z.string().optional().describe("GeoNames' name for the feature code."),
|
|
122
|
+
countryCode: z
|
|
123
|
+
.string()
|
|
124
|
+
.optional()
|
|
125
|
+
.describe('ISO 3166-1 alpha-2 code of the containing country.'),
|
|
126
|
+
adminName1: z
|
|
127
|
+
.string()
|
|
128
|
+
.optional()
|
|
129
|
+
.describe('Name of the first-order admin division containing it.'),
|
|
130
|
+
lat: z
|
|
131
|
+
.number()
|
|
132
|
+
.optional()
|
|
133
|
+
.describe('Latitude in decimal degrees. Absent when GeoNames sent none.'),
|
|
134
|
+
lng: z
|
|
135
|
+
.number()
|
|
136
|
+
.optional()
|
|
137
|
+
.describe('Longitude in decimal degrees. Absent when GeoNames sent none.'),
|
|
138
|
+
distanceInKm: z
|
|
139
|
+
.number()
|
|
140
|
+
.optional()
|
|
141
|
+
.describe('Distance from the point in kilometres. Absent when GeoNames sent no usable value.'),
|
|
142
|
+
population: z
|
|
143
|
+
.number()
|
|
144
|
+
.optional()
|
|
145
|
+
.describe('Population. Absent when GeoNames records none.'),
|
|
146
|
+
})
|
|
147
|
+
.describe('One nearby place or feature.'))
|
|
148
|
+
.describe('Nearest places or features, nearest first; empty when nearbyKind is none.'),
|
|
149
|
+
timezone: z
|
|
150
|
+
.object({
|
|
151
|
+
timezoneId: z
|
|
152
|
+
.string()
|
|
153
|
+
.optional()
|
|
154
|
+
.describe('IANA timezone id, such as Europe/Paris. Absent offshore.'),
|
|
155
|
+
countryCode: z
|
|
156
|
+
.string()
|
|
157
|
+
.optional()
|
|
158
|
+
.describe('ISO 3166-1 alpha-2 code of the timezone country. Absent offshore.'),
|
|
159
|
+
rawOffsetInHours: z.number().describe('Standard UTC offset in hours, without DST.'),
|
|
160
|
+
gmtOffsetInHours: z.number().describe('UTC offset in hours on 1 January.'),
|
|
161
|
+
dstOffsetInHours: z
|
|
162
|
+
.number()
|
|
163
|
+
.describe("UTC offset in hours on 1 July. Without a timezoneId the offsets are GeoNames' open-water estimate, which has no DST, so this equals rawOffsetInHours."),
|
|
164
|
+
localTime: z
|
|
165
|
+
.string()
|
|
166
|
+
.optional()
|
|
167
|
+
.describe('Current local time, YYYY-MM-DD HH:mm. Absent offshore.'),
|
|
168
|
+
sunrise: z
|
|
169
|
+
.string()
|
|
170
|
+
.optional()
|
|
171
|
+
.describe("Today's local sunrise, YYYY-MM-DD HH:mm. Absent offshore."),
|
|
172
|
+
sunset: z
|
|
173
|
+
.string()
|
|
174
|
+
.optional()
|
|
175
|
+
.describe("Today's local sunset, YYYY-MM-DD HH:mm. Absent offshore."),
|
|
176
|
+
})
|
|
177
|
+
.optional()
|
|
178
|
+
.describe('The timezone at the point; present only with includeTimezone.'),
|
|
179
|
+
}),
|
|
180
|
+
enrichment: {
|
|
181
|
+
truncated: z
|
|
182
|
+
.boolean()
|
|
183
|
+
.describe('True when nearby is full at nearbyLimit, so more may lie within the radius.'),
|
|
184
|
+
shown: z.number().describe('Nearby places or features returned.'),
|
|
185
|
+
cap: z.number().describe('The nearbyLimit that was applied.'),
|
|
186
|
+
notice: z
|
|
187
|
+
.string()
|
|
188
|
+
.optional()
|
|
189
|
+
.describe('Guidance when the point is offshore or unmapped, its country was matched within coastalBufferKm, nothing is nearby, nearby is full, or no IANA timezone covers it.'),
|
|
190
|
+
},
|
|
191
|
+
errors: [
|
|
192
|
+
{
|
|
193
|
+
reason: 'unknown_feature_code',
|
|
194
|
+
code: JsonRpcErrorCode.ValidationError,
|
|
195
|
+
when: 'A featureCodes entry is not a GeoNames feature code.',
|
|
196
|
+
recovery: 'Look up valid codes with geonames_list_reference topic feature_codes, then retry with a listed code.',
|
|
197
|
+
severity: 'notice',
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
reason: 'conflicting_filters',
|
|
201
|
+
code: JsonRpcErrorCode.ValidationError,
|
|
202
|
+
when: 'cities was combined with featureClasses or featureCodes.',
|
|
203
|
+
recovery: 'Call geonames_reverse_geocode again with cities for the nearest populated places, or featureClasses/featureCodes for the nearest features of a type, not both.',
|
|
204
|
+
severity: 'notice',
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
reason: 'feature_filter_mismatch',
|
|
208
|
+
code: JsonRpcErrorCode.ValidationError,
|
|
209
|
+
when: "featureClasses and featureCodes are both set and a code's class is not listed or a listed class has no listed code. GeoNames intersects the two lists, so those entries match nothing.",
|
|
210
|
+
recovery: 'Call geonames_reverse_geocode again with featureCodes alone (each code implies its class) or featureClasses alone; for a whole class plus codes of another class, make one call per class.',
|
|
211
|
+
severity: 'notice',
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
reason: 'username_required',
|
|
215
|
+
code: JsonRpcErrorCode.Unauthorized,
|
|
216
|
+
when: "Neither geonamesUsername nor the server's GEONAMES_USERNAME supplies a GeoNames account.",
|
|
217
|
+
recovery: 'Call the tool again with geonamesUsername set to a free GeoNames account that has web services enabled, or ask the operator to set GEONAMES_USERNAME.',
|
|
218
|
+
severity: 'notice',
|
|
219
|
+
thrownBy: 'service',
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
reason: 'caller_account_rejected',
|
|
223
|
+
code: JsonRpcErrorCode.Unauthorized,
|
|
224
|
+
when: 'GeoNames rejected the caller-supplied geonamesUsername (unknown user, or free web services not enabled).',
|
|
225
|
+
recovery: "Enable free web services for that account on its GeoNames account page, or call the tool again without geonamesUsername to use the server's account.",
|
|
226
|
+
severity: 'notice',
|
|
227
|
+
thrownBy: 'service',
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
reason: 'server_account_rejected',
|
|
231
|
+
code: JsonRpcErrorCode.ConfigurationError,
|
|
232
|
+
when: "GeoNames rejected the server's GEONAMES_USERNAME.",
|
|
233
|
+
recovery: 'The operator must set GEONAMES_USERNAME to a registered account with free web services enabled; until then call the tool again with geonamesUsername set to your own account.',
|
|
234
|
+
thrownBy: 'service',
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
reason: 'quota_exhausted',
|
|
238
|
+
code: JsonRpcErrorCode.RateLimited,
|
|
239
|
+
when: "GeoNames reported the account's hourly, daily, or weekly credit limit spent, or this server's pacer for the account shed the call.",
|
|
240
|
+
recovery: "Wait for the window named in the message before calling again, or call again with a different GeoNames account: pass geonamesUsername, or omit it to use the server's.",
|
|
241
|
+
retryable: true,
|
|
242
|
+
thrownBy: 'service',
|
|
243
|
+
},
|
|
244
|
+
{
|
|
245
|
+
reason: 'upstream_rejected_parameter',
|
|
246
|
+
code: JsonRpcErrorCode.ValidationError,
|
|
247
|
+
when: 'GeoNames rejected a value the schema let through; the message carries its text.',
|
|
248
|
+
recovery: 'Correct the value named in the message and call again; geonames_list_reference lists valid feature classes, feature codes, and postal coverage.',
|
|
249
|
+
severity: 'notice',
|
|
250
|
+
thrownBy: 'service',
|
|
251
|
+
},
|
|
252
|
+
],
|
|
253
|
+
async handler(input, ctx) {
|
|
254
|
+
const startedAt = Date.now();
|
|
255
|
+
ctx.enrich({ truncated: false, shown: 0, cap: input.nearbyLimit });
|
|
256
|
+
const { lat, lng, nearbyLimit, radiusKm, cities, featureClasses, featureCodes, coastalBufferKm, } = input;
|
|
257
|
+
if (cities !== undefined && (featureClasses !== undefined || featureCodes !== undefined)) {
|
|
258
|
+
throw ctx.fail('conflicting_filters', 'cities narrows the nearest populated places, while featureClasses and featureCodes switch to the nearest features of a type; pass one or the other.');
|
|
259
|
+
}
|
|
260
|
+
const unknownCodes = featureCodes?.filter((code) => getFeatureCode(code) === undefined) ?? [];
|
|
261
|
+
if (unknownCodes.length > 0) {
|
|
262
|
+
throw ctx.fail('unknown_feature_code', `Not a GeoNames feature code: ${unknownCodes.join(', ')}.`, { featureCodes: unknownCodes });
|
|
263
|
+
}
|
|
264
|
+
const mismatch = featureFilterMismatch({ featureClasses, featureCodes });
|
|
265
|
+
if (mismatch !== undefined) {
|
|
266
|
+
const { message, ...offending } = mismatch;
|
|
267
|
+
throw ctx.fail('feature_filter_mismatch', message, offending);
|
|
268
|
+
}
|
|
269
|
+
const service = getGeoNamesService();
|
|
270
|
+
const account = service.resolveAccount(input.geonamesUsername);
|
|
271
|
+
const nearbyKind = nearbyLimit === 0
|
|
272
|
+
? 'none'
|
|
273
|
+
: featureClasses !== undefined || featureCodes !== undefined
|
|
274
|
+
? 'features'
|
|
275
|
+
: 'populated_places';
|
|
276
|
+
/** Containment, then the ocean only when no country contains the point or lies within the buffer. */
|
|
277
|
+
const locate = async () => {
|
|
278
|
+
const subdivision = await service.subdivision(lat, lng, account, ctx, {
|
|
279
|
+
bufferKm: coastalBufferKm,
|
|
280
|
+
});
|
|
281
|
+
if (subdivision !== undefined)
|
|
282
|
+
return { subdivision };
|
|
283
|
+
const remainingMs = TOOL_BUDGET_MS - (Date.now() - startedAt);
|
|
284
|
+
const ocean = await service.ocean(lat, lng, account, ctx, {
|
|
285
|
+
deadlineMs: Math.min(OCEAN_BUDGET_MS, remainingMs),
|
|
286
|
+
});
|
|
287
|
+
return ocean === undefined ? {} : { ocean };
|
|
288
|
+
};
|
|
289
|
+
const nearbyParams = { lat, lng, radiusKm, limit: nearbyLimit };
|
|
290
|
+
let nearbyLeg = Promise.resolve([]);
|
|
291
|
+
if (nearbyKind === 'populated_places') {
|
|
292
|
+
nearbyLeg = service.nearbyPlaces({ ...nearbyParams, cities }, account, ctx);
|
|
293
|
+
}
|
|
294
|
+
else if (nearbyKind === 'features') {
|
|
295
|
+
nearbyLeg = service.nearbyFeatures({ ...nearbyParams, featureClasses, featureCodes }, account, ctx);
|
|
296
|
+
}
|
|
297
|
+
const [{ subdivision, ocean }, nearby, timezone] = await Promise.all([
|
|
298
|
+
locate(),
|
|
299
|
+
nearbyLeg,
|
|
300
|
+
input.includeTimezone ? service.timezone(lat, lng, account, ctx) : undefined,
|
|
301
|
+
]);
|
|
302
|
+
const shown = nearby.length;
|
|
303
|
+
ctx.enrich({ shown });
|
|
304
|
+
const fragments = [];
|
|
305
|
+
if (subdivision === undefined && ocean !== undefined) {
|
|
306
|
+
fragments.push(coastalBufferKm > 0
|
|
307
|
+
? `No country lies within ${coastalBufferKm} km of this point; it lies in ${inlineText(ocean.name)}.`
|
|
308
|
+
: `No country contains this point; it lies in ${inlineText(ocean.name)}. A harbor or shoreline point just outside a country's outline resolves to the water body: set coastalBufferKm (up to ${MAX_COASTAL_BUFFER_KM}) to match the nearest country within that distance.`);
|
|
309
|
+
}
|
|
310
|
+
else if (subdivision === undefined) {
|
|
311
|
+
const noCountry = coastalBufferKm > 0
|
|
312
|
+
? `GeoNames has no country within ${coastalBufferKm} km of this point and no ocean for it`
|
|
313
|
+
: 'GeoNames has no country or ocean for this point';
|
|
314
|
+
fragments.push(`${noCountry} (polar or unmapped area); geonames_search_places with a boundingBox around it can still find named features.`);
|
|
315
|
+
if (coastalBufferKm === 0) {
|
|
316
|
+
fragments.push(`A shoreline point just outside a country's outline can land here too: set coastalBufferKm (up to ${MAX_COASTAL_BUFFER_KM}) to match the nearest country within that distance.`);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
else if (subdivision.country?.distanceInKm !== undefined) {
|
|
320
|
+
const { countryCode, countryName, distanceInKm } = subdivision.country;
|
|
321
|
+
const label = countryName === undefined
|
|
322
|
+
? inlineText(countryCode)
|
|
323
|
+
: `${inlineText(countryName)} (${inlineText(countryCode)})`;
|
|
324
|
+
fragments.push(`No country contains this point exactly; ${label} was matched ${distanceInKm} km away, within the ${coastalBufferKm} km coastal buffer.`);
|
|
325
|
+
}
|
|
326
|
+
const widen = radiusKm < MAX_RADIUS_KM
|
|
327
|
+
? `raise radiusKm (max ${MAX_RADIUS_KM})`
|
|
328
|
+
: 'search a wider area with geonames_search_places and a boundingBox';
|
|
329
|
+
if (nearbyKind === 'populated_places' && shown === 0) {
|
|
330
|
+
fragments.push(`No populated place within ${radiusKm} km${cities === undefined ? '' : ` in ${cities}`}; ${widen}${cities === undefined ? '' : ' or drop cities'}.`);
|
|
331
|
+
}
|
|
332
|
+
if (nearbyKind === 'features' && shown === 0) {
|
|
333
|
+
// Past feature_filter_mismatch, any listed classes are the codes' own: the codes are the filter.
|
|
334
|
+
const filter = featureCodes === undefined
|
|
335
|
+
? `of class ${featureClasses?.join(', ')}`
|
|
336
|
+
: `with code ${featureCodes.join(', ')}`;
|
|
337
|
+
fragments.push(`No feature ${filter} within ${radiusKm} km; ${widen} or widen the feature filter (geonames_list_reference topic feature_codes).`);
|
|
338
|
+
}
|
|
339
|
+
if (shown > 0 && shown === nearbyLimit) {
|
|
340
|
+
ctx.enrich.truncated({ shown, cap: nearbyLimit });
|
|
341
|
+
fragments.push(nearbyLimit < MAX_NEARBY
|
|
342
|
+
? `Only the nearest ${nearbyLimit} are listed, and more may lie within ${radiusKm} km; raise nearbyLimit (max ${MAX_NEARBY}) to see them.`
|
|
343
|
+
: `Only the nearest ${MAX_NEARBY} are listed, the most one call returns, and more may lie within ${radiusKm} km; list the rest with geonames_search_places and a boundingBox.`);
|
|
344
|
+
}
|
|
345
|
+
if (input.includeTimezone && timezone?.timezoneId === undefined) {
|
|
346
|
+
fragments.push(timezone === undefined
|
|
347
|
+
? 'GeoNames has no timezone for this point.'
|
|
348
|
+
: "No IANA timezone covers this point; the offsets are GeoNames' estimate for open water.");
|
|
349
|
+
}
|
|
350
|
+
if (fragments.length > 0)
|
|
351
|
+
ctx.enrich.notice(fragments.join(' '));
|
|
352
|
+
return {
|
|
353
|
+
lat,
|
|
354
|
+
lng,
|
|
355
|
+
...(subdivision?.country === undefined ? {} : { country: subdivision.country }),
|
|
356
|
+
adminLevels: subdivision?.adminLevels ?? [],
|
|
357
|
+
...(ocean === undefined ? {} : { ocean }),
|
|
358
|
+
nearbyKind,
|
|
359
|
+
nearby: nearby.map(toNearby),
|
|
360
|
+
...(timezone === undefined ? {} : { timezone: toTimezone(timezone) }),
|
|
361
|
+
};
|
|
362
|
+
},
|
|
363
|
+
format: (result) => {
|
|
364
|
+
const lines = [`## GeoNames reverse geocode of ${result.lat}, ${result.lng}`, ''];
|
|
365
|
+
const { country, ocean, timezone } = result;
|
|
366
|
+
lines.push(`**Country:** ${country === undefined
|
|
367
|
+
? 'None'
|
|
368
|
+
: `${country.countryName === undefined ? '' : `${inlineText(country.countryName)} `}(${inlineText(country.countryCode)})${country.distanceInKm === undefined ? '' : `, ${country.distanceInKm} km away (matched within the coastal buffer)`}`}`);
|
|
369
|
+
if (ocean !== undefined) {
|
|
370
|
+
lines.push(`**Ocean or sea:** ${inlineText(ocean.name)}${ocean.geonameId === undefined ? '' : ` (geonameId ${ocean.geonameId})`}`);
|
|
371
|
+
}
|
|
372
|
+
lines.push('', '### Admin divisions');
|
|
373
|
+
if (result.adminLevels.length === 0) {
|
|
374
|
+
lines.push(country === undefined ? 'None: no country contains this point.' : 'None recorded.');
|
|
375
|
+
}
|
|
376
|
+
else {
|
|
377
|
+
lines.push('| Level | Name | Code | geonameId | ISO 3166-2 |', '|:---|:---|:---|:---|:---|');
|
|
378
|
+
for (const level of result.adminLevels) {
|
|
379
|
+
lines.push(`| ADM${level.level} | ${orNotAvailable(level.name)} | ${orNotAvailable(level.code)} | ${orNotAvailable(level.geonameId)} | ${orNotAvailable(level.isoCode)} |`);
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
lines.push('', `### ${NEARBY_TITLES[result.nearbyKind]} (nearbyKind ${result.nearbyKind})`);
|
|
383
|
+
if (result.nearby.length === 0) {
|
|
384
|
+
lines.push(result.nearbyKind === 'none' ? 'Not requested.' : 'None within the radius.');
|
|
385
|
+
}
|
|
386
|
+
else {
|
|
387
|
+
lines.push('| Distance (km) | geonameId | Name | Feature | Country | First-level division | Population | Lat, Lng |', '|:---|:---|:---|:---|:---|:---|:---|:---|');
|
|
388
|
+
for (const row of result.nearby) {
|
|
389
|
+
const name = row.toponymName === row.name
|
|
390
|
+
? tableCell(row.name)
|
|
391
|
+
: `${tableCell(row.name)} (toponym: ${tableCell(row.toponymName)})`;
|
|
392
|
+
const feature = row.featureCode === undefined && row.featureClass === undefined
|
|
393
|
+
? 'Not available'
|
|
394
|
+
: [
|
|
395
|
+
row.featureCode && tableCell(row.featureCode),
|
|
396
|
+
row.featureName && tableCell(row.featureName),
|
|
397
|
+
row.featureClass && `(class ${tableCell(row.featureClass)})`,
|
|
398
|
+
]
|
|
399
|
+
.filter(Boolean)
|
|
400
|
+
.join(' ');
|
|
401
|
+
lines.push(`| ${[
|
|
402
|
+
orNotAvailable(row.distanceInKm),
|
|
403
|
+
row.geonameId,
|
|
404
|
+
name,
|
|
405
|
+
feature,
|
|
406
|
+
orNotAvailable(row.countryCode),
|
|
407
|
+
orNotAvailable(row.adminName1),
|
|
408
|
+
row.population === undefined ? 'Not available' : row.population.toLocaleString('en-US'),
|
|
409
|
+
row.lat === undefined || row.lng === undefined
|
|
410
|
+
? 'Not available'
|
|
411
|
+
: `${row.lat}, ${row.lng}`,
|
|
412
|
+
].join(' | ')} |`);
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
if (timezone !== undefined) {
|
|
416
|
+
lines.push('', '### Timezone', `- **IANA id:** ${timezone.timezoneId === undefined ? 'Not available' : inlineText(timezone.timezoneId)}`, `- **Country:** ${timezone.countryCode === undefined ? 'Not available' : inlineText(timezone.countryCode)}`, `- **UTC offsets (hours):** standard ${timezone.rawOffsetInHours}, 1 January ${timezone.gmtOffsetInHours}, 1 July ${timezone.dstOffsetInHours}`, `- **Local time:** ${timezone.localTime === undefined ? 'Not available' : inlineText(timezone.localTime)}`, `- **Sunrise:** ${timezone.sunrise === undefined ? 'Not available' : inlineText(timezone.sunrise)}`, `- **Sunset:** ${timezone.sunset === undefined ? 'Not available' : inlineText(timezone.sunset)}`);
|
|
417
|
+
}
|
|
418
|
+
return [{ type: 'text', text: lines.join('\n') }];
|
|
419
|
+
},
|
|
420
|
+
});
|
|
421
|
+
//# sourceMappingURL=reverse-geocode.tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reverse-geocode.tool.js","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/reverse-geocode.tool.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EACL,YAAY,EACZ,WAAW,EACX,mBAAmB,EACnB,iBAAiB,EACjB,qBAAqB,EACrB,qBAAqB,EACrB,QAAQ,EACR,QAAQ,EACR,gBAAgB,GACjB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;AACtE,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAC;AAE7E,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAE/D,0EAA0E;AAC1E,MAAM,cAAc,GAAG,MAAM,CAAC;AAE9B,mGAAmG;AACnG,MAAM,eAAe,GAAG,MAAM,CAAC;AAE/B,6CAA6C;AAC7C,MAAM,UAAU,GAAG,EAAE,CAAC;AAEtB,2EAA2E;AAC3E,MAAM,aAAa,GAAG,GAAG,CAAC;AAE1B;;;GAGG;AACH,MAAM,qBAAqB,GAAG,EAAE,CAAC;AAEjC,MAAM,YAAY,GAAG,CAAC,kBAAkB,EAAE,UAAU,EAAE,MAAM,CAAU,CAAC;AAIvE,MAAM,aAAa,GAA+B;IAChD,gBAAgB,EAAE,0BAA0B;IAC5C,QAAQ,EAAE,kBAAkB;IAC5B,IAAI,EAAE,uCAAuC;CAC9C,CAAC;AAEF,yFAAyF;AACzF,MAAM,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AAQ,CAAC,OAAO,CAAC,EAAE,EACnG,iBAAiB,QAAQ,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CACjG,CAAC;QACJ,CAAC;QACD,OAAO,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACpD,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview geonames_search_places — searches the GeoNames gazetteer by name and
|
|
3
|
+
* filters (country, feature class or code, population tier, bounding box) through
|
|
4
|
+
* `searchJSON`, one credit a call, cached for an hour.
|
|
5
|
+
* @module mcp-server/tools/definitions/search-places.tool
|
|
6
|
+
*/
|
|
7
|
+
import { z } from '@cyanheads/mcp-ts-core';
|
|
8
|
+
import { JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
|
|
9
|
+
export declare const searchPlacesTool: import("@cyanheads/mcp-ts-core").ToolDefinition<z.ZodObject<{
|
|
10
|
+
query: z.ZodPreprocess<z.ZodOptional<z.ZodString>, unknown>;
|
|
11
|
+
match: z.ZodPreprocess<z.ZodPreprocess<z.ZodOptional<z.ZodEnum<{
|
|
12
|
+
any_field: "any_field";
|
|
13
|
+
exact_name: "exact_name";
|
|
14
|
+
name_prefix: "name_prefix";
|
|
15
|
+
name_required: "name_required";
|
|
16
|
+
}>>, unknown>, unknown>;
|
|
17
|
+
countries: z.ZodPreprocess<z.ZodOptional<z.ZodArray<z.ZodString>>, unknown>;
|
|
18
|
+
featureClasses: z.ZodPreprocess<z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
19
|
+
A: "A";
|
|
20
|
+
H: "H";
|
|
21
|
+
L: "L";
|
|
22
|
+
P: "P";
|
|
23
|
+
R: "R";
|
|
24
|
+
S: "S";
|
|
25
|
+
T: "T";
|
|
26
|
+
U: "U";
|
|
27
|
+
V: "V";
|
|
28
|
+
}>>>, unknown>;
|
|
29
|
+
featureCodes: z.ZodPreprocess<z.ZodOptional<z.ZodArray<z.ZodString>>, unknown>;
|
|
30
|
+
cities: z.ZodPreprocess<z.ZodPreprocess<z.ZodOptional<z.ZodEnum<{
|
|
31
|
+
cities1000: "cities1000";
|
|
32
|
+
cities15000: "cities15000";
|
|
33
|
+
cities5000: "cities5000";
|
|
34
|
+
}>>, unknown>, unknown>;
|
|
35
|
+
boundingBox: z.ZodPreprocess<z.ZodOptional<z.ZodObject<{
|
|
36
|
+
north: z.ZodNumber;
|
|
37
|
+
south: z.ZodNumber;
|
|
38
|
+
east: z.ZodNumber;
|
|
39
|
+
west: z.ZodNumber;
|
|
40
|
+
}, z.core.$strict>>, unknown>;
|
|
41
|
+
orderBy: z.ZodPreprocess<z.ZodPreprocess<z.ZodOptional<z.ZodEnum<{
|
|
42
|
+
population: "population";
|
|
43
|
+
relevance: "relevance";
|
|
44
|
+
}>>, unknown>, unknown>;
|
|
45
|
+
limit: z.ZodPreprocess<z.ZodDefault<z.ZodNumber>, unknown>;
|
|
46
|
+
offset: z.ZodPreprocess<z.ZodDefault<z.ZodNumber>, unknown>;
|
|
47
|
+
geonamesUsername: z.ZodPreprocess<z.ZodOptional<z.ZodString>, unknown>;
|
|
48
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
49
|
+
places: z.ZodArray<z.ZodObject<{
|
|
50
|
+
geonameId: z.ZodNumber;
|
|
51
|
+
name: z.ZodString;
|
|
52
|
+
toponymName: z.ZodString;
|
|
53
|
+
lat: z.ZodOptional<z.ZodNumber>;
|
|
54
|
+
lng: z.ZodOptional<z.ZodNumber>;
|
|
55
|
+
featureClass: z.ZodOptional<z.ZodString>;
|
|
56
|
+
featureClassName: z.ZodOptional<z.ZodString>;
|
|
57
|
+
featureCode: z.ZodOptional<z.ZodString>;
|
|
58
|
+
featureName: z.ZodOptional<z.ZodString>;
|
|
59
|
+
countryCode: z.ZodOptional<z.ZodString>;
|
|
60
|
+
countryName: z.ZodOptional<z.ZodString>;
|
|
61
|
+
adminCode1: z.ZodOptional<z.ZodString>;
|
|
62
|
+
adminName1: z.ZodOptional<z.ZodString>;
|
|
63
|
+
iso3166_2: z.ZodOptional<z.ZodString>;
|
|
64
|
+
population: z.ZodOptional<z.ZodNumber>;
|
|
65
|
+
}, z.core.$strip>>;
|
|
66
|
+
nextOffset: z.ZodOptional<z.ZodNumber>;
|
|
67
|
+
}, z.core.$strip>, readonly [{
|
|
68
|
+
readonly reason: "query_or_filter_required";
|
|
69
|
+
readonly code: JsonRpcErrorCode.ValidationError;
|
|
70
|
+
readonly when: "Neither query nor a narrowing filter (countries, featureClasses, featureCodes, boundingBox) was given.";
|
|
71
|
+
readonly recovery: "Pass query, or at least one of countries, featureClasses, featureCodes, or boundingBox, then call geonames_search_places again.";
|
|
72
|
+
readonly severity: "notice";
|
|
73
|
+
}, {
|
|
74
|
+
readonly reason: "query_required";
|
|
75
|
+
readonly code: JsonRpcErrorCode.ValidationError;
|
|
76
|
+
readonly when: "match was set without query.";
|
|
77
|
+
readonly recovery: "Call geonames_search_places again with query text for the chosen match mode, or drop match to search by filters alone.";
|
|
78
|
+
readonly severity: "notice";
|
|
79
|
+
}, {
|
|
80
|
+
readonly reason: "unknown_country_code";
|
|
81
|
+
readonly code: JsonRpcErrorCode.ValidationError;
|
|
82
|
+
readonly when: "A countries entry is a well-formed alpha-3 or three-digit numeric code that no country has.";
|
|
83
|
+
readonly recovery: "Find the country with geonames_get_countries (nameContains matches its name), then call again with its alpha-2, alpha-3, or numeric code.";
|
|
84
|
+
readonly severity: "notice";
|
|
85
|
+
}, {
|
|
86
|
+
readonly reason: "unknown_feature_code";
|
|
87
|
+
readonly code: JsonRpcErrorCode.ValidationError;
|
|
88
|
+
readonly when: "A featureCodes entry is not a GeoNames feature code.";
|
|
89
|
+
readonly recovery: "Look up valid codes with geonames_list_reference topic feature_codes, then retry with a listed code.";
|
|
90
|
+
readonly severity: "notice";
|
|
91
|
+
}, {
|
|
92
|
+
readonly reason: "feature_filter_mismatch";
|
|
93
|
+
readonly code: JsonRpcErrorCode.ValidationError;
|
|
94
|
+
readonly when: "featureClasses and featureCodes are both set and a code's class is not listed or a listed class has no listed code, or cities (class P only) is set beside another class or a code outside class P. GeoNames intersects the filters, so those entries match nothing.";
|
|
95
|
+
readonly recovery: `${string} ${string}`;
|
|
96
|
+
readonly severity: "notice";
|
|
97
|
+
}, {
|
|
98
|
+
readonly reason: "invalid_bounding_box";
|
|
99
|
+
readonly code: JsonRpcErrorCode.ValidationError;
|
|
100
|
+
readonly when: "boundingBox has south greater than or equal to north, or west greater than or equal to east.";
|
|
101
|
+
readonly recovery: "Call geonames_search_places again with south below north and west below east; split a box that crosses the 180° meridian into two searches.";
|
|
102
|
+
readonly severity: "notice";
|
|
103
|
+
}, {
|
|
104
|
+
readonly reason: "username_required";
|
|
105
|
+
readonly code: JsonRpcErrorCode.Unauthorized;
|
|
106
|
+
readonly when: "Neither geonamesUsername nor the server's GEONAMES_USERNAME supplies a GeoNames account.";
|
|
107
|
+
readonly recovery: "Call the tool again with geonamesUsername set to a free GeoNames account that has web services enabled, or ask the operator to set GEONAMES_USERNAME.";
|
|
108
|
+
readonly severity: "notice";
|
|
109
|
+
readonly thrownBy: "service";
|
|
110
|
+
}, {
|
|
111
|
+
readonly reason: "caller_account_rejected";
|
|
112
|
+
readonly code: JsonRpcErrorCode.Unauthorized;
|
|
113
|
+
readonly when: "GeoNames rejected the caller-supplied geonamesUsername (unknown user, or free web services not enabled).";
|
|
114
|
+
readonly recovery: "Enable free web services for that account on its GeoNames account page, or call the tool again without geonamesUsername to use the server's account.";
|
|
115
|
+
readonly severity: "notice";
|
|
116
|
+
readonly thrownBy: "service";
|
|
117
|
+
}, {
|
|
118
|
+
readonly reason: "server_account_rejected";
|
|
119
|
+
readonly code: JsonRpcErrorCode.ConfigurationError;
|
|
120
|
+
readonly when: "GeoNames rejected the server's GEONAMES_USERNAME.";
|
|
121
|
+
readonly recovery: "The operator must set GEONAMES_USERNAME to a registered account with free web services enabled; until then call the tool again with geonamesUsername set to your own account.";
|
|
122
|
+
readonly thrownBy: "service";
|
|
123
|
+
}, {
|
|
124
|
+
readonly reason: "quota_exhausted";
|
|
125
|
+
readonly code: JsonRpcErrorCode.RateLimited;
|
|
126
|
+
readonly when: "GeoNames reported the account's hourly, daily, or weekly credit limit spent, or this server's pacer for the account shed the call.";
|
|
127
|
+
readonly recovery: "Wait for the window named in the message before calling again, or call again with a different GeoNames account: pass geonamesUsername, or omit it to use the server's.";
|
|
128
|
+
readonly retryable: true;
|
|
129
|
+
readonly thrownBy: "service";
|
|
130
|
+
}, {
|
|
131
|
+
readonly reason: "upstream_rejected_parameter";
|
|
132
|
+
readonly code: JsonRpcErrorCode.ValidationError;
|
|
133
|
+
readonly when: "GeoNames rejected a value the schema let through; the message carries its text.";
|
|
134
|
+
readonly recovery: "Correct the value named in the message and call again; geonames_list_reference lists valid feature classes, feature codes, and postal coverage.";
|
|
135
|
+
readonly severity: "notice";
|
|
136
|
+
readonly thrownBy: "service";
|
|
137
|
+
}], {
|
|
138
|
+
readonly totalCount: z.ZodNumber;
|
|
139
|
+
readonly effectiveQuery: z.ZodString;
|
|
140
|
+
readonly truncated: z.ZodBoolean;
|
|
141
|
+
readonly shown: z.ZodNumber;
|
|
142
|
+
readonly cap: z.ZodNumber;
|
|
143
|
+
readonly notice: z.ZodOptional<z.ZodString>;
|
|
144
|
+
}>;
|
|
145
|
+
//# sourceMappingURL=search-places.tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search-places.tool.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/search-places.tool.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAQ,CAAC,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAqDjE,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAia3B,CAAC"}
|