@cyanheads/openstreetmap-mcp-server 0.2.0
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/CLAUDE.md +393 -0
- package/Dockerfile +99 -0
- package/LICENSE +201 -0
- package/README.md +283 -0
- package/dist/config/server-config.d.ts +14 -0
- package/dist/config/server-config.d.ts.map +1 -0
- package/dist/config/server-config.js +47 -0
- package/dist/config/server-config.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +40 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp-server/tools/definitions/openstreetmap-format.d.ts +18 -0
- package/dist/mcp-server/tools/definitions/openstreetmap-format.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/openstreetmap-format.js +36 -0
- package/dist/mcp-server/tools/definitions/openstreetmap-format.js.map +1 -0
- package/dist/mcp-server/tools/definitions/openstreetmap-geocode.tool.d.ts +59 -0
- package/dist/mcp-server/tools/definitions/openstreetmap-geocode.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/openstreetmap-geocode.tool.js +203 -0
- package/dist/mcp-server/tools/definitions/openstreetmap-geocode.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/openstreetmap-lookup.tool.d.ts +39 -0
- package/dist/mcp-server/tools/definitions/openstreetmap-lookup.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/openstreetmap-lookup.tool.js +136 -0
- package/dist/mcp-server/tools/definitions/openstreetmap-lookup.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/openstreetmap-query-bbox.tool.d.ts +57 -0
- package/dist/mcp-server/tools/definitions/openstreetmap-query-bbox.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/openstreetmap-query-bbox.tool.js +170 -0
- package/dist/mcp-server/tools/definitions/openstreetmap-query-bbox.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/openstreetmap-query-nearby.tool.d.ts +56 -0
- package/dist/mcp-server/tools/definitions/openstreetmap-query-nearby.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/openstreetmap-query-nearby.tool.js +174 -0
- package/dist/mcp-server/tools/definitions/openstreetmap-query-nearby.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/openstreetmap-query-raw.tool.d.ts +38 -0
- package/dist/mcp-server/tools/definitions/openstreetmap-query-raw.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/openstreetmap-query-raw.tool.js +124 -0
- package/dist/mcp-server/tools/definitions/openstreetmap-query-raw.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/openstreetmap-reverse.tool.d.ts +40 -0
- package/dist/mcp-server/tools/definitions/openstreetmap-reverse.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/openstreetmap-reverse.tool.js +129 -0
- package/dist/mcp-server/tools/definitions/openstreetmap-reverse.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/openstreetmap-tag-input.d.ts +21 -0
- package/dist/mcp-server/tools/definitions/openstreetmap-tag-input.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/openstreetmap-tag-input.js +22 -0
- package/dist/mcp-server/tools/definitions/openstreetmap-tag-input.js.map +1 -0
- package/dist/services/nominatim/nominatim-service.d.ts +24 -0
- package/dist/services/nominatim/nominatim-service.d.ts.map +1 -0
- package/dist/services/nominatim/nominatim-service.js +160 -0
- package/dist/services/nominatim/nominatim-service.js.map +1 -0
- package/dist/services/nominatim/types.d.ts +55 -0
- package/dist/services/nominatim/types.d.ts.map +1 -0
- package/dist/services/nominatim/types.js +6 -0
- package/dist/services/nominatim/types.js.map +1 -0
- package/dist/services/overpass/overpass-service.d.ts +25 -0
- package/dist/services/overpass/overpass-service.d.ts.map +1 -0
- package/dist/services/overpass/overpass-service.js +146 -0
- package/dist/services/overpass/overpass-service.js.map +1 -0
- package/dist/services/overpass/types.d.ts +59 -0
- package/dist/services/overpass/types.d.ts.map +1 -0
- package/dist/services/overpass/types.js +6 -0
- package/dist/services/overpass/types.js.map +1 -0
- package/package.json +91 -0
- package/server.json +153 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Shared formatting helpers for Nominatim place result rendering.
|
|
3
|
+
* @module mcp-server/tools/definitions/openstreetmap-format
|
|
4
|
+
*/
|
|
5
|
+
/** Address keys to omit from the address details line (technical codes, not human-readable). */
|
|
6
|
+
const ADDR_SKIP_KEYS = new Set(['country_code', 'ISO3166-2-lvl4']);
|
|
7
|
+
/**
|
|
8
|
+
* Append formatted lines for the common fields shared across all three Nominatim
|
|
9
|
+
* tool format() functions: OSM ref, category, address breakdown, bounding box, extratags.
|
|
10
|
+
*/
|
|
11
|
+
export function appendPlaceLines(lines, r) {
|
|
12
|
+
if (r.osm_type && r.osm_id !== undefined) {
|
|
13
|
+
lines.push(`**OSM:** ${r.osm_type.charAt(0).toUpperCase()}${r.osm_id}`);
|
|
14
|
+
}
|
|
15
|
+
if (r.category) {
|
|
16
|
+
lines.push(`**Category:** ${r.category}${r.type ? ` / ${r.type}` : ''}`);
|
|
17
|
+
}
|
|
18
|
+
if (r.address) {
|
|
19
|
+
const addrParts = Object.entries(r.address)
|
|
20
|
+
.filter(([k]) => !ADDR_SKIP_KEYS.has(k))
|
|
21
|
+
.map(([k, v]) => `${k}: ${v}`)
|
|
22
|
+
.join(', ');
|
|
23
|
+
if (addrParts)
|
|
24
|
+
lines.push(`**Address details:** ${addrParts}`);
|
|
25
|
+
}
|
|
26
|
+
if (r.boundingbox) {
|
|
27
|
+
lines.push(`**Bounding box:** S:${r.boundingbox[0]} N:${r.boundingbox[1]} W:${r.boundingbox[2]} E:${r.boundingbox[3]}`);
|
|
28
|
+
}
|
|
29
|
+
if (r.extratags && Object.keys(r.extratags).length > 0) {
|
|
30
|
+
const extra = Object.entries(r.extratags)
|
|
31
|
+
.map(([k, v]) => `${k}: ${v}`)
|
|
32
|
+
.join(', ');
|
|
33
|
+
lines.push(`**Extra tags:** ${extra}`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=openstreetmap-format.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openstreetmap-format.js","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/openstreetmap-format.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,gGAAgG;AAChG,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC,CAAC,cAAc,EAAE,gBAAgB,CAAC,CAAC,CAAC;AAEnE;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAC9B,KAAe,EACf,CAQC;IAED,IAAI,CAAC,CAAC,QAAQ,IAAI,CAAC,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;QACzC,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;IAC1E,CAAC;IACD,IAAI,CAAC,CAAC,QAAQ,EAAE,CAAC;QACf,KAAK,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,QAAQ,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAC3E,CAAC;IACD,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC;QACd,MAAM,SAAS,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC;aACxC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;aACvC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;aAC7B,IAAI,CAAC,IAAI,CAAC,CAAC;QACd,IAAI,SAAS;YAAE,KAAK,CAAC,IAAI,CAAC,wBAAwB,SAAS,EAAE,CAAC,CAAC;IACjE,CAAC;IACD,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC;QAClB,KAAK,CAAC,IAAI,CACR,uBAAuB,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,CAC5G,CAAC;IACJ,CAAC;IACD,IAAI,CAAC,CAAC,SAAS,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACvD,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC;aACtC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;aAC7B,IAAI,CAAC,IAAI,CAAC,CAAC;QACd,KAAK,CAAC,IAAI,CAAC,mBAAmB,KAAK,EAAE,CAAC,CAAC;IACzC,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Forward geocoding tool — converts place names or addresses to coordinates.
|
|
3
|
+
* @module mcp-server/tools/definitions/openstreetmap-geocode.tool
|
|
4
|
+
*/
|
|
5
|
+
import { z } from '@cyanheads/mcp-ts-core';
|
|
6
|
+
import { JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
|
|
7
|
+
export declare const openstreetmapGeocode: import("@cyanheads/mcp-ts-core").ToolDefinition<z.ZodObject<{
|
|
8
|
+
query: z.ZodOptional<z.ZodString>;
|
|
9
|
+
street: z.ZodOptional<z.ZodString>;
|
|
10
|
+
city: z.ZodOptional<z.ZodString>;
|
|
11
|
+
county: z.ZodOptional<z.ZodString>;
|
|
12
|
+
state: z.ZodOptional<z.ZodString>;
|
|
13
|
+
country: z.ZodOptional<z.ZodString>;
|
|
14
|
+
postalcode: z.ZodOptional<z.ZodString>;
|
|
15
|
+
limit: z.ZodDefault<z.ZodNumber>;
|
|
16
|
+
countrycodes: z.ZodOptional<z.ZodString>;
|
|
17
|
+
layer: z.ZodOptional<z.ZodString>;
|
|
18
|
+
featureType: z.ZodOptional<z.ZodEnum<{
|
|
19
|
+
city: "city";
|
|
20
|
+
state: "state";
|
|
21
|
+
country: "country";
|
|
22
|
+
settlement: "settlement";
|
|
23
|
+
}>>;
|
|
24
|
+
extratags: z.ZodDefault<z.ZodBoolean>;
|
|
25
|
+
language: z.ZodOptional<z.ZodString>;
|
|
26
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
27
|
+
results: z.ZodArray<z.ZodObject<{
|
|
28
|
+
place_id: z.ZodNumber;
|
|
29
|
+
osm_type: z.ZodOptional<z.ZodEnum<{
|
|
30
|
+
node: "node";
|
|
31
|
+
way: "way";
|
|
32
|
+
relation: "relation";
|
|
33
|
+
}>>;
|
|
34
|
+
osm_id: z.ZodOptional<z.ZodNumber>;
|
|
35
|
+
lat: z.ZodString;
|
|
36
|
+
lon: z.ZodString;
|
|
37
|
+
display_name: z.ZodString;
|
|
38
|
+
name: z.ZodOptional<z.ZodString>;
|
|
39
|
+
category: z.ZodOptional<z.ZodString>;
|
|
40
|
+
type: z.ZodOptional<z.ZodString>;
|
|
41
|
+
importance: z.ZodOptional<z.ZodNumber>;
|
|
42
|
+
address: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
43
|
+
boundingbox: z.ZodOptional<z.ZodTuple<[z.ZodString, z.ZodString, z.ZodString, z.ZodString], null>>;
|
|
44
|
+
extratags: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
45
|
+
}, z.core.$strip>>;
|
|
46
|
+
total: z.ZodNumber;
|
|
47
|
+
attribution: z.ZodString;
|
|
48
|
+
}, z.core.$strip>, readonly [{
|
|
49
|
+
readonly reason: "no_results";
|
|
50
|
+
readonly code: JsonRpcErrorCode.NotFound;
|
|
51
|
+
readonly when: "No places matched the query.";
|
|
52
|
+
readonly recovery: "Try broader terms, remove constraints, or check spelling. For structured queries, try the free-form query parameter.";
|
|
53
|
+
}, {
|
|
54
|
+
readonly reason: "invalid_input";
|
|
55
|
+
readonly code: JsonRpcErrorCode.ValidationError;
|
|
56
|
+
readonly when: "Both query and structured fields are provided, or neither is provided.";
|
|
57
|
+
readonly recovery: "Provide either the query parameter (free-form) or structured address fields (street, city, etc.), not both.";
|
|
58
|
+
}]>;
|
|
59
|
+
//# sourceMappingURL=openstreetmap-geocode.tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openstreetmap-geocode.tool.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/openstreetmap-geocode.tool.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAQ,CAAC,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAMjE,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwP/B,CAAC"}
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Forward geocoding tool — converts place names or addresses to coordinates.
|
|
3
|
+
* @module mcp-server/tools/definitions/openstreetmap-geocode.tool
|
|
4
|
+
*/
|
|
5
|
+
import { tool, z } from '@cyanheads/mcp-ts-core';
|
|
6
|
+
import { JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
|
|
7
|
+
import { getNominatimService } from '../../../services/nominatim/nominatim-service.js';
|
|
8
|
+
import { appendPlaceLines } from './openstreetmap-format.js';
|
|
9
|
+
const ATTRIBUTION = 'Data © OpenStreetMap contributors, ODbL 1.0';
|
|
10
|
+
export const openstreetmapGeocode = tool('openstreetmap_geocode', {
|
|
11
|
+
title: 'Geocode a place name or address',
|
|
12
|
+
description: 'Convert a place name or address to geographic coordinates and structured place data via Nominatim/OpenStreetMap. ' +
|
|
13
|
+
'Accepts either a free-form query string (e.g., "Space Needle Seattle") or structured address fields (street, city, state, etc.) — ' +
|
|
14
|
+
'the two modes are mutually exclusive. Returns results ordered by Nominatim relevance (importance score). ' +
|
|
15
|
+
'Use countrycodes to restrict results to specific countries. ' +
|
|
16
|
+
'For exhaustive POI lists in an area, use openstreetmap_query_nearby or openstreetmap_query_bbox instead — ' +
|
|
17
|
+
'Nominatim search returns best matches, not all matching objects.',
|
|
18
|
+
annotations: { readOnlyHint: true, idempotentHint: true, openWorldHint: true },
|
|
19
|
+
input: z.object({
|
|
20
|
+
query: z
|
|
21
|
+
.string()
|
|
22
|
+
.optional()
|
|
23
|
+
.describe('Free-form search string (e.g., "Space Needle Seattle" or "1600 Pennsylvania Ave NW, Washington DC"). Cannot be combined with structured address fields.'),
|
|
24
|
+
street: z
|
|
25
|
+
.string()
|
|
26
|
+
.optional()
|
|
27
|
+
.describe('House number and street name (structured query). Use with city/state/country fields. Cannot be combined with query.'),
|
|
28
|
+
city: z.string().optional().describe('City name (structured query).'),
|
|
29
|
+
county: z.string().optional().describe('County or district (structured query).'),
|
|
30
|
+
state: z.string().optional().describe('State or province (structured query).'),
|
|
31
|
+
country: z
|
|
32
|
+
.string()
|
|
33
|
+
.optional()
|
|
34
|
+
.describe('Country name or ISO 3166-1 alpha-2 code (structured query).'),
|
|
35
|
+
postalcode: z.string().optional().describe('Postal or ZIP code (structured query).'),
|
|
36
|
+
limit: z
|
|
37
|
+
.number()
|
|
38
|
+
.int()
|
|
39
|
+
.min(1)
|
|
40
|
+
.max(40)
|
|
41
|
+
.default(5)
|
|
42
|
+
.describe('Maximum results to return. Nominatim may return fewer when additional results do not sufficiently match. Max 40.'),
|
|
43
|
+
countrycodes: z
|
|
44
|
+
.string()
|
|
45
|
+
.optional()
|
|
46
|
+
.describe('Restrict results to one or more countries. Comma-separated ISO 3166-1 alpha-2 codes (e.g., "us,ca"). Preferred over the structured country field when filtering.'),
|
|
47
|
+
layer: z
|
|
48
|
+
.string()
|
|
49
|
+
.optional()
|
|
50
|
+
.describe('Filter by data layer. Comma-separated values: address, poi, railway, natural, manmade. Default: no restriction.'),
|
|
51
|
+
featureType: z
|
|
52
|
+
.enum(['country', 'state', 'city', 'settlement'])
|
|
53
|
+
.optional()
|
|
54
|
+
.describe('Restrict results to a geographic feature type. Automatically implies the address layer.'),
|
|
55
|
+
extratags: z
|
|
56
|
+
.boolean()
|
|
57
|
+
.default(false)
|
|
58
|
+
.describe('Include extra OSM tags when available (e.g., phone, website, opening_hours, wikidata). Increases response size.'),
|
|
59
|
+
language: z
|
|
60
|
+
.string()
|
|
61
|
+
.optional()
|
|
62
|
+
.describe('Preferred language for result names (BCP 47 code or Accept-Language string, e.g., "en", "de", "fr,en"). Defaults to local OSM language.'),
|
|
63
|
+
}),
|
|
64
|
+
output: z.object({
|
|
65
|
+
results: z
|
|
66
|
+
.array(z
|
|
67
|
+
.object({
|
|
68
|
+
place_id: z
|
|
69
|
+
.number()
|
|
70
|
+
.describe('Nominatim internal place ID. Use osm_type+osm_id for stable cross-server references.'),
|
|
71
|
+
osm_type: z.enum(['node', 'way', 'relation']).optional().describe('OSM object type.'),
|
|
72
|
+
osm_id: z
|
|
73
|
+
.number()
|
|
74
|
+
.optional()
|
|
75
|
+
.describe('OSM object ID. Combine with osm_type for openstreetmap_lookup.'),
|
|
76
|
+
lat: z.string().describe('Latitude (WGS84, as string from API).'),
|
|
77
|
+
lon: z.string().describe('Longitude (WGS84, as string from API).'),
|
|
78
|
+
display_name: z.string().describe('Full human-readable address string.'),
|
|
79
|
+
name: z
|
|
80
|
+
.string()
|
|
81
|
+
.optional()
|
|
82
|
+
.describe('Feature name if applicable (e.g., "Space Needle"). Absent for address-only results.'),
|
|
83
|
+
category: z
|
|
84
|
+
.string()
|
|
85
|
+
.optional()
|
|
86
|
+
.describe('OSM feature category (e.g., "amenity", "man_made", "boundary").'),
|
|
87
|
+
type: z
|
|
88
|
+
.string()
|
|
89
|
+
.optional()
|
|
90
|
+
.describe('OSM feature type within category (e.g., "hospital", "tower", "administrative").'),
|
|
91
|
+
importance: z
|
|
92
|
+
.number()
|
|
93
|
+
.optional()
|
|
94
|
+
.describe('Nominatim relevance score (0–1). Higher is more globally prominent.'),
|
|
95
|
+
address: z
|
|
96
|
+
.record(z.string(), z.string())
|
|
97
|
+
.optional()
|
|
98
|
+
.describe('Structured address breakdown. Keys vary by feature type and country. Common keys: house_number, road, suburb, city, state, postcode, country, country_code.'),
|
|
99
|
+
boundingbox: z
|
|
100
|
+
.tuple([z.string(), z.string(), z.string(), z.string()])
|
|
101
|
+
.optional()
|
|
102
|
+
.describe('Bounding box as [south, north, west, east] strings.'),
|
|
103
|
+
extratags: z
|
|
104
|
+
.record(z.string(), z.string())
|
|
105
|
+
.optional()
|
|
106
|
+
.describe('Additional OSM tags (phone, website, opening_hours, wikidata). Present only when extratags was requested.'),
|
|
107
|
+
})
|
|
108
|
+
.describe('A single geocoding result.'))
|
|
109
|
+
.describe('Geocoding results, ordered by Nominatim relevance (importance score descending).'),
|
|
110
|
+
total: z.number().describe('Number of results returned.'),
|
|
111
|
+
attribution: z
|
|
112
|
+
.string()
|
|
113
|
+
.describe('Required data attribution: Data © OpenStreetMap contributors, ODbL 1.0.'),
|
|
114
|
+
}),
|
|
115
|
+
errors: [
|
|
116
|
+
{
|
|
117
|
+
reason: 'no_results',
|
|
118
|
+
code: JsonRpcErrorCode.NotFound,
|
|
119
|
+
when: 'No places matched the query.',
|
|
120
|
+
recovery: 'Try broader terms, remove constraints, or check spelling. For structured queries, try the free-form query parameter.',
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
reason: 'invalid_input',
|
|
124
|
+
code: JsonRpcErrorCode.ValidationError,
|
|
125
|
+
when: 'Both query and structured fields are provided, or neither is provided.',
|
|
126
|
+
recovery: 'Provide either the query parameter (free-form) or structured address fields (street, city, etc.), not both.',
|
|
127
|
+
},
|
|
128
|
+
],
|
|
129
|
+
async handler(input, ctx) {
|
|
130
|
+
const hasQuery = Boolean(input.query?.trim());
|
|
131
|
+
const hasStructured = Boolean(input.street?.trim() ||
|
|
132
|
+
input.city?.trim() ||
|
|
133
|
+
input.county?.trim() ||
|
|
134
|
+
input.state?.trim() ||
|
|
135
|
+
input.country?.trim() ||
|
|
136
|
+
input.postalcode?.trim());
|
|
137
|
+
if (hasQuery && hasStructured) {
|
|
138
|
+
throw ctx.fail('invalid_input', 'Cannot combine free-form query with structured address fields.', { ...ctx.recoveryFor('invalid_input') });
|
|
139
|
+
}
|
|
140
|
+
if (!hasQuery && !hasStructured) {
|
|
141
|
+
throw ctx.fail('invalid_input', 'Provide either the query parameter or at least one structured address field.', { ...ctx.recoveryFor('invalid_input') });
|
|
142
|
+
}
|
|
143
|
+
const service = getNominatimService();
|
|
144
|
+
const results = await service.search({
|
|
145
|
+
...(hasQuery && input.query ? { q: input.query } : {}),
|
|
146
|
+
...(input.street?.trim() ? { street: input.street } : {}),
|
|
147
|
+
...(input.city?.trim() ? { city: input.city } : {}),
|
|
148
|
+
...(input.county?.trim() ? { county: input.county } : {}),
|
|
149
|
+
...(input.state?.trim() ? { state: input.state } : {}),
|
|
150
|
+
...(input.country?.trim() ? { country: input.country } : {}),
|
|
151
|
+
...(input.postalcode?.trim() ? { postalcode: input.postalcode } : {}),
|
|
152
|
+
limit: input.limit,
|
|
153
|
+
...(input.countrycodes?.trim() ? { countrycodes: input.countrycodes } : {}),
|
|
154
|
+
...(input.layer?.trim() ? { layer: input.layer } : {}),
|
|
155
|
+
...(input.featureType ? { featureType: input.featureType } : {}),
|
|
156
|
+
extratags: input.extratags,
|
|
157
|
+
...(input.language?.trim() ? { language: input.language } : {}),
|
|
158
|
+
}, ctx);
|
|
159
|
+
if (results.length === 0) {
|
|
160
|
+
throw ctx.fail('no_results', `No places found for "${input.query ?? [input.city, input.state, input.country].filter(Boolean).join(', ')}"`, { ...ctx.recoveryFor('no_results') });
|
|
161
|
+
}
|
|
162
|
+
ctx.log.info('Geocode results', { count: results.length });
|
|
163
|
+
return {
|
|
164
|
+
results: results.map((r) => ({
|
|
165
|
+
place_id: r.place_id,
|
|
166
|
+
...(r.osm_type ? { osm_type: r.osm_type } : {}),
|
|
167
|
+
...(r.osm_id !== undefined ? { osm_id: r.osm_id } : {}),
|
|
168
|
+
lat: r.lat,
|
|
169
|
+
lon: r.lon,
|
|
170
|
+
display_name: r.display_name,
|
|
171
|
+
...(r.name ? { name: r.name } : {}),
|
|
172
|
+
...(r.category ? { category: r.category } : {}),
|
|
173
|
+
...(r.type ? { type: r.type } : {}),
|
|
174
|
+
...(r.importance !== undefined ? { importance: r.importance } : {}),
|
|
175
|
+
...(r.address ? { address: r.address } : {}),
|
|
176
|
+
...(r.boundingbox ? { boundingbox: r.boundingbox } : {}),
|
|
177
|
+
...(r.extratags ? { extratags: r.extratags } : {}),
|
|
178
|
+
})),
|
|
179
|
+
total: results.length,
|
|
180
|
+
attribution: ATTRIBUTION,
|
|
181
|
+
};
|
|
182
|
+
},
|
|
183
|
+
format: (result) => {
|
|
184
|
+
const lines = [
|
|
185
|
+
`**${result.total} result${result.total === 1 ? '' : 's'} found**`,
|
|
186
|
+
'',
|
|
187
|
+
];
|
|
188
|
+
for (const r of result.results) {
|
|
189
|
+
if (r.name)
|
|
190
|
+
lines.push(`## ${r.name}`);
|
|
191
|
+
lines.push(`**Address:** ${r.display_name}`);
|
|
192
|
+
lines.push(`**Coordinates:** ${r.lat}, ${r.lon}`);
|
|
193
|
+
lines.push(`**Place ID:** ${r.place_id}`);
|
|
194
|
+
if (r.importance !== undefined)
|
|
195
|
+
lines.push(`**Importance:** ${r.importance.toFixed(3)}`);
|
|
196
|
+
appendPlaceLines(lines, r);
|
|
197
|
+
lines.push('');
|
|
198
|
+
}
|
|
199
|
+
lines.push(`*${result.attribution}*`);
|
|
200
|
+
return [{ type: 'text', text: lines.join('\n') }];
|
|
201
|
+
},
|
|
202
|
+
});
|
|
203
|
+
//# sourceMappingURL=openstreetmap-geocode.tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openstreetmap-geocode.tool.js","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/openstreetmap-geocode.tool.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,2CAA2C,CAAC;AAChF,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAE7D,MAAM,WAAW,GAAG,6CAA6C,CAAC;AAElE,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAI,CAAC,uBAAuB,EAAE;IAChE,KAAK,EAAE,iCAAiC;IACxC,WAAW,EACT,mHAAmH;QACnH,oIAAoI;QACpI,2GAA2G;QAC3G,8DAA8D;QAC9D,4GAA4G;QAC5G,kEAAkE;IACpE,WAAW,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE;IAE9E,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC;QACd,KAAK,EAAE,CAAC;aACL,MAAM,EAAE;aACR,QAAQ,EAAE;aACV,QAAQ,CACP,yJAAyJ,CAC1J;QACH,MAAM,EAAE,CAAC;aACN,MAAM,EAAE;aACR,QAAQ,EAAE;aACV,QAAQ,CACP,qHAAqH,CACtH;QACH,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,+BAA+B,CAAC;QACrE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,wCAA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AAC;QACtC,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,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview OSM ID lookup tool — fetches address details for known OSM objects.
|
|
3
|
+
* @module mcp-server/tools/definitions/openstreetmap-lookup.tool
|
|
4
|
+
*/
|
|
5
|
+
import { z } from '@cyanheads/mcp-ts-core';
|
|
6
|
+
import { JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
|
|
7
|
+
export declare const openstreetmapLookup: import("@cyanheads/mcp-ts-core").ToolDefinition<z.ZodObject<{
|
|
8
|
+
osm_ids: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>;
|
|
9
|
+
extratags: z.ZodDefault<z.ZodBoolean>;
|
|
10
|
+
language: z.ZodOptional<z.ZodString>;
|
|
11
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
12
|
+
results: z.ZodArray<z.ZodObject<{
|
|
13
|
+
place_id: z.ZodNumber;
|
|
14
|
+
osm_type: z.ZodOptional<z.ZodEnum<{
|
|
15
|
+
node: "node";
|
|
16
|
+
way: "way";
|
|
17
|
+
relation: "relation";
|
|
18
|
+
}>>;
|
|
19
|
+
osm_id: z.ZodOptional<z.ZodNumber>;
|
|
20
|
+
lat: z.ZodString;
|
|
21
|
+
lon: z.ZodString;
|
|
22
|
+
display_name: z.ZodString;
|
|
23
|
+
name: z.ZodOptional<z.ZodString>;
|
|
24
|
+
category: z.ZodOptional<z.ZodString>;
|
|
25
|
+
type: z.ZodOptional<z.ZodString>;
|
|
26
|
+
address: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
27
|
+
boundingbox: z.ZodOptional<z.ZodTuple<[z.ZodString, z.ZodString, z.ZodString, z.ZodString], null>>;
|
|
28
|
+
extratags: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
29
|
+
}, z.core.$strip>>;
|
|
30
|
+
not_found: z.ZodArray<z.ZodString>;
|
|
31
|
+
total: z.ZodNumber;
|
|
32
|
+
attribution: z.ZodString;
|
|
33
|
+
}, z.core.$strip>, readonly [{
|
|
34
|
+
readonly reason: "invalid_id_format";
|
|
35
|
+
readonly code: JsonRpcErrorCode.ValidationError;
|
|
36
|
+
readonly when: "An OSM ID is missing the N/W/R prefix or is otherwise malformed.";
|
|
37
|
+
readonly recovery: "Prefix each ID with N (node), W (way), or R (relation), e.g., \"N12345\" not \"12345\".";
|
|
38
|
+
}]>;
|
|
39
|
+
//# sourceMappingURL=openstreetmap-lookup.tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openstreetmap-lookup.tool.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/openstreetmap-lookup.tool.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAQ,CAAC,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AASjE,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuJ9B,CAAC"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview OSM ID lookup tool — fetches address details for known OSM objects.
|
|
3
|
+
* @module mcp-server/tools/definitions/openstreetmap-lookup.tool
|
|
4
|
+
*/
|
|
5
|
+
import { tool, z } from '@cyanheads/mcp-ts-core';
|
|
6
|
+
import { JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
|
|
7
|
+
import { getNominatimService } from '../../../services/nominatim/nominatim-service.js';
|
|
8
|
+
import { appendPlaceLines } from './openstreetmap-format.js';
|
|
9
|
+
const ATTRIBUTION = 'Data © OpenStreetMap contributors, ODbL 1.0';
|
|
10
|
+
/** Regex for valid OSM IDs: N/W/R prefix followed by digits. */
|
|
11
|
+
const OSM_ID_PATTERN = /^[NWRnwr]\d+$/;
|
|
12
|
+
export const openstreetmapLookup = tool('openstreetmap_lookup', {
|
|
13
|
+
title: 'Look up address details for OSM objects by ID',
|
|
14
|
+
description: 'Fetch address details for one or more known OSM objects by their IDs via Nominatim. ' +
|
|
15
|
+
'Each ID must be prefixed with N (node), W (way), or R (relation), e.g., "N240109189", "W50637691", "R146656". ' +
|
|
16
|
+
'Up to 50 IDs per call. ' +
|
|
17
|
+
'Use when an OSM ID is already known from a prior openstreetmap_query_nearby or openstreetmap_query_bbox result — ' +
|
|
18
|
+
'this is more efficient than a geocoding round trip to get the full Nominatim address record.',
|
|
19
|
+
annotations: { readOnlyHint: true, idempotentHint: true, openWorldHint: true },
|
|
20
|
+
input: z.object({
|
|
21
|
+
osm_ids: z
|
|
22
|
+
.union([
|
|
23
|
+
z.string().describe('Single OSM ID string, e.g., "N240109189".'),
|
|
24
|
+
z.array(z.string()).min(1).max(50).describe('Array of OSM ID strings, up to 50.'),
|
|
25
|
+
])
|
|
26
|
+
.describe('One or more OSM IDs, each prefixed with N (node), W (way), or R (relation). E.g., "N240109189", ["W50637691", "R146656"]. Up to 50 IDs per call.'),
|
|
27
|
+
extratags: z
|
|
28
|
+
.boolean()
|
|
29
|
+
.default(false)
|
|
30
|
+
.describe('Include extra OSM tags (phone, website, wikidata, etc.).'),
|
|
31
|
+
language: z.string().optional().describe('Preferred language for names (BCP 47 code).'),
|
|
32
|
+
}),
|
|
33
|
+
output: z.object({
|
|
34
|
+
results: z
|
|
35
|
+
.array(z
|
|
36
|
+
.object({
|
|
37
|
+
place_id: z.number().describe('Nominatim internal place ID.'),
|
|
38
|
+
osm_type: z.enum(['node', 'way', 'relation']).optional().describe('OSM object type.'),
|
|
39
|
+
osm_id: z.number().optional().describe('OSM object ID.'),
|
|
40
|
+
lat: z.string().describe('Latitude (WGS84, as string from API).'),
|
|
41
|
+
lon: z.string().describe('Longitude (WGS84, as string from API).'),
|
|
42
|
+
display_name: z.string().describe('Full human-readable address string.'),
|
|
43
|
+
name: z.string().optional().describe('Feature name if applicable.'),
|
|
44
|
+
category: z.string().optional().describe('OSM feature category.'),
|
|
45
|
+
type: z.string().optional().describe('OSM feature type within category.'),
|
|
46
|
+
address: z
|
|
47
|
+
.record(z.string(), z.string())
|
|
48
|
+
.optional()
|
|
49
|
+
.describe('Structured address breakdown. Keys vary by feature type.'),
|
|
50
|
+
boundingbox: z
|
|
51
|
+
.tuple([z.string(), z.string(), z.string(), z.string()])
|
|
52
|
+
.optional()
|
|
53
|
+
.describe('Bounding box as [south, north, west, east] strings.'),
|
|
54
|
+
extratags: z
|
|
55
|
+
.record(z.string(), z.string())
|
|
56
|
+
.optional()
|
|
57
|
+
.describe('Additional OSM tags. Present only when extratags was requested.'),
|
|
58
|
+
})
|
|
59
|
+
.describe('Address details for a single OSM ID lookup result.'))
|
|
60
|
+
.describe('Address details for the requested OSM IDs that were found.'),
|
|
61
|
+
not_found: z.array(z.string()).describe('OSM IDs from the request that returned no result.'),
|
|
62
|
+
total: z.number().describe('Number of results returned.'),
|
|
63
|
+
attribution: z
|
|
64
|
+
.string()
|
|
65
|
+
.describe('Required data attribution: Data © OpenStreetMap contributors, ODbL 1.0.'),
|
|
66
|
+
}),
|
|
67
|
+
errors: [
|
|
68
|
+
{
|
|
69
|
+
reason: 'invalid_id_format',
|
|
70
|
+
code: JsonRpcErrorCode.ValidationError,
|
|
71
|
+
when: 'An OSM ID is missing the N/W/R prefix or is otherwise malformed.',
|
|
72
|
+
recovery: 'Prefix each ID with N (node), W (way), or R (relation), e.g., "N12345" not "12345".',
|
|
73
|
+
},
|
|
74
|
+
],
|
|
75
|
+
async handler(input, ctx) {
|
|
76
|
+
const ids = Array.isArray(input.osm_ids) ? input.osm_ids : [input.osm_ids];
|
|
77
|
+
for (const id of ids) {
|
|
78
|
+
if (!OSM_ID_PATTERN.test(id.trim())) {
|
|
79
|
+
throw ctx.fail('invalid_id_format', `Invalid OSM ID format: "${id}". IDs must be prefixed with N, W, or R (e.g., "N12345").`, { id, ...ctx.recoveryFor('invalid_id_format') });
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
const normalizedIds = ids.map((id) => id.trim().toUpperCase());
|
|
83
|
+
const service = getNominatimService();
|
|
84
|
+
const results = await service.lookup({
|
|
85
|
+
osm_ids: normalizedIds,
|
|
86
|
+
extratags: input.extratags,
|
|
87
|
+
...(input.language?.trim() ? { language: input.language } : {}),
|
|
88
|
+
}, ctx);
|
|
89
|
+
const foundOsmIds = new Set(results.flatMap((r) => r.osm_type && r.osm_id !== undefined
|
|
90
|
+
? [`${r.osm_type.charAt(0).toUpperCase()}${r.osm_id}`]
|
|
91
|
+
: []));
|
|
92
|
+
const notFound = normalizedIds.filter((id) => !foundOsmIds.has(id));
|
|
93
|
+
ctx.log.info('Lookup results', { found: results.length, notFound: notFound.length });
|
|
94
|
+
return {
|
|
95
|
+
results: results.map((r) => ({
|
|
96
|
+
place_id: r.place_id,
|
|
97
|
+
...(r.osm_type ? { osm_type: r.osm_type } : {}),
|
|
98
|
+
...(r.osm_id !== undefined ? { osm_id: r.osm_id } : {}),
|
|
99
|
+
lat: r.lat,
|
|
100
|
+
lon: r.lon,
|
|
101
|
+
display_name: r.display_name,
|
|
102
|
+
...(r.name ? { name: r.name } : {}),
|
|
103
|
+
...(r.category ? { category: r.category } : {}),
|
|
104
|
+
...(r.type ? { type: r.type } : {}),
|
|
105
|
+
...(r.address ? { address: r.address } : {}),
|
|
106
|
+
...(r.boundingbox ? { boundingbox: r.boundingbox } : {}),
|
|
107
|
+
...(r.extratags ? { extratags: r.extratags } : {}),
|
|
108
|
+
})),
|
|
109
|
+
not_found: notFound,
|
|
110
|
+
total: results.length,
|
|
111
|
+
attribution: ATTRIBUTION,
|
|
112
|
+
};
|
|
113
|
+
},
|
|
114
|
+
format: (result) => {
|
|
115
|
+
const lines = [
|
|
116
|
+
`**${result.total} result${result.total === 1 ? '' : 's'} found**`,
|
|
117
|
+
'',
|
|
118
|
+
];
|
|
119
|
+
for (const r of result.results) {
|
|
120
|
+
if (r.name)
|
|
121
|
+
lines.push(`## ${r.name}`);
|
|
122
|
+
lines.push(`**Address:** ${r.display_name}`);
|
|
123
|
+
lines.push(`**Coordinates:** ${r.lat}, ${r.lon}`);
|
|
124
|
+
lines.push(`**Place ID:** ${r.place_id}`);
|
|
125
|
+
appendPlaceLines(lines, r);
|
|
126
|
+
lines.push('');
|
|
127
|
+
}
|
|
128
|
+
if (result.not_found.length > 0) {
|
|
129
|
+
lines.push(`**Not found:** ${result.not_found.join(', ')}`);
|
|
130
|
+
lines.push('');
|
|
131
|
+
}
|
|
132
|
+
lines.push(`*${result.attribution}*`);
|
|
133
|
+
return [{ type: 'text', text: lines.join('\n') }];
|
|
134
|
+
},
|
|
135
|
+
});
|
|
136
|
+
//# sourceMappingURL=openstreetmap-lookup.tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openstreetmap-lookup.tool.js","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/openstreetmap-lookup.tool.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,2CAA2C,CAAC;AAChF,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAE7D,MAAM,WAAW,GAAG,6CAA6C,CAAC;AAElE,gEAAgE;AAChE,MAAM,cAAc,GAAG,eAAe,CAAC;AAEvC,MAAM,CAAC,MAAM,mBAAmB,GAAG,IAAI,CAAC,sBAAsB,EAAE;IAC9D,KAAK,EAAE,+CAA+C;IACtD,WAAW,EACT,sFAAsF;QACtF,gHAAgH;QAChH,yBAAyB;QACzB,mHAAmH;QACnH,8FAA8F;IAChG,WAAW,EAAE,EAAE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AAC,CAAC;YAClD,KAAK,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;YAC1C,gBAAgB,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;YAC3B,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACjB,CAAC;QACD,IAAI,MAAM,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAChC,KAAK,CAAC,IAAI,CAAC,kBAAkB,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YAC5D,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACjB,CAAC;QACD,KAAK,CAAC,IAAI,CAAC,IAAI,MAAM,CAAC,WAAW,GAAG,CAAC,CAAC;QACtC,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,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Overpass bounding box query tool — finds OSM features within a bbox.
|
|
3
|
+
* @module mcp-server/tools/definitions/openstreetmap-query-bbox.tool
|
|
4
|
+
*/
|
|
5
|
+
import { z } from '@cyanheads/mcp-ts-core';
|
|
6
|
+
import { JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
|
|
7
|
+
export declare const openstreetmapQueryBbox: import("@cyanheads/mcp-ts-core").ToolDefinition<z.ZodObject<{
|
|
8
|
+
south: z.ZodNumber;
|
|
9
|
+
west: z.ZodNumber;
|
|
10
|
+
north: z.ZodNumber;
|
|
11
|
+
east: z.ZodNumber;
|
|
12
|
+
amenity: z.ZodOptional<z.ZodString>;
|
|
13
|
+
tag_key: z.ZodOptional<z.ZodString>;
|
|
14
|
+
tag_value: z.ZodOptional<z.ZodString>;
|
|
15
|
+
element_types: z.ZodDefault<z.ZodArray<z.ZodEnum<{
|
|
16
|
+
node: "node";
|
|
17
|
+
way: "way";
|
|
18
|
+
relation: "relation";
|
|
19
|
+
}>>>;
|
|
20
|
+
limit: z.ZodDefault<z.ZodNumber>;
|
|
21
|
+
timeout_seconds: z.ZodDefault<z.ZodNumber>;
|
|
22
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
23
|
+
elements: z.ZodArray<z.ZodObject<{
|
|
24
|
+
osm_type: z.ZodEnum<{
|
|
25
|
+
node: "node";
|
|
26
|
+
way: "way";
|
|
27
|
+
relation: "relation";
|
|
28
|
+
}>;
|
|
29
|
+
osm_id: z.ZodNumber;
|
|
30
|
+
lat: z.ZodOptional<z.ZodNumber>;
|
|
31
|
+
lon: z.ZodOptional<z.ZodNumber>;
|
|
32
|
+
name: z.ZodOptional<z.ZodString>;
|
|
33
|
+
tags: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
34
|
+
}, z.core.$strip>>;
|
|
35
|
+
total_found: z.ZodNumber;
|
|
36
|
+
truncated: z.ZodBoolean;
|
|
37
|
+
data_timestamp: z.ZodString;
|
|
38
|
+
attribution: z.ZodString;
|
|
39
|
+
}, z.core.$strip>, readonly [{
|
|
40
|
+
readonly reason: "invalid_tag";
|
|
41
|
+
readonly code: JsonRpcErrorCode.ValidationError;
|
|
42
|
+
readonly when: "Both amenity and tag_key/tag_value are provided, or neither is provided.";
|
|
43
|
+
readonly recovery: "Provide either amenity (e.g., \"hospital\") or tag_key + tag_value (e.g., tag_key=\"leisure\", tag_value=\"park\"), but not both and not neither.";
|
|
44
|
+
}, {
|
|
45
|
+
readonly reason: "query_timeout";
|
|
46
|
+
readonly code: JsonRpcErrorCode.Timeout;
|
|
47
|
+
readonly when: "The Overpass query exceeded the timeout.";
|
|
48
|
+
readonly retryable: true;
|
|
49
|
+
readonly recovery: "Reduce the bounding box area, add more specific tag filters, or increase timeout_seconds and retry.";
|
|
50
|
+
}, {
|
|
51
|
+
readonly reason: "rate_limited";
|
|
52
|
+
readonly code: JsonRpcErrorCode.ServiceUnavailable;
|
|
53
|
+
readonly when: "Overpass returned HTTP 429 — all 4 concurrent query slots are occupied.";
|
|
54
|
+
readonly retryable: true;
|
|
55
|
+
readonly recovery: "Wait a few seconds and retry. Reduce concurrent calls or switch to a private Overpass instance via OSM_OVERPASS_BASE_URL.";
|
|
56
|
+
}]>;
|
|
57
|
+
//# sourceMappingURL=openstreetmap-query-bbox.tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openstreetmap-query-bbox.tool.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/openstreetmap-query-bbox.tool.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAQ,CAAC,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAMjE,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8LjC,CAAC"}
|