@cyanheads/geonames-mcp-server 0.0.0-stage → 0.1.1
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 +438 -0
- package/CLAUDE.md +438 -0
- package/Dockerfile +177 -0
- package/LICENSE +201 -0
- package/README.md +316 -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/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 +90 -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 +262 -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 +88 -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 +248 -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 +735 -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 +134 -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 +381 -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 +133 -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 +348 -0
- package/dist/mcp-server/tools/definitions/search-places.tool.js.map +1 -0
- package/dist/mcp-server/tools/shared-inputs.d.ts +97 -0
- package/dist/mcp-server/tools/shared-inputs.d.ts.map +1 -0
- package/dist/mcp-server/tools/shared-inputs.js +156 -0
- package/dist/mcp-server/tools/shared-inputs.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 +98 -0
- package/dist/services/geonames/geonames-service.d.ts.map +1 -0
- package/dist/services/geonames/geonames-service.js +555 -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 +34 -0
- package/dist/services/geonames/response-parsers.d.ts.map +1 -0
- package/dist/services/geonames/response-parsers.js +350 -0
- package/dist/services/geonames/response-parsers.js.map +1 -0
- package/dist/services/geonames/types.d.ts +218 -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 +114 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAWH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAS9B,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Every GeoNames tool definition, collected for `createApp()`.
|
|
3
|
+
* @module mcp-server/tools/definitions
|
|
4
|
+
*/
|
|
5
|
+
import { findPostalCodesTool } from './find-postal-codes.tool.js';
|
|
6
|
+
import { getChildrenTool } from './get-children.tool.js';
|
|
7
|
+
import { getCountriesTool } from './get-countries.tool.js';
|
|
8
|
+
import { getHierarchyTool } from './get-hierarchy.tool.js';
|
|
9
|
+
import { getPlaceTool } from './get-place.tool.js';
|
|
10
|
+
import { listReferenceTool } from './list-reference.tool.js';
|
|
11
|
+
import { reverseGeocodeTool } from './reverse-geocode.tool.js';
|
|
12
|
+
import { searchPlacesTool } from './search-places.tool.js';
|
|
13
|
+
export const allToolDefinitions = [
|
|
14
|
+
searchPlacesTool,
|
|
15
|
+
getPlaceTool,
|
|
16
|
+
getHierarchyTool,
|
|
17
|
+
getChildrenTool,
|
|
18
|
+
reverseGeocodeTool,
|
|
19
|
+
findPostalCodesTool,
|
|
20
|
+
getCountriesTool,
|
|
21
|
+
listReferenceTool,
|
|
22
|
+
];
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3D,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,gBAAgB;IAChB,YAAY;IACZ,gBAAgB;IAChB,eAAe;IACf,kBAAkB;IAClB,mBAAmB;IACnB,gBAAgB;IAChB,iBAAiB;CAClB,CAAC"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview geonames_list_reference — decodes GeoNames vocabulary: the nine feature
|
|
3
|
+
* classes and 684 feature codes (bundled, no credits) and the countries with postal-code
|
|
4
|
+
* data (one cached GeoNames call a day).
|
|
5
|
+
* @module mcp-server/tools/definitions/list-reference.tool
|
|
6
|
+
*/
|
|
7
|
+
import { z } from '@cyanheads/mcp-ts-core';
|
|
8
|
+
import { JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
|
|
9
|
+
export declare const listReferenceTool: import("@cyanheads/mcp-ts-core").ToolDefinition<z.ZodObject<{
|
|
10
|
+
topic: z.ZodPreprocess<z.ZodEnum<{
|
|
11
|
+
feature_classes: "feature_classes";
|
|
12
|
+
feature_codes: "feature_codes";
|
|
13
|
+
postal_countries: "postal_countries";
|
|
14
|
+
}>, unknown>;
|
|
15
|
+
featureClass: z.ZodPreprocess<z.ZodPreprocess<z.ZodOptional<z.ZodEnum<{
|
|
16
|
+
A: "A";
|
|
17
|
+
H: "H";
|
|
18
|
+
L: "L";
|
|
19
|
+
P: "P";
|
|
20
|
+
R: "R";
|
|
21
|
+
S: "S";
|
|
22
|
+
T: "T";
|
|
23
|
+
U: "U";
|
|
24
|
+
V: "V";
|
|
25
|
+
}>>, unknown>, unknown>;
|
|
26
|
+
nameContains: z.ZodPreprocess<z.ZodOptional<z.ZodString>, unknown>;
|
|
27
|
+
limit: z.ZodPreprocess<z.ZodDefault<z.ZodNumber>, unknown>;
|
|
28
|
+
offset: z.ZodPreprocess<z.ZodDefault<z.ZodNumber>, unknown>;
|
|
29
|
+
geonamesUsername: z.ZodPreprocess<z.ZodOptional<z.ZodString>, unknown>;
|
|
30
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
31
|
+
topic: z.ZodEnum<{
|
|
32
|
+
feature_classes: "feature_classes";
|
|
33
|
+
feature_codes: "feature_codes";
|
|
34
|
+
postal_countries: "postal_countries";
|
|
35
|
+
}>;
|
|
36
|
+
entries: z.ZodArray<z.ZodObject<{
|
|
37
|
+
code: z.ZodString;
|
|
38
|
+
name: z.ZodString;
|
|
39
|
+
description: z.ZodOptional<z.ZodString>;
|
|
40
|
+
featureClass: z.ZodOptional<z.ZodEnum<{
|
|
41
|
+
A: "A";
|
|
42
|
+
H: "H";
|
|
43
|
+
L: "L";
|
|
44
|
+
P: "P";
|
|
45
|
+
R: "R";
|
|
46
|
+
S: "S";
|
|
47
|
+
T: "T";
|
|
48
|
+
U: "U";
|
|
49
|
+
V: "V";
|
|
50
|
+
}>>;
|
|
51
|
+
postalCodeCount: z.ZodOptional<z.ZodNumber>;
|
|
52
|
+
minPostalCode: z.ZodOptional<z.ZodString>;
|
|
53
|
+
maxPostalCode: z.ZodOptional<z.ZodString>;
|
|
54
|
+
}, z.core.$strip>>;
|
|
55
|
+
nextOffset: z.ZodOptional<z.ZodNumber>;
|
|
56
|
+
}, z.core.$strip>, readonly [{
|
|
57
|
+
readonly reason: "filter_not_applicable";
|
|
58
|
+
readonly code: JsonRpcErrorCode.ValidationError;
|
|
59
|
+
readonly when: "featureClass was given with a topic other than feature_codes.";
|
|
60
|
+
readonly recovery: "Drop featureClass, or call geonames_list_reference with topic feature_codes to filter codes by class.";
|
|
61
|
+
readonly severity: "notice";
|
|
62
|
+
}, {
|
|
63
|
+
readonly reason: "username_required";
|
|
64
|
+
readonly code: JsonRpcErrorCode.Unauthorized;
|
|
65
|
+
readonly when: "Neither geonamesUsername nor the server's GEONAMES_USERNAME supplies a GeoNames account.";
|
|
66
|
+
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.";
|
|
67
|
+
readonly severity: "notice";
|
|
68
|
+
readonly thrownBy: "service";
|
|
69
|
+
}, {
|
|
70
|
+
readonly reason: "caller_account_rejected";
|
|
71
|
+
readonly code: JsonRpcErrorCode.Unauthorized;
|
|
72
|
+
readonly when: "GeoNames rejected the caller-supplied geonamesUsername (unknown user, or free web services not enabled).";
|
|
73
|
+
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.";
|
|
74
|
+
readonly severity: "notice";
|
|
75
|
+
readonly thrownBy: "service";
|
|
76
|
+
}, {
|
|
77
|
+
readonly reason: "server_account_rejected";
|
|
78
|
+
readonly code: JsonRpcErrorCode.ConfigurationError;
|
|
79
|
+
readonly when: "GeoNames rejected the server's GEONAMES_USERNAME.";
|
|
80
|
+
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.";
|
|
81
|
+
readonly thrownBy: "service";
|
|
82
|
+
}, {
|
|
83
|
+
readonly reason: "quota_exhausted";
|
|
84
|
+
readonly code: JsonRpcErrorCode.RateLimited;
|
|
85
|
+
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.";
|
|
86
|
+
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.";
|
|
87
|
+
readonly retryable: true;
|
|
88
|
+
readonly thrownBy: "service";
|
|
89
|
+
}, {
|
|
90
|
+
readonly reason: "upstream_rejected_parameter";
|
|
91
|
+
readonly code: JsonRpcErrorCode.ValidationError;
|
|
92
|
+
readonly when: "GeoNames rejected a value the schema let through; the message carries its text.";
|
|
93
|
+
readonly recovery: "Correct the value named in the message and call again; geonames_list_reference lists valid feature classes, feature codes, and postal coverage.";
|
|
94
|
+
readonly severity: "notice";
|
|
95
|
+
readonly thrownBy: "service";
|
|
96
|
+
}], {
|
|
97
|
+
readonly totalCount: z.ZodNumber;
|
|
98
|
+
readonly truncated: z.ZodBoolean;
|
|
99
|
+
readonly shown: z.ZodNumber;
|
|
100
|
+
readonly cap: z.ZodNumber;
|
|
101
|
+
readonly notice: z.ZodOptional<z.ZodString>;
|
|
102
|
+
}>;
|
|
103
|
+
//# sourceMappingURL=list-reference.tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-reference.tool.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/list-reference.tool.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAQ,CAAC,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AA+DjE,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAsP5B,CAAC"}
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview geonames_list_reference — decodes GeoNames vocabulary: the nine feature
|
|
3
|
+
* classes and 684 feature codes (bundled, no credits) and the countries with postal-code
|
|
4
|
+
* data (one cached GeoNames call a day).
|
|
5
|
+
* @module mcp-server/tools/definitions/list-reference.tool
|
|
6
|
+
*/
|
|
7
|
+
import { tool, z } from '@cyanheads/mcp-ts-core';
|
|
8
|
+
import { JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
|
|
9
|
+
import { blankAsUnset, geonamesUsernameInput, limitInput, lowerCased, nameContainsInput, nameMatcher, offsetInput, paginate, USERNAME_ALIASES, } from '../shared-inputs.js';
|
|
10
|
+
import { FEATURE_CLASS_CODES, FEATURE_CLASS_LABELS, FEATURE_CODES, } 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 TOPICS = ['feature_classes', 'feature_codes', 'postal_countries'];
|
|
14
|
+
const TOPIC_TITLES = {
|
|
15
|
+
feature_classes: 'feature classes',
|
|
16
|
+
feature_codes: 'feature codes',
|
|
17
|
+
postal_countries: 'countries with postal-code data',
|
|
18
|
+
};
|
|
19
|
+
/** Each class's GeoNames category, with examples drawn from its readme label and codes. */
|
|
20
|
+
const CLASS_CATEGORIES = {
|
|
21
|
+
A: 'Administrative boundary features: countries, states, regions, and other divisions',
|
|
22
|
+
H: 'Hydrographic features: streams, lakes, bays, springs, and other water',
|
|
23
|
+
L: 'Area features: parks, regions, reserves, ports, and other areas',
|
|
24
|
+
P: 'Populated place features: cities, towns, villages, and their sections',
|
|
25
|
+
R: 'Road and railroad features',
|
|
26
|
+
S: 'Spot features: buildings, farms, airports, stations, and other sites',
|
|
27
|
+
T: 'Hypsographic features: mountains, hills, rocks, valleys, and other terrain',
|
|
28
|
+
U: 'Undersea features',
|
|
29
|
+
V: 'Vegetation features: forests, heaths, and other land cover',
|
|
30
|
+
};
|
|
31
|
+
const FEATURE_CLASS_ENTRIES = FEATURE_CLASS_CODES.map((code) => {
|
|
32
|
+
const count = FEATURE_CODES.filter((entry) => entry.featureClass === code).length;
|
|
33
|
+
return {
|
|
34
|
+
code,
|
|
35
|
+
name: FEATURE_CLASS_LABELS[code],
|
|
36
|
+
description: `${CLASS_CATEGORIES[code]}. ${count} feature codes; list them with topic feature_codes and featureClass ${code}.`,
|
|
37
|
+
};
|
|
38
|
+
});
|
|
39
|
+
export const listReferenceTool = tool('geonames_list_reference', {
|
|
40
|
+
title: 'GeoNames reference vocabulary',
|
|
41
|
+
description: "Decode GeoNames vocabulary used by the other tools: topic feature_classes lists the 9 one-letter classes; topic feature_codes lists the 684 feature codes with names and definitions, filterable by class and text; topic postal_countries lists the 122 countries with postal-code data and each one's code range and count. feature_classes and feature_codes are bundled and spend no credits; postal_countries costs 1 GeoNames credit a day (cached).",
|
|
42
|
+
annotations: { readOnlyHint: true, idempotentHint: true, openWorldHint: true },
|
|
43
|
+
input: z.object({
|
|
44
|
+
topic: lowerCased(z.enum(TOPICS)).describe('Vocabulary to list: feature_classes (the 9 one-letter classes), feature_codes (the 684 codes), or postal_countries (countries with postal-code data). Case-insensitive.'),
|
|
45
|
+
featureClass: blankAsUnset(z.preprocess((value) => (typeof value === 'string' ? value.toUpperCase() : value), z.enum(FEATURE_CLASS_CODES).optional())).describe('Topic feature_codes only: keep the codes of this one-letter class (A, H, L, P, R, S, T, U, V). Case-insensitive.'),
|
|
46
|
+
nameContains: nameContainsInput.describe('Keep only entries whose code, name, or description contains every word of this text as a substring (port also matches airport), ignoring case, accents, and punctuation.'),
|
|
47
|
+
limit: limitInput(700, 100),
|
|
48
|
+
offset: offsetInput(),
|
|
49
|
+
geonamesUsername: geonamesUsernameInput.describe("Topic postal_countries only, and only when the list is not already cached: your own GeoNames username, so the call spends that account's credit instead of the server's. The account needs free web services enabled on its geonames.org account page."),
|
|
50
|
+
}),
|
|
51
|
+
inputAliases: USERNAME_ALIASES,
|
|
52
|
+
output: z.object({
|
|
53
|
+
topic: z.enum(TOPICS).describe('The topic listed.'),
|
|
54
|
+
entries: z
|
|
55
|
+
.array(z
|
|
56
|
+
.object({
|
|
57
|
+
code: z
|
|
58
|
+
.string()
|
|
59
|
+
.describe('Feature class letter, feature code without its class prefix (PPLC), or ISO 3166-1 alpha-2 country code.'),
|
|
60
|
+
name: z
|
|
61
|
+
.string()
|
|
62
|
+
.describe("GeoNames' label: the class label, the feature code's name, or the country name."),
|
|
63
|
+
description: z
|
|
64
|
+
.string()
|
|
65
|
+
.optional()
|
|
66
|
+
.describe("The class's category and code count, or GeoNames' definition of the feature code. Absent where GeoNames gives none."),
|
|
67
|
+
featureClass: z
|
|
68
|
+
.enum(FEATURE_CLASS_CODES)
|
|
69
|
+
.optional()
|
|
70
|
+
.describe('Topic feature_codes: the class the code belongs to.'),
|
|
71
|
+
postalCodeCount: z
|
|
72
|
+
.number()
|
|
73
|
+
.optional()
|
|
74
|
+
.describe('Topic postal_countries: how many postal codes GeoNames holds for the country.'),
|
|
75
|
+
minPostalCode: z
|
|
76
|
+
.string()
|
|
77
|
+
.optional()
|
|
78
|
+
.describe('Topic postal_countries: the lowest postal code or prefix GeoNames holds.'),
|
|
79
|
+
maxPostalCode: z
|
|
80
|
+
.string()
|
|
81
|
+
.optional()
|
|
82
|
+
.describe('Topic postal_countries: the highest postal code or prefix GeoNames holds.'),
|
|
83
|
+
})
|
|
84
|
+
.describe('One vocabulary entry.'))
|
|
85
|
+
.describe('Entries on this page, in GeoNames order.'),
|
|
86
|
+
nextOffset: z.number().optional().describe('Offset of the next page; absent on the last page.'),
|
|
87
|
+
}),
|
|
88
|
+
enrichment: {
|
|
89
|
+
totalCount: z.number().describe('Entries matching the topic and filters, before paging.'),
|
|
90
|
+
truncated: z.boolean().describe('True when more entries remain past this page.'),
|
|
91
|
+
shown: z.number().describe('Entries returned on this page.'),
|
|
92
|
+
cap: z.number().describe('The limit that was applied.'),
|
|
93
|
+
notice: z
|
|
94
|
+
.string()
|
|
95
|
+
.optional()
|
|
96
|
+
.describe('Guidance when nothing matched, the offset is past the end, or more pages remain.'),
|
|
97
|
+
},
|
|
98
|
+
errors: [
|
|
99
|
+
{
|
|
100
|
+
reason: 'filter_not_applicable',
|
|
101
|
+
code: JsonRpcErrorCode.ValidationError,
|
|
102
|
+
when: 'featureClass was given with a topic other than feature_codes.',
|
|
103
|
+
recovery: 'Drop featureClass, or call geonames_list_reference with topic feature_codes to filter codes by class.',
|
|
104
|
+
severity: 'notice',
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
reason: 'username_required',
|
|
108
|
+
code: JsonRpcErrorCode.Unauthorized,
|
|
109
|
+
when: "Neither geonamesUsername nor the server's GEONAMES_USERNAME supplies a GeoNames account.",
|
|
110
|
+
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.',
|
|
111
|
+
severity: 'notice',
|
|
112
|
+
thrownBy: 'service',
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
reason: 'caller_account_rejected',
|
|
116
|
+
code: JsonRpcErrorCode.Unauthorized,
|
|
117
|
+
when: 'GeoNames rejected the caller-supplied geonamesUsername (unknown user, or free web services not enabled).',
|
|
118
|
+
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.",
|
|
119
|
+
severity: 'notice',
|
|
120
|
+
thrownBy: 'service',
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
reason: 'server_account_rejected',
|
|
124
|
+
code: JsonRpcErrorCode.ConfigurationError,
|
|
125
|
+
when: "GeoNames rejected the server's GEONAMES_USERNAME.",
|
|
126
|
+
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.',
|
|
127
|
+
thrownBy: 'service',
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
reason: 'quota_exhausted',
|
|
131
|
+
code: JsonRpcErrorCode.RateLimited,
|
|
132
|
+
when: "GeoNames reported the account's hourly, daily, or weekly credit limit spent, or this server's pacer for the account shed the call.",
|
|
133
|
+
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.",
|
|
134
|
+
retryable: true,
|
|
135
|
+
thrownBy: 'service',
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
reason: 'upstream_rejected_parameter',
|
|
139
|
+
code: JsonRpcErrorCode.ValidationError,
|
|
140
|
+
when: 'GeoNames rejected a value the schema let through; the message carries its text.',
|
|
141
|
+
recovery: 'Correct the value named in the message and call again; geonames_list_reference lists valid feature classes, feature codes, and postal coverage.',
|
|
142
|
+
severity: 'notice',
|
|
143
|
+
thrownBy: 'service',
|
|
144
|
+
},
|
|
145
|
+
],
|
|
146
|
+
async handler(input, ctx) {
|
|
147
|
+
ctx.enrich({ totalCount: 0, truncated: false, shown: 0, cap: input.limit });
|
|
148
|
+
if (input.featureClass !== undefined && input.topic !== 'feature_codes') {
|
|
149
|
+
throw ctx.fail('filter_not_applicable', `featureClass applies only to topic feature_codes, not ${input.topic}.`);
|
|
150
|
+
}
|
|
151
|
+
let entries;
|
|
152
|
+
switch (input.topic) {
|
|
153
|
+
case 'feature_classes':
|
|
154
|
+
entries = FEATURE_CLASS_ENTRIES;
|
|
155
|
+
break;
|
|
156
|
+
case 'feature_codes':
|
|
157
|
+
entries =
|
|
158
|
+
input.featureClass === undefined
|
|
159
|
+
? FEATURE_CODES
|
|
160
|
+
: FEATURE_CODES.filter((entry) => entry.featureClass === input.featureClass);
|
|
161
|
+
break;
|
|
162
|
+
case 'postal_countries': {
|
|
163
|
+
const service = getGeoNamesService();
|
|
164
|
+
const account = service.resolveAccount(input.geonamesUsername);
|
|
165
|
+
entries = (await service.postalCountries(account, ctx)).map(({ countryCode, countryName, ...postal }) => ({
|
|
166
|
+
code: countryCode,
|
|
167
|
+
name: countryName,
|
|
168
|
+
...postal,
|
|
169
|
+
}));
|
|
170
|
+
break;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
const matcher = input.nameContains === undefined ? undefined : nameMatcher(input.nameContains);
|
|
174
|
+
const matches = matcher
|
|
175
|
+
? entries.filter((entry) => matcher([entry.code, entry.name, entry.description]))
|
|
176
|
+
: entries;
|
|
177
|
+
const { page, nextOffset } = paginate(matches, input.offset, input.limit);
|
|
178
|
+
ctx.enrich.total(matches.length);
|
|
179
|
+
ctx.enrich({ shown: page.length });
|
|
180
|
+
if (nextOffset !== undefined) {
|
|
181
|
+
ctx.enrich.truncated({
|
|
182
|
+
shown: page.length,
|
|
183
|
+
cap: input.limit,
|
|
184
|
+
guidance: `${matches.length - nextOffset} more ${matches.length - nextOffset === 1 ? 'entry' : 'entries'}; call again with offset ${nextOffset}.`,
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
if (page.length === 0) {
|
|
188
|
+
const scope = input.featureClass === undefined
|
|
189
|
+
? input.topic
|
|
190
|
+
: `${input.topic} of class ${input.featureClass}`;
|
|
191
|
+
if (matches.length > 0) {
|
|
192
|
+
ctx.enrich.notice(`offset ${input.offset} is past the last entry (${matches.length}); call again with a smaller offset.`);
|
|
193
|
+
}
|
|
194
|
+
else if (input.nameContains !== undefined) {
|
|
195
|
+
ctx.enrich.notice(`Nothing in ${scope} matches "${inlineText(input.nameContains)}"; call again without nameContains.`);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
return {
|
|
199
|
+
topic: input.topic,
|
|
200
|
+
entries: page,
|
|
201
|
+
...(nextOffset === undefined ? {} : { nextOffset }),
|
|
202
|
+
};
|
|
203
|
+
},
|
|
204
|
+
format: (result) => {
|
|
205
|
+
const lines = [`## GeoNames ${TOPIC_TITLES[result.topic]} (topic ${result.topic})`, ''];
|
|
206
|
+
if (result.entries.length === 0) {
|
|
207
|
+
lines.push('No entries on this page.');
|
|
208
|
+
}
|
|
209
|
+
else {
|
|
210
|
+
const has = (key) => result.entries.some((entry) => entry[key] !== undefined);
|
|
211
|
+
const columns = [
|
|
212
|
+
['Code', (entry) => tableCell(entry.code)],
|
|
213
|
+
['Name', (entry) => tableCell(entry.name)],
|
|
214
|
+
];
|
|
215
|
+
if (has('featureClass'))
|
|
216
|
+
columns.push(['Class', (entry) => entry.featureClass ?? '—']);
|
|
217
|
+
if (has('description')) {
|
|
218
|
+
columns.push(['Description', (entry) => tableCell(entry.description ?? 'Not available')]);
|
|
219
|
+
}
|
|
220
|
+
if (has('postalCodeCount')) {
|
|
221
|
+
columns.push(['Postal codes', (entry) => String(entry.postalCodeCount ?? 'Not available')]);
|
|
222
|
+
}
|
|
223
|
+
if (has('minPostalCode') || has('maxPostalCode')) {
|
|
224
|
+
columns.push(['Lowest', (entry) => tableCell(entry.minPostalCode ?? 'Not available')], ['Highest', (entry) => tableCell(entry.maxPostalCode ?? 'Not available')]);
|
|
225
|
+
}
|
|
226
|
+
lines.push(`| ${columns.map(([header]) => header).join(' | ')} |`, `|${columns.map(() => ':---').join('|')}|`, ...result.entries.map((entry) => `| ${columns.map(([, cell]) => cell(entry)).join(' | ')} |`));
|
|
227
|
+
}
|
|
228
|
+
if (result.nextOffset !== undefined)
|
|
229
|
+
lines.push('', `Next page: offset ${result.nextOffset}.`);
|
|
230
|
+
return [{ type: 'text', text: lines.join('\n') }];
|
|
231
|
+
},
|
|
232
|
+
});
|
|
233
|
+
//# sourceMappingURL=list-reference.tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-reference.tool.js","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/list-reference.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,qBAAqB,EACrB,UAAU,EACV,UAAU,EACV,iBAAiB,EACjB,WAAW,EACX,WAAW,EACX,QAAQ,EACR,gBAAgB,GACjB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EACL,mBAAmB,EACnB,oBAAoB,EACpB,aAAa,GA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E,CAAC,CAAC;IACpD,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,134 @@
|
|
|
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 { z } from '@cyanheads/mcp-ts-core';
|
|
10
|
+
import { JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
|
|
11
|
+
export declare const reverseGeocodeTool: import("@cyanheads/mcp-ts-core").ToolDefinition<z.ZodObject<{
|
|
12
|
+
lat: z.ZodNumber;
|
|
13
|
+
lng: z.ZodNumber;
|
|
14
|
+
nearbyLimit: z.ZodPreprocess<z.ZodDefault<z.ZodNumber>, unknown>;
|
|
15
|
+
radiusKm: z.ZodPreprocess<z.ZodDefault<z.ZodNumber>, unknown>;
|
|
16
|
+
cities: z.ZodPreprocess<z.ZodPreprocess<z.ZodOptional<z.ZodEnum<{
|
|
17
|
+
cities1000: "cities1000";
|
|
18
|
+
cities15000: "cities15000";
|
|
19
|
+
cities5000: "cities5000";
|
|
20
|
+
}>>, unknown>, unknown>;
|
|
21
|
+
featureClasses: z.ZodPreprocess<z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
22
|
+
A: "A";
|
|
23
|
+
H: "H";
|
|
24
|
+
L: "L";
|
|
25
|
+
P: "P";
|
|
26
|
+
R: "R";
|
|
27
|
+
S: "S";
|
|
28
|
+
T: "T";
|
|
29
|
+
U: "U";
|
|
30
|
+
V: "V";
|
|
31
|
+
}>>>, unknown>;
|
|
32
|
+
featureCodes: z.ZodPreprocess<z.ZodOptional<z.ZodArray<z.ZodString>>, unknown>;
|
|
33
|
+
includeTimezone: z.ZodPreprocess<z.ZodDefault<z.ZodBoolean>, unknown>;
|
|
34
|
+
geonamesUsername: z.ZodPreprocess<z.ZodOptional<z.ZodString>, unknown>;
|
|
35
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
36
|
+
lat: z.ZodNumber;
|
|
37
|
+
lng: z.ZodNumber;
|
|
38
|
+
country: z.ZodOptional<z.ZodObject<{
|
|
39
|
+
countryCode: z.ZodString;
|
|
40
|
+
countryName: z.ZodOptional<z.ZodString>;
|
|
41
|
+
}, z.core.$strip>>;
|
|
42
|
+
adminLevels: z.ZodArray<z.ZodObject<{
|
|
43
|
+
level: z.ZodNumber;
|
|
44
|
+
code: z.ZodOptional<z.ZodString>;
|
|
45
|
+
name: z.ZodOptional<z.ZodString>;
|
|
46
|
+
geonameId: z.ZodOptional<z.ZodNumber>;
|
|
47
|
+
isoCode: z.ZodOptional<z.ZodString>;
|
|
48
|
+
}, z.core.$strip>>;
|
|
49
|
+
ocean: z.ZodOptional<z.ZodObject<{
|
|
50
|
+
name: z.ZodString;
|
|
51
|
+
geonameId: z.ZodOptional<z.ZodNumber>;
|
|
52
|
+
}, z.core.$strip>>;
|
|
53
|
+
nearbyKind: z.ZodEnum<{
|
|
54
|
+
features: "features";
|
|
55
|
+
none: "none";
|
|
56
|
+
populated_places: "populated_places";
|
|
57
|
+
}>;
|
|
58
|
+
nearby: z.ZodArray<z.ZodObject<{
|
|
59
|
+
geonameId: z.ZodNumber;
|
|
60
|
+
name: z.ZodString;
|
|
61
|
+
toponymName: z.ZodString;
|
|
62
|
+
featureClass: z.ZodOptional<z.ZodString>;
|
|
63
|
+
featureCode: z.ZodOptional<z.ZodString>;
|
|
64
|
+
featureName: z.ZodOptional<z.ZodString>;
|
|
65
|
+
countryCode: z.ZodOptional<z.ZodString>;
|
|
66
|
+
adminName1: z.ZodOptional<z.ZodString>;
|
|
67
|
+
lat: z.ZodOptional<z.ZodNumber>;
|
|
68
|
+
lng: z.ZodOptional<z.ZodNumber>;
|
|
69
|
+
distanceInKm: z.ZodOptional<z.ZodNumber>;
|
|
70
|
+
population: z.ZodOptional<z.ZodNumber>;
|
|
71
|
+
}, z.core.$strip>>;
|
|
72
|
+
timezone: z.ZodOptional<z.ZodObject<{
|
|
73
|
+
timezoneId: z.ZodOptional<z.ZodString>;
|
|
74
|
+
countryCode: z.ZodOptional<z.ZodString>;
|
|
75
|
+
rawOffsetInHours: z.ZodNumber;
|
|
76
|
+
gmtOffsetInHours: z.ZodNumber;
|
|
77
|
+
dstOffsetInHours: z.ZodNumber;
|
|
78
|
+
localTime: z.ZodOptional<z.ZodString>;
|
|
79
|
+
sunrise: z.ZodOptional<z.ZodString>;
|
|
80
|
+
sunset: z.ZodOptional<z.ZodString>;
|
|
81
|
+
}, z.core.$strip>>;
|
|
82
|
+
}, z.core.$strip>, readonly [{
|
|
83
|
+
readonly reason: "unknown_feature_code";
|
|
84
|
+
readonly code: JsonRpcErrorCode.ValidationError;
|
|
85
|
+
readonly when: "A featureCodes entry is not a GeoNames feature code.";
|
|
86
|
+
readonly recovery: "Look up valid codes with geonames_list_reference topic feature_codes, then retry with a listed code.";
|
|
87
|
+
readonly severity: "notice";
|
|
88
|
+
}, {
|
|
89
|
+
readonly reason: "conflicting_filters";
|
|
90
|
+
readonly code: JsonRpcErrorCode.ValidationError;
|
|
91
|
+
readonly when: "cities was combined with featureClasses or featureCodes.";
|
|
92
|
+
readonly 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.";
|
|
93
|
+
readonly severity: "notice";
|
|
94
|
+
}, {
|
|
95
|
+
readonly reason: "username_required";
|
|
96
|
+
readonly code: JsonRpcErrorCode.Unauthorized;
|
|
97
|
+
readonly when: "Neither geonamesUsername nor the server's GEONAMES_USERNAME supplies a GeoNames account.";
|
|
98
|
+
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.";
|
|
99
|
+
readonly severity: "notice";
|
|
100
|
+
readonly thrownBy: "service";
|
|
101
|
+
}, {
|
|
102
|
+
readonly reason: "caller_account_rejected";
|
|
103
|
+
readonly code: JsonRpcErrorCode.Unauthorized;
|
|
104
|
+
readonly when: "GeoNames rejected the caller-supplied geonamesUsername (unknown user, or free web services not enabled).";
|
|
105
|
+
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.";
|
|
106
|
+
readonly severity: "notice";
|
|
107
|
+
readonly thrownBy: "service";
|
|
108
|
+
}, {
|
|
109
|
+
readonly reason: "server_account_rejected";
|
|
110
|
+
readonly code: JsonRpcErrorCode.ConfigurationError;
|
|
111
|
+
readonly when: "GeoNames rejected the server's GEONAMES_USERNAME.";
|
|
112
|
+
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.";
|
|
113
|
+
readonly thrownBy: "service";
|
|
114
|
+
}, {
|
|
115
|
+
readonly reason: "quota_exhausted";
|
|
116
|
+
readonly code: JsonRpcErrorCode.RateLimited;
|
|
117
|
+
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.";
|
|
118
|
+
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.";
|
|
119
|
+
readonly retryable: true;
|
|
120
|
+
readonly thrownBy: "service";
|
|
121
|
+
}, {
|
|
122
|
+
readonly reason: "upstream_rejected_parameter";
|
|
123
|
+
readonly code: JsonRpcErrorCode.ValidationError;
|
|
124
|
+
readonly when: "GeoNames rejected a value the schema let through; the message carries its text.";
|
|
125
|
+
readonly recovery: "Correct the value named in the message and call again; geonames_list_reference lists valid feature classes, feature codes, and postal coverage.";
|
|
126
|
+
readonly severity: "notice";
|
|
127
|
+
readonly thrownBy: "service";
|
|
128
|
+
}], {
|
|
129
|
+
readonly truncated: z.ZodBoolean;
|
|
130
|
+
readonly shown: z.ZodNumber;
|
|
131
|
+
readonly cap: z.ZodNumber;
|
|
132
|
+
readonly notice: z.ZodOptional<z.ZodString>;
|
|
133
|
+
}>;
|
|
134
|
+
//# sourceMappingURL=reverse-geocode.tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reverse-geocode.tool.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/reverse-geocode.tool.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAQ,CAAC,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAsDjE,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAqb7B,CAAC"}
|