@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,385 @@
|
|
|
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 { tool, z } from '@cyanheads/mcp-ts-core';
|
|
8
|
+
import { JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
|
|
9
|
+
import { blankAsUnset, citiesInput, countriesInput, featureClassesInput, featureCodesInput, featureFilterMismatch, geonamesUsernameInput, isBlank, limitInput, lowerCased, offsetInput, USERNAME_ALIASES, unknownCountryCodes, } from '../shared-inputs.js';
|
|
10
|
+
import { getFeatureCode } from '../../../services/geonames/feature-codes.js';
|
|
11
|
+
import { getGeoNamesService } from '../../../services/geonames/geonames-service.js';
|
|
12
|
+
import { inlineText, tableCell } from '../../../utils/inline-text.js';
|
|
13
|
+
const MATCHES = ['name_required', 'any_field', 'exact_name', 'name_prefix'];
|
|
14
|
+
/** GeoNames' free service pages no further than `startRow=5000` (status 25 beyond). */
|
|
15
|
+
const MAX_OFFSET = 5000;
|
|
16
|
+
/** The search row as this tool returns it: the gazetteer fields minus nearby and country-id extras. */
|
|
17
|
+
const toPlace = ({ countryGeonameId: _countryId, distanceInKm: _distance, ...place }) => place;
|
|
18
|
+
const orNotAvailable = (value) => value === undefined ? 'Not available' : tableCell(value);
|
|
19
|
+
/** feature_filter_mismatch recovery, one sentence per restriction; a throw carries those its call breaks. */
|
|
20
|
+
const MISMATCH_RECOVERY = {
|
|
21
|
+
lists: 'Call geonames_search_places 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.',
|
|
22
|
+
cities: 'cities keeps only class P: beside it, list only P or class-P codes such as PPLC, or drop cities.',
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* A boundingBox bound. A blank or missing bound fails with a message that says so and
|
|
26
|
+
* names both ways out, instead of the bare number-type error.
|
|
27
|
+
*/
|
|
28
|
+
const bound = () => z.number({
|
|
29
|
+
error: ({ input }) => isBlank(input)
|
|
30
|
+
? `${input === undefined ? 'Missing' : 'Blank'} bound: give all four bounds as numbers, or omit boundingBox to search without a box`
|
|
31
|
+
: undefined,
|
|
32
|
+
});
|
|
33
|
+
export const searchPlacesTool = tool('geonames_search_places', {
|
|
34
|
+
title: 'Search GeoNames places',
|
|
35
|
+
description: 'Search the GeoNames gazetteer of 13M+ places by name and filters: country, feature class (P populated places, A admin divisions, T mountains and terrain, H water, S buildings and spots), feature code (PPLC capitals, ADM1 states, MT mountains, AIRP airports), population tier, and bounding box. Results carry the geonameId that geonames_get_place, geonames_get_hierarchy, and geonames_get_children take. The default match requires a query term in the place name while letting other terms match the country or admin names ("Berlin, Germany"). Costs 1 GeoNames credit per call.',
|
|
36
|
+
annotations: { readOnlyHint: true, idempotentHint: true, openWorldHint: true },
|
|
37
|
+
input: z.object({
|
|
38
|
+
query: blankAsUnset(z.string().max(200).optional()).describe('Place name to search for, such as Springfield or "Berlin, Germany", up to 200 characters. match sets how it is compared. Omit it to search by filters alone, which then needs at least one of countries, featureClasses, featureCodes, or boundingBox (cities alone is not enough).'),
|
|
39
|
+
match: blankAsUnset(lowerCased(z.enum(MATCHES).optional())).describe('How query is matched. name_required (the default) needs at least one query term in the place name while other terms may match the country or admin names; any_field lets every term match any of those fields; exact_name matches the whole name exactly, alternate and historical names included; name_prefix matches names that start with query. Needs query. Case-insensitive.'),
|
|
40
|
+
countries: countriesInput,
|
|
41
|
+
featureClasses: featureClassesInput,
|
|
42
|
+
featureCodes: featureCodesInput,
|
|
43
|
+
cities: citiesInput,
|
|
44
|
+
boundingBox: blankAsUnset(z
|
|
45
|
+
.object({
|
|
46
|
+
north: bound()
|
|
47
|
+
.min(-90)
|
|
48
|
+
.max(90)
|
|
49
|
+
.describe('Northern latitude bound, decimal degrees, -90 to 90.'),
|
|
50
|
+
south: bound()
|
|
51
|
+
.min(-90)
|
|
52
|
+
.max(90)
|
|
53
|
+
.describe('Southern latitude bound, decimal degrees, -90 to 90; below north.'),
|
|
54
|
+
east: bound()
|
|
55
|
+
.min(-180)
|
|
56
|
+
.max(180)
|
|
57
|
+
.describe('Eastern longitude bound, decimal degrees, -180 to 180.'),
|
|
58
|
+
west: bound()
|
|
59
|
+
.min(-180)
|
|
60
|
+
.max(180)
|
|
61
|
+
.describe('Western longitude bound, decimal degrees, -180 to 180; below east.'),
|
|
62
|
+
})
|
|
63
|
+
.strict()
|
|
64
|
+
.optional()).describe('Keep only places inside this box. The box cannot cross the 180° meridian: split such an area into two searches.'),
|
|
65
|
+
orderBy: blankAsUnset(lowerCased(z.enum(['relevance', 'population']).optional())).describe("Result order: relevance (GeoNames' default) or population, largest first. Case-insensitive."),
|
|
66
|
+
limit: limitInput(100, 10),
|
|
67
|
+
offset: offsetInput(MAX_OFFSET),
|
|
68
|
+
geonamesUsername: geonamesUsernameInput,
|
|
69
|
+
}),
|
|
70
|
+
inputAliases: USERNAME_ALIASES,
|
|
71
|
+
output: z.object({
|
|
72
|
+
places: z
|
|
73
|
+
.array(z
|
|
74
|
+
.object({
|
|
75
|
+
geonameId: z
|
|
76
|
+
.number()
|
|
77
|
+
.describe('GeoNames feature id: pass it to geonames_get_place, geonames_get_hierarchy, or geonames_get_children.'),
|
|
78
|
+
name: z.string().describe('Name of the place, as GeoNames displays it.'),
|
|
79
|
+
toponymName: z
|
|
80
|
+
.string()
|
|
81
|
+
.describe("GeoNames' main name for the feature, often the local-language form."),
|
|
82
|
+
lat: z
|
|
83
|
+
.number()
|
|
84
|
+
.optional()
|
|
85
|
+
.describe('Latitude in decimal degrees. Absent when GeoNames sent none.'),
|
|
86
|
+
lng: z
|
|
87
|
+
.number()
|
|
88
|
+
.optional()
|
|
89
|
+
.describe('Longitude in decimal degrees. Absent when GeoNames sent none.'),
|
|
90
|
+
featureClass: z
|
|
91
|
+
.string()
|
|
92
|
+
.optional()
|
|
93
|
+
.describe('One-letter feature class (P populated place, A admin division, …).'),
|
|
94
|
+
featureClassName: z.string().optional().describe("GeoNames' label for the class."),
|
|
95
|
+
featureCode: z
|
|
96
|
+
.string()
|
|
97
|
+
.optional()
|
|
98
|
+
.describe('Feature code, such as PPLC (capital) or ADM1 (first-order division).'),
|
|
99
|
+
featureName: z.string().optional().describe("GeoNames' name for the feature code."),
|
|
100
|
+
countryCode: z
|
|
101
|
+
.string()
|
|
102
|
+
.optional()
|
|
103
|
+
.describe('ISO 3166-1 alpha-2 code of the containing country.'),
|
|
104
|
+
countryName: z.string().optional().describe('Name of the containing country.'),
|
|
105
|
+
adminCode1: z
|
|
106
|
+
.string()
|
|
107
|
+
.optional()
|
|
108
|
+
.describe('Code of the first-order admin division (state, province) containing it.'),
|
|
109
|
+
adminName1: z
|
|
110
|
+
.string()
|
|
111
|
+
.optional()
|
|
112
|
+
.describe('Name of the first-order admin division containing it.'),
|
|
113
|
+
iso3166_2: z
|
|
114
|
+
.string()
|
|
115
|
+
.optional()
|
|
116
|
+
.describe('ISO 3166-2 code of the first-order admin division, subdivision part only: MO, not US-MO.'),
|
|
117
|
+
population: z
|
|
118
|
+
.number()
|
|
119
|
+
.optional()
|
|
120
|
+
.describe('Population. Absent when GeoNames records none.'),
|
|
121
|
+
})
|
|
122
|
+
.describe('One matching place.'))
|
|
123
|
+
.describe('Places on this page, in the requested order.'),
|
|
124
|
+
nextOffset: z
|
|
125
|
+
.number()
|
|
126
|
+
.optional()
|
|
127
|
+
.describe("Offset of the next page; absent on the last page and once offset is 5000. Capped at 5000, the last offset GeoNames' free service accepts, so that page can repeat rows of this one."),
|
|
128
|
+
}),
|
|
129
|
+
enrichment: {
|
|
130
|
+
totalCount: z.number().describe("GeoNames' count of matching places, before paging."),
|
|
131
|
+
effectiveQuery: z
|
|
132
|
+
.string()
|
|
133
|
+
.describe('The match mode, query, and filters as the server sent them to GeoNames.'),
|
|
134
|
+
truncated: z.boolean().describe('True when more matching places remain past this page.'),
|
|
135
|
+
shown: z.number().describe('Places returned on this page.'),
|
|
136
|
+
cap: z.number().describe('The limit that was applied.'),
|
|
137
|
+
notice: z.string().optional().describe('Guidance when nothing matched or more pages remain.'),
|
|
138
|
+
},
|
|
139
|
+
errors: [
|
|
140
|
+
{
|
|
141
|
+
reason: 'query_or_filter_required',
|
|
142
|
+
code: JsonRpcErrorCode.ValidationError,
|
|
143
|
+
when: 'Neither query nor a narrowing filter (countries, featureClasses, featureCodes, boundingBox) was given.',
|
|
144
|
+
recovery: 'Pass query, or at least one of countries, featureClasses, featureCodes, or boundingBox, then call geonames_search_places again.',
|
|
145
|
+
severity: 'notice',
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
reason: 'query_required',
|
|
149
|
+
code: JsonRpcErrorCode.ValidationError,
|
|
150
|
+
when: 'match was set without query.',
|
|
151
|
+
recovery: 'Call geonames_search_places again with query text for the chosen match mode, or drop match to search by filters alone.',
|
|
152
|
+
severity: 'notice',
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
reason: 'unknown_country_code',
|
|
156
|
+
code: JsonRpcErrorCode.ValidationError,
|
|
157
|
+
when: 'A countries entry is a well-formed alpha-3 or three-digit numeric code that no country has.',
|
|
158
|
+
recovery: 'Find the country with geonames_get_countries (nameContains matches its name), then call again with its alpha-2, alpha-3, or numeric code.',
|
|
159
|
+
severity: 'notice',
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
reason: 'unknown_feature_code',
|
|
163
|
+
code: JsonRpcErrorCode.ValidationError,
|
|
164
|
+
when: 'A featureCodes entry is not a GeoNames feature code.',
|
|
165
|
+
recovery: 'Look up valid codes with geonames_list_reference topic feature_codes, then retry with a listed code.',
|
|
166
|
+
severity: 'notice',
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
reason: 'feature_filter_mismatch',
|
|
170
|
+
code: JsonRpcErrorCode.ValidationError,
|
|
171
|
+
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.",
|
|
172
|
+
recovery: `${MISMATCH_RECOVERY.lists} ${MISMATCH_RECOVERY.cities}`,
|
|
173
|
+
severity: 'notice',
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
reason: 'invalid_bounding_box',
|
|
177
|
+
code: JsonRpcErrorCode.ValidationError,
|
|
178
|
+
when: 'boundingBox has south greater than or equal to north, or west greater than or equal to east.',
|
|
179
|
+
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.',
|
|
180
|
+
severity: 'notice',
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
reason: 'username_required',
|
|
184
|
+
code: JsonRpcErrorCode.Unauthorized,
|
|
185
|
+
when: "Neither geonamesUsername nor the server's GEONAMES_USERNAME supplies a GeoNames account.",
|
|
186
|
+
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.',
|
|
187
|
+
severity: 'notice',
|
|
188
|
+
thrownBy: 'service',
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
reason: 'caller_account_rejected',
|
|
192
|
+
code: JsonRpcErrorCode.Unauthorized,
|
|
193
|
+
when: 'GeoNames rejected the caller-supplied geonamesUsername (unknown user, or free web services not enabled).',
|
|
194
|
+
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.",
|
|
195
|
+
severity: 'notice',
|
|
196
|
+
thrownBy: 'service',
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
reason: 'server_account_rejected',
|
|
200
|
+
code: JsonRpcErrorCode.ConfigurationError,
|
|
201
|
+
when: "GeoNames rejected the server's GEONAMES_USERNAME.",
|
|
202
|
+
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.',
|
|
203
|
+
thrownBy: 'service',
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
reason: 'quota_exhausted',
|
|
207
|
+
code: JsonRpcErrorCode.RateLimited,
|
|
208
|
+
when: "GeoNames reported the account's hourly, daily, or weekly credit limit spent, or this server's pacer for the account shed the call.",
|
|
209
|
+
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.",
|
|
210
|
+
retryable: true,
|
|
211
|
+
thrownBy: 'service',
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
reason: 'upstream_rejected_parameter',
|
|
215
|
+
code: JsonRpcErrorCode.ValidationError,
|
|
216
|
+
when: 'GeoNames rejected a value the schema let through; the message carries its text.',
|
|
217
|
+
recovery: 'Correct the value named in the message and call again; geonames_list_reference lists valid feature classes, feature codes, and postal coverage.',
|
|
218
|
+
severity: 'notice',
|
|
219
|
+
thrownBy: 'service',
|
|
220
|
+
},
|
|
221
|
+
],
|
|
222
|
+
async handler(input, ctx) {
|
|
223
|
+
const { query, countries, featureClasses, featureCodes, cities, boundingBox, orderBy } = input;
|
|
224
|
+
const match = query === undefined ? undefined : (input.match ?? 'name_required');
|
|
225
|
+
const effectiveQuery = [
|
|
226
|
+
query === undefined ? undefined : `${match} "${inlineText(query)}"`,
|
|
227
|
+
countries && `countries ${countries.join(',')}`,
|
|
228
|
+
featureClasses && `featureClasses ${featureClasses.join(',')}`,
|
|
229
|
+
featureCodes && `featureCodes ${featureCodes.join(',')}`,
|
|
230
|
+
cities && `cities ${cities}`,
|
|
231
|
+
boundingBox &&
|
|
232
|
+
`boundingBox north ${boundingBox.north} south ${boundingBox.south} east ${boundingBox.east} west ${boundingBox.west}`,
|
|
233
|
+
orderBy && `orderBy ${orderBy}`,
|
|
234
|
+
]
|
|
235
|
+
.filter(Boolean)
|
|
236
|
+
.join(' · ');
|
|
237
|
+
ctx.enrich({ totalCount: 0, truncated: false, shown: 0, cap: input.limit, effectiveQuery });
|
|
238
|
+
if (input.match !== undefined && query === undefined) {
|
|
239
|
+
throw ctx.fail('query_required', `match ${input.match} needs query text to match.`);
|
|
240
|
+
}
|
|
241
|
+
if (query === undefined &&
|
|
242
|
+
countries === undefined &&
|
|
243
|
+
featureClasses === undefined &&
|
|
244
|
+
featureCodes === undefined &&
|
|
245
|
+
boundingBox === undefined) {
|
|
246
|
+
throw ctx.fail('query_or_filter_required', `geonames_search_places needs query or a narrowing filter (countries, featureClasses, featureCodes, boundingBox)${cities === undefined ? '' : '; cities alone does not narrow enough'}.`);
|
|
247
|
+
}
|
|
248
|
+
const unknownCountries = unknownCountryCodes(countries);
|
|
249
|
+
if (unknownCountries !== undefined) {
|
|
250
|
+
const { message, ...offending } = unknownCountries;
|
|
251
|
+
throw ctx.fail('unknown_country_code', message, offending);
|
|
252
|
+
}
|
|
253
|
+
const unknownCodes = featureCodes?.filter((code) => getFeatureCode(code) === undefined) ?? [];
|
|
254
|
+
if (unknownCodes.length > 0) {
|
|
255
|
+
throw ctx.fail('unknown_feature_code', `Not a GeoNames feature code: ${unknownCodes.join(', ')}.`, { featureCodes: unknownCodes });
|
|
256
|
+
}
|
|
257
|
+
const mismatch = featureFilterMismatch({ featureClasses, featureCodes, cities });
|
|
258
|
+
if (mismatch !== undefined) {
|
|
259
|
+
const { message, ...offending } = mismatch;
|
|
260
|
+
const listsDisagree = cities === undefined ||
|
|
261
|
+
featureFilterMismatch({ featureClasses, featureCodes }) !== undefined;
|
|
262
|
+
const hint = [
|
|
263
|
+
listsDisagree && MISMATCH_RECOVERY.lists,
|
|
264
|
+
cities !== undefined && MISMATCH_RECOVERY.cities,
|
|
265
|
+
]
|
|
266
|
+
.filter(Boolean)
|
|
267
|
+
.join(' ');
|
|
268
|
+
throw ctx.fail('feature_filter_mismatch', message, { ...offending, recovery: { hint } });
|
|
269
|
+
}
|
|
270
|
+
if (boundingBox !== undefined &&
|
|
271
|
+
(boundingBox.south >= boundingBox.north || boundingBox.west >= boundingBox.east)) {
|
|
272
|
+
throw ctx.fail('invalid_bounding_box', `boundingBox needs south below north and west below east; got north ${boundingBox.north}, south ${boundingBox.south}, east ${boundingBox.east}, west ${boundingBox.west}.`);
|
|
273
|
+
}
|
|
274
|
+
const service = getGeoNamesService();
|
|
275
|
+
const { places, totalCount } = await service.search({
|
|
276
|
+
limit: input.limit,
|
|
277
|
+
offset: input.offset,
|
|
278
|
+
query,
|
|
279
|
+
match,
|
|
280
|
+
countries,
|
|
281
|
+
featureClasses,
|
|
282
|
+
featureCodes,
|
|
283
|
+
cities,
|
|
284
|
+
boundingBox,
|
|
285
|
+
orderBy,
|
|
286
|
+
}, service.resolveAccount(input.geonamesUsername), ctx);
|
|
287
|
+
const shown = places.length;
|
|
288
|
+
const next = input.offset + shown;
|
|
289
|
+
const more = shown > 0 && next < totalCount;
|
|
290
|
+
/** Past the cap, offset 5000 is still a page: it repeats this page's tail, then reaches row `next`. */
|
|
291
|
+
const nextOffset = more && input.offset < MAX_OFFSET ? Math.min(next, MAX_OFFSET) : undefined;
|
|
292
|
+
ctx.enrich.total(totalCount);
|
|
293
|
+
ctx.enrich({ shown });
|
|
294
|
+
if (more) {
|
|
295
|
+
const remaining = `${(totalCount - next).toLocaleString('en-US')} more ${totalCount - next === 1 ? 'place' : 'places'}`;
|
|
296
|
+
const repeated = next - MAX_OFFSET;
|
|
297
|
+
ctx.enrich.truncated({
|
|
298
|
+
shown,
|
|
299
|
+
cap: input.limit,
|
|
300
|
+
guidance: nextOffset === undefined
|
|
301
|
+
? "GeoNames' free service accepts no offset past 5,000, so no later page is reachable; narrow with countries, featureCodes, or boundingBox to reach the rest."
|
|
302
|
+
: nextOffset < next
|
|
303
|
+
? `${remaining}; call again with offset ${MAX_OFFSET}, the last offset GeoNames' free service accepts (its first ${repeated} ${repeated === 1 ? 'row repeats' : 'rows repeat'} this page).`
|
|
304
|
+
: `${remaining}; call again with offset ${next}.`,
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
if (shown === 0) {
|
|
308
|
+
ctx.enrich.notice(totalCount > 0
|
|
309
|
+
? `offset ${input.offset} is past the last result (${totalCount}); call again with a smaller offset.`
|
|
310
|
+
: [
|
|
311
|
+
`No GeoNames place matched ${effectiveQuery}.`,
|
|
312
|
+
match === 'exact_name' &&
|
|
313
|
+
`No place is named exactly "${inlineText(query ?? '')}"; retry with match name_prefix or name_required.`,
|
|
314
|
+
match === 'name_required' &&
|
|
315
|
+
'At least one query term must appear in the place name; retry with match any_field to also match country and admin names.',
|
|
316
|
+
(featureCodes || featureClasses) &&
|
|
317
|
+
'The feature filter may be too narrow; drop it, or check codes with geonames_list_reference topic feature_codes.',
|
|
318
|
+
countries &&
|
|
319
|
+
`Only ${countries.join(', ')} were searched, and a code GeoNames does not know matches nothing; check the codes with geonames_get_countries, or drop countries to search worldwide.`,
|
|
320
|
+
boundingBox &&
|
|
321
|
+
'Only places inside the bounding box were searched; widen or drop boundingBox.',
|
|
322
|
+
cities && `${cities} excludes smaller populated places; drop cities to include them.`,
|
|
323
|
+
]
|
|
324
|
+
.filter(Boolean)
|
|
325
|
+
.join(' '));
|
|
326
|
+
}
|
|
327
|
+
return { places: places.map(toPlace), ...(nextOffset === undefined ? {} : { nextOffset }) };
|
|
328
|
+
},
|
|
329
|
+
format: (result) => {
|
|
330
|
+
const lines = ['## GeoNames places', ''];
|
|
331
|
+
if (result.places.length === 0) {
|
|
332
|
+
lines.push('No places on this page.');
|
|
333
|
+
}
|
|
334
|
+
else {
|
|
335
|
+
lines.push('| geonameId | Name | Feature | Country | First-level division | Population | Lat, Lng |', '|:---|:---|:---|:---|:---|:---|:---|');
|
|
336
|
+
for (const place of result.places) {
|
|
337
|
+
const name = place.toponymName === place.name
|
|
338
|
+
? tableCell(place.name)
|
|
339
|
+
: `${tableCell(place.name)} (toponym: ${tableCell(place.toponymName)})`;
|
|
340
|
+
const feature = place.featureCode === undefined && place.featureClass === undefined
|
|
341
|
+
? 'Not available'
|
|
342
|
+
: [
|
|
343
|
+
place.featureCode && tableCell(place.featureCode),
|
|
344
|
+
place.featureName && tableCell(place.featureName),
|
|
345
|
+
place.featureClass &&
|
|
346
|
+
`(class ${tableCell(place.featureClass)}${place.featureClassName ? `: ${tableCell(place.featureClassName)}` : ''})`,
|
|
347
|
+
]
|
|
348
|
+
.filter(Boolean)
|
|
349
|
+
.join(' ');
|
|
350
|
+
const country = place.countryCode === undefined
|
|
351
|
+
? orNotAvailable(place.countryName)
|
|
352
|
+
: `${place.countryName ? `${tableCell(place.countryName)} ` : ''}(${tableCell(place.countryCode)})`;
|
|
353
|
+
const admin1 = place.adminName1 === undefined &&
|
|
354
|
+
place.adminCode1 === undefined &&
|
|
355
|
+
place.iso3166_2 === undefined
|
|
356
|
+
? 'Not available'
|
|
357
|
+
: [
|
|
358
|
+
place.adminName1 && tableCell(place.adminName1),
|
|
359
|
+
place.adminCode1 && `(code ${tableCell(place.adminCode1)})`,
|
|
360
|
+
place.iso3166_2 && `ISO ${tableCell(place.iso3166_2)}`,
|
|
361
|
+
]
|
|
362
|
+
.filter(Boolean)
|
|
363
|
+
.join(' ');
|
|
364
|
+
const coordinates = place.lat === undefined || place.lng === undefined
|
|
365
|
+
? 'Not available'
|
|
366
|
+
: `${place.lat}, ${place.lng}`;
|
|
367
|
+
lines.push(`| ${[
|
|
368
|
+
place.geonameId,
|
|
369
|
+
name,
|
|
370
|
+
feature,
|
|
371
|
+
country,
|
|
372
|
+
admin1,
|
|
373
|
+
place.population === undefined
|
|
374
|
+
? 'Not available'
|
|
375
|
+
: place.population.toLocaleString('en-US'),
|
|
376
|
+
coordinates,
|
|
377
|
+
].join(' | ')} |`);
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
if (result.nextOffset !== undefined)
|
|
381
|
+
lines.push('', `Next page: offset ${result.nextOffset}.`);
|
|
382
|
+
return [{ type: 'text', text: lines.join('\n') }];
|
|
383
|
+
},
|
|
384
|
+
});
|
|
385
|
+
//# sourceMappingURL=search-places.tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search-places.tool.js","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/search-places.tool.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;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,cAAc,EACd,mBAAmB,EACnB,iBAAiB,EACjB,qBAAqB,EACrB,qBAAqB,EACrB,OAAO,EACP,UAAU,EACV,UAAU,EACV,WAAW,EACX,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,qCAAqC,CAAC;AAC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CAAC;QAC/F,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,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Input schemas and local list semantics shared by every GeoNames tool.
|
|
3
|
+
* Normalizations run in the schema, before validation: blanks from form clients
|
|
4
|
+
* become unset, lists accept a comma-separated string, codes are upper-cased (country
|
|
5
|
+
* codes mapped to alpha-2), and word enums are lower-cased. Also the checks tools run
|
|
6
|
+
* before any request: country codes no country has, and feature filters that intersect
|
|
7
|
+
* to nothing.
|
|
8
|
+
* @module mcp-server/tools/shared-inputs
|
|
9
|
+
*/
|
|
10
|
+
import { z } from '@cyanheads/mcp-ts-core';
|
|
11
|
+
import { type FeatureClass } from '../../services/geonames/feature-codes.js';
|
|
12
|
+
/** Blank when absent, null, or a whitespace-only string. */
|
|
13
|
+
export declare const isBlank: (value: unknown) => boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Wraps an optional or defaulted schema so `''`, whitespace, and all-blank objects
|
|
16
|
+
* parse as unset (taking the default when there is one). Sits outside `.default()`.
|
|
17
|
+
*/
|
|
18
|
+
export declare const blankAsUnset: <T extends z.ZodType>(schema: T) => z.ZodPreprocess<T, unknown>;
|
|
19
|
+
/** Options for {@link listInput}. */
|
|
20
|
+
export interface ListInputOptions {
|
|
21
|
+
/** Most items accepted; the preprocess keeps one more so `.max()` still reports overflow. */
|
|
22
|
+
max: number;
|
|
23
|
+
/** Per-item normalization applied after trimming, before validation. */
|
|
24
|
+
normalize: (item: string) => string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* An optional list that also accepts a comma-separated string. Items are trimmed and
|
|
28
|
+
* normalized, blanks dropped, and an empty list is unset.
|
|
29
|
+
*/
|
|
30
|
+
export declare function listInput<T extends z.ZodType>(item: T, { max, normalize }: ListInputOptions): z.ZodPreprocess<z.ZodOptional<z.ZodArray<T>>, unknown>;
|
|
31
|
+
/** Lower-cases a string before `schema` validates it, so a word enum accepts any case (`Tourism`). */
|
|
32
|
+
export declare const lowerCased: <T extends z.ZodType>(schema: T) => z.ZodPreprocess<T, unknown>;
|
|
33
|
+
/**
|
|
34
|
+
* Upper-cases a country code and maps it to the alpha-2 GeoNames keys countries by: `UK`
|
|
35
|
+
* (ISO's exceptionally reserved code for the United Kingdom) to `GB`, and an alpha-3 or
|
|
36
|
+
* three-digit numeric code to its country's alpha-2. A code no country has stays, upper-cased.
|
|
37
|
+
*/
|
|
38
|
+
export declare const toAlpha2: (item: string) => string;
|
|
39
|
+
/** Optional caller GeoNames account; never logged, cached, or echoed. */
|
|
40
|
+
export declare const geonamesUsernameInput: z.ZodPreprocess<z.ZodOptional<z.ZodString>, unknown>;
|
|
41
|
+
/** Spread into a tool's `inputAliases`. */
|
|
42
|
+
export declare const USERNAME_ALIASES: {
|
|
43
|
+
readonly username: 'geonamesUsername';
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Argument names `setup()` registers with `sanitization.setSensitiveFields`, so the
|
|
47
|
+
* failed-call payload record redacts a username sent under a near-miss key. The framework
|
|
48
|
+
* matches a key by its lower-cased alphanumerics and by its camelCase, snake_case, or
|
|
49
|
+
* kebab-case words: `user` and `account` cover `geonames_user` and `GeoNamesAccount`, and
|
|
50
|
+
* the run-together names cover all-caps keys such as `GEONAMES_USER`, which split into
|
|
51
|
+
* single letters.
|
|
52
|
+
*/
|
|
53
|
+
export declare const USERNAME_LOG_FIELDS: string[];
|
|
54
|
+
/**
|
|
55
|
+
* Required GeoNames feature id, as a digit string of at most {@link MAX_GEONAME_ID}. A
|
|
56
|
+
* JSON integer becomes its digit string here, so an out-of-range one gets the range message.
|
|
57
|
+
*/
|
|
58
|
+
export declare const geonameIdInput: z.ZodPreprocess<z.ZodString, unknown>;
|
|
59
|
+
/**
|
|
60
|
+
* Optional country filter, up to 10 codes, each mapped to alpha-2 by {@link toAlpha2}. A
|
|
61
|
+
* well-formed alpha-3 or numeric code no country has passes the schema for the tool to
|
|
62
|
+
* reject; see {@link unknownCountryCodes}.
|
|
63
|
+
*/
|
|
64
|
+
export declare const countriesInput: z.ZodPreprocess<z.ZodOptional<z.ZodArray<z.ZodString>>, unknown>;
|
|
65
|
+
/** `countries` entries no country has, and the message naming them. */
|
|
66
|
+
export interface UnknownCountryCodes {
|
|
67
|
+
/** Each entry as normalized, in input order. */
|
|
68
|
+
countries: string[];
|
|
69
|
+
message: string;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* The `countries` entries {@link toAlpha2} could not map: well-formed alpha-3 or numeric
|
|
73
|
+
* codes no country has. Returns `undefined` when every entry is alpha-2; an alpha-2 code
|
|
74
|
+
* GeoNames does not know still goes upstream and matches nothing.
|
|
75
|
+
*/
|
|
76
|
+
export declare function unknownCountryCodes(countries: readonly string[] | undefined): UnknownCountryCodes | undefined;
|
|
77
|
+
/** Optional feature-class filter, up to all nine classes. */
|
|
78
|
+
export declare const featureClassesInput: z.ZodPreprocess<z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
79
|
+
A: "A";
|
|
80
|
+
H: "H";
|
|
81
|
+
L: "L";
|
|
82
|
+
P: "P";
|
|
83
|
+
R: "R";
|
|
84
|
+
S: "S";
|
|
85
|
+
T: "T";
|
|
86
|
+
U: "U";
|
|
87
|
+
V: "V";
|
|
88
|
+
}>>>, unknown>;
|
|
89
|
+
/** Optional feature-code filter, up to 20 codes; tools check each against the bundled table. */
|
|
90
|
+
export declare const featureCodesInput: z.ZodPreprocess<z.ZodOptional<z.ZodArray<z.ZodString>>, unknown>;
|
|
91
|
+
/** Optional population tier for populated places. */
|
|
92
|
+
export declare const citiesInput: z.ZodPreprocess<z.ZodPreprocess<z.ZodOptional<z.ZodEnum<{
|
|
93
|
+
cities1000: "cities1000";
|
|
94
|
+
cities15000: "cities15000";
|
|
95
|
+
cities5000: "cities5000";
|
|
96
|
+
}>>, unknown>, unknown>;
|
|
97
|
+
/** Feature-filter entries GeoNames can never match, and the message naming them. */
|
|
98
|
+
export interface FeatureFilterMismatch {
|
|
99
|
+
/** Listed classes with no listed code, or other than P beside `cities`; each once, in input order. */
|
|
100
|
+
featureClasses: FeatureClass[];
|
|
101
|
+
/** Listed codes outside the listed classes, or outside class P beside `cities`; each once, in input order. */
|
|
102
|
+
featureCodes: string[];
|
|
103
|
+
message: string;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* GeoNames applies `featureClass`, `featureCode`, and `cities` (class P only) together,
|
|
107
|
+
* so a code whose class is not listed, a listed class with no listed code, and a class or
|
|
108
|
+
* code other than P beside `cities` each match nothing. Returns those entries, or
|
|
109
|
+
* `undefined` when every entry can match. A code the bundled table lacks has no class to
|
|
110
|
+
* compare and is skipped: tools reject it first as `unknown_feature_code`.
|
|
111
|
+
*/
|
|
112
|
+
export declare function featureFilterMismatch({ featureClasses, featureCodes, cities, }: {
|
|
113
|
+
cities?: string | undefined;
|
|
114
|
+
featureClasses: readonly FeatureClass[] | undefined;
|
|
115
|
+
featureCodes: readonly string[] | undefined;
|
|
116
|
+
}): FeatureFilterMismatch | undefined;
|
|
117
|
+
/** Latitude in decimal degrees. */
|
|
118
|
+
export declare const latInput: z.ZodNumber;
|
|
119
|
+
/** Longitude in decimal degrees. */
|
|
120
|
+
export declare const lngInput: z.ZodNumber;
|
|
121
|
+
/** Optional local name filter; see {@link nameMatcher}. */
|
|
122
|
+
export declare const nameContainsInput: z.ZodPreprocess<z.ZodOptional<z.ZodString>, unknown>;
|
|
123
|
+
/** A `limit` input: 1–`max`, `fallback` when omitted or blank. */
|
|
124
|
+
export declare const limitInput: (max: number, fallback: number) => z.ZodPreprocess<z.ZodDefault<z.ZodNumber>, unknown>;
|
|
125
|
+
/** An `offset` input: entries to skip, 0 when omitted or blank. */
|
|
126
|
+
export declare const offsetInput: (max?: number) => z.ZodPreprocess<z.ZodDefault<z.ZodNumber>, unknown>;
|
|
127
|
+
/**
|
|
128
|
+
* Builds the strict token matcher behind `nameContains`: every word of `query` must
|
|
129
|
+
* appear somewhere in the given fields.
|
|
130
|
+
*/
|
|
131
|
+
export declare function nameMatcher(query: string): (fields: readonly (string | undefined)[]) => boolean;
|
|
132
|
+
/** One page of a locally held list. */
|
|
133
|
+
export interface LocalPage<T> {
|
|
134
|
+
/** Offset of the next page; absent on the last page. */
|
|
135
|
+
nextOffset?: number;
|
|
136
|
+
page: T[];
|
|
137
|
+
}
|
|
138
|
+
/** Slices `items` at `offset`/`limit` and reports where the next page starts. */
|
|
139
|
+
export declare function paginate<T>(items: readonly T[], offset: number, limit: number): LocalPage<T>;
|
|
140
|
+
//# sourceMappingURL=shared-inputs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared-inputs.d.ts","sourceRoot":"","sources":["../../../src/mcp-server/tools/shared-inputs.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,wBAAwB,CAAC;AAE3C,OAAO,EAEL,KAAK,YAAY,EAElB,MAAM,sCAAsC,CAAC;AAE9C,4DAA4D;AAC5D,eAAO,MAAM,OAAO,UAAW,OAAO,KAAG,OACoD,CAAC;AAc9F;;;GAGG;AACH,eAAO,MAAM,YAAY,GAAI,CAAC,SAAS,CAAC,CAAC,OAAO,UAAU,CAAC,gCAAuC,CAAC;AAEnG,qCAAqC;AACrC,MAAM,WAAW,gBAAgB;IAC/B,6FAA6F;IAC7F,GAAG,EAAE,MAAM,CAAC;IACZ,wEAAwE;IACxE,SAAS,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;CACrC;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,CAAC,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE,EAAE,gBAAgB,0DAU3F;AAED,sGAAsG;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