@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.
Files changed (62) hide show
  1. package/CLAUDE.md +393 -0
  2. package/Dockerfile +99 -0
  3. package/LICENSE +201 -0
  4. package/README.md +283 -0
  5. package/dist/config/server-config.d.ts +14 -0
  6. package/dist/config/server-config.d.ts.map +1 -0
  7. package/dist/config/server-config.js +47 -0
  8. package/dist/config/server-config.js.map +1 -0
  9. package/dist/index.d.ts +7 -0
  10. package/dist/index.d.ts.map +1 -0
  11. package/dist/index.js +40 -0
  12. package/dist/index.js.map +1 -0
  13. package/dist/mcp-server/tools/definitions/openstreetmap-format.d.ts +18 -0
  14. package/dist/mcp-server/tools/definitions/openstreetmap-format.d.ts.map +1 -0
  15. package/dist/mcp-server/tools/definitions/openstreetmap-format.js +36 -0
  16. package/dist/mcp-server/tools/definitions/openstreetmap-format.js.map +1 -0
  17. package/dist/mcp-server/tools/definitions/openstreetmap-geocode.tool.d.ts +59 -0
  18. package/dist/mcp-server/tools/definitions/openstreetmap-geocode.tool.d.ts.map +1 -0
  19. package/dist/mcp-server/tools/definitions/openstreetmap-geocode.tool.js +203 -0
  20. package/dist/mcp-server/tools/definitions/openstreetmap-geocode.tool.js.map +1 -0
  21. package/dist/mcp-server/tools/definitions/openstreetmap-lookup.tool.d.ts +39 -0
  22. package/dist/mcp-server/tools/definitions/openstreetmap-lookup.tool.d.ts.map +1 -0
  23. package/dist/mcp-server/tools/definitions/openstreetmap-lookup.tool.js +136 -0
  24. package/dist/mcp-server/tools/definitions/openstreetmap-lookup.tool.js.map +1 -0
  25. package/dist/mcp-server/tools/definitions/openstreetmap-query-bbox.tool.d.ts +57 -0
  26. package/dist/mcp-server/tools/definitions/openstreetmap-query-bbox.tool.d.ts.map +1 -0
  27. package/dist/mcp-server/tools/definitions/openstreetmap-query-bbox.tool.js +170 -0
  28. package/dist/mcp-server/tools/definitions/openstreetmap-query-bbox.tool.js.map +1 -0
  29. package/dist/mcp-server/tools/definitions/openstreetmap-query-nearby.tool.d.ts +56 -0
  30. package/dist/mcp-server/tools/definitions/openstreetmap-query-nearby.tool.d.ts.map +1 -0
  31. package/dist/mcp-server/tools/definitions/openstreetmap-query-nearby.tool.js +174 -0
  32. package/dist/mcp-server/tools/definitions/openstreetmap-query-nearby.tool.js.map +1 -0
  33. package/dist/mcp-server/tools/definitions/openstreetmap-query-raw.tool.d.ts +38 -0
  34. package/dist/mcp-server/tools/definitions/openstreetmap-query-raw.tool.d.ts.map +1 -0
  35. package/dist/mcp-server/tools/definitions/openstreetmap-query-raw.tool.js +124 -0
  36. package/dist/mcp-server/tools/definitions/openstreetmap-query-raw.tool.js.map +1 -0
  37. package/dist/mcp-server/tools/definitions/openstreetmap-reverse.tool.d.ts +40 -0
  38. package/dist/mcp-server/tools/definitions/openstreetmap-reverse.tool.d.ts.map +1 -0
  39. package/dist/mcp-server/tools/definitions/openstreetmap-reverse.tool.js +129 -0
  40. package/dist/mcp-server/tools/definitions/openstreetmap-reverse.tool.js.map +1 -0
  41. package/dist/mcp-server/tools/definitions/openstreetmap-tag-input.d.ts +21 -0
  42. package/dist/mcp-server/tools/definitions/openstreetmap-tag-input.d.ts.map +1 -0
  43. package/dist/mcp-server/tools/definitions/openstreetmap-tag-input.js +22 -0
  44. package/dist/mcp-server/tools/definitions/openstreetmap-tag-input.js.map +1 -0
  45. package/dist/services/nominatim/nominatim-service.d.ts +24 -0
  46. package/dist/services/nominatim/nominatim-service.d.ts.map +1 -0
  47. package/dist/services/nominatim/nominatim-service.js +160 -0
  48. package/dist/services/nominatim/nominatim-service.js.map +1 -0
  49. package/dist/services/nominatim/types.d.ts +55 -0
  50. package/dist/services/nominatim/types.d.ts.map +1 -0
  51. package/dist/services/nominatim/types.js +6 -0
  52. package/dist/services/nominatim/types.js.map +1 -0
  53. package/dist/services/overpass/overpass-service.d.ts +25 -0
  54. package/dist/services/overpass/overpass-service.d.ts.map +1 -0
  55. package/dist/services/overpass/overpass-service.js +146 -0
  56. package/dist/services/overpass/overpass-service.js.map +1 -0
  57. package/dist/services/overpass/types.d.ts +59 -0
  58. package/dist/services/overpass/types.d.ts.map +1 -0
  59. package/dist/services/overpass/types.js +6 -0
  60. package/dist/services/overpass/types.js.map +1 -0
  61. package/package.json +91 -0
  62. package/server.json +153 -0
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2025 Casey Hand @cyanheads
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,283 @@
1
+ <div align="center">
2
+ <h1>@cyanheads/openstreetmap-mcp-server</h1>
3
+ <p><b>Geocode, reverse geocode, and run Overpass spatial queries on OpenStreetMap data via MCP. STDIO or Streamable HTTP.</b>
4
+ <div>6 Tools</div>
5
+ </p>
6
+ </div>
7
+
8
+ <div align="center">
9
+
10
+
11
+
12
+ [![Version](https://img.shields.io/badge/Version-0.2.0-blue.svg?style=flat-square)](./CHANGELOG.md) [![License](https://img.shields.io/badge/License-Apache%202.0-orange.svg?style=flat-square)](./LICENSE) [![Docker](https://img.shields.io/badge/Docker-ghcr.io-2496ED?style=flat-square&logo=docker&logoColor=white)](https://github.com/users/cyanheads/packages/container/package/openstreetmap-mcp-server) [![MCP SDK](https://img.shields.io/badge/MCP%20SDK-^1.29.0-green.svg?style=flat-square)](https://modelcontextprotocol.io/) [![npm](https://img.shields.io/npm/v/@cyanheads/openstreetmap-mcp-server?style=flat-square&logo=npm&logoColor=white)](https://www.npmjs.com/package/@cyanheads/openstreetmap-mcp-server) [![TypeScript](https://img.shields.io/badge/TypeScript-^6.0.3-3178C6.svg?style=flat-square)](https://www.typescriptlang.org/) [![Bun](https://img.shields.io/badge/Bun-v1.3.0-blueviolet.svg?style=flat-square)](https://bun.sh/)
13
+
14
+ </div>
15
+
16
+ <div align="center">
17
+
18
+ [![Install in Claude Desktop](https://img.shields.io/badge/Install_in-Claude_Desktop-D97757?style=for-the-badge&logo=anthropic&logoColor=white)](https://github.com/cyanheads/openstreetmap-mcp-server/releases/latest/download/openstreetmap-mcp-server.mcpb) [![Install in Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en/install-mcp?name=openstreetmap-mcp-server&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBjeWFuaGVhZHMvb3BlbnN0cmVldG1hcC1tY3Atc2VydmVyIl19) [![Install in VS Code](https://img.shields.io/badge/VS_Code-Install_Server-0098FF?style=for-the-badge&logo=visualstudiocode&logoColor=white)](https://vscode.dev/redirect?url=vscode:mcp/install?%7B%22name%22%3A%22openstreetmap-mcp-server%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40cyanheads%2Fopenstreetmap-mcp-server%22%5D%7D)
19
+
20
+ [![Framework](https://img.shields.io/badge/Built%20on-@cyanheads/mcp--ts--core-67E8F9?style=flat-square)](https://www.npmjs.com/package/@cyanheads/mcp-ts-core)
21
+
22
+ </div>
23
+
24
+ <div align="center">
25
+
26
+ **Public Hosted Server:** [https://openstreetmap.caseyjhand.com/mcp](https://openstreetmap.caseyjhand.com/mcp)
27
+
28
+ </div>
29
+
30
+ ---
31
+
32
+ ## Tools
33
+
34
+ 6 tools for geocoding and spatial queries against OpenStreetMap data:
35
+
36
+ | Tool | Description |
37
+ |:---|:---|
38
+ | `openstreetmap_geocode` | Convert a place name or address to geographic coordinates and structured place data |
39
+ | `openstreetmap_reverse` | Convert latitude/longitude coordinates to the nearest address or place name |
40
+ | `openstreetmap_lookup` | Fetch address details for one or more known OSM objects by their IDs |
41
+ | `openstreetmap_query_nearby` | Find OSM features within a radius around a geographic point |
42
+ | `openstreetmap_query_bbox` | Find OSM features within a rectangular bounding box |
43
+ | `openstreetmap_query_raw` | Execute a raw Overpass QL query for advanced spatial operations |
44
+
45
+ ### `openstreetmap_geocode`
46
+
47
+ Convert a place name or address to geographic coordinates via Nominatim/OpenStreetMap.
48
+
49
+ - Two input modes: free-form query string (e.g., `"Space Needle Seattle"`) or structured address fields (street, city, state, country, postal code) — mutually exclusive
50
+ - Country filtering via ISO 3166-1 alpha-2 codes (`countrycodes`)
51
+ - Data layer filtering: address, poi, railway, natural, manmade
52
+ - Feature type restriction: country, state, city, settlement
53
+ - Optional extra OSM tags (phone, website, opening_hours, wikidata)
54
+ - Preferred language override via BCP 47 code
55
+ - Returns results ordered by Nominatim importance score (global prominence)
56
+ - Results include coordinates, structured address, bounding box, OSM type/ID for chaining into `openstreetmap_lookup`
57
+
58
+ ---
59
+
60
+ ### `openstreetmap_reverse`
61
+
62
+ Convert latitude/longitude to the nearest address or named place.
63
+
64
+ - Zoom-level control for address detail: 18=building, 16=street, 14=neighbourhood, 12=town, 10=city, 8=county, 5=state, 3=country
65
+ - Layer filtering for matched OSM object type
66
+ - Optional extra OSM tags and language preference
67
+ - Returns structured address breakdown, OSM type/ID, and bounding box
68
+
69
+ ---
70
+
71
+ ### `openstreetmap_lookup`
72
+
73
+ Fetch full Nominatim address records for known OSM object IDs.
74
+
75
+ - Accepts single ID or array of up to 50 IDs
76
+ - IDs must be prefixed with N (node), W (way), or R (relation): e.g., `"N240109189"`, `"W50637691"`, `"R146656"`
77
+ - Efficient alternative to a full geocoding round-trip when OSM IDs are already known (e.g., from an Overpass result)
78
+ - Reports `not_found` list for IDs that returned no result
79
+ - Optional extra OSM tags and language preference
80
+
81
+ ---
82
+
83
+ ### `openstreetmap_query_nearby`
84
+
85
+ Find OSM features within a radius around a point via the Overpass API.
86
+
87
+ - Primary tool for "what's near X?" spatial queries
88
+ - Supports `amenity` shortcut for common POI types (hospital, pharmacy, restaurant, cafe, school, atm) or `tag_key` + `tag_value` for any OSM category (leisure=park, shop=supermarket, natural=peak)
89
+ - Configurable radius up to 50km; keep under 5km for dense urban POI queries
90
+ - Element type filtering: node (standalone POIs), way (buildings/areas), relation (complex structures)
91
+ - Limit up to 500 results; `truncated` flag signals when more exist
92
+ - Returns OSM type/ID, coordinates, name, and full tag set for each feature
93
+
94
+ ---
95
+
96
+ ### `openstreetmap_query_bbox`
97
+
98
+ Find OSM features within a rectangular geographic bounding box.
99
+
100
+ - Useful for area surveys where proximity to a single point isn't the goal
101
+ - Same `amenity` / `tag_key` + `tag_value` interface as `openstreetmap_query_nearby`
102
+ - Configurable timeout for large bounding boxes or dense areas
103
+ - Limit up to 500 results with `truncated` flag
104
+
105
+ ---
106
+
107
+ ### `openstreetmap_query_raw`
108
+
109
+ Execute arbitrary Overpass QL for queries the convenience tools don't cover.
110
+
111
+ - Full Overpass QL expressiveness: multi-type queries, union queries, relation membership, historical queries
112
+ - Query must include `[out:json]`; server injects `[timeout:N]` if absent
113
+ - Returns raw element array — structure varies by query type (nodes have lat/lon, ways have nodes[], relations have members[])
114
+ - Validate complex queries at [overpass-turbo.eu](https://overpass-turbo.eu) before use
115
+
116
+ ## Features
117
+
118
+ Built on [`@cyanheads/mcp-ts-core`](https://github.com/cyanheads/mcp-ts-core):
119
+
120
+ - Declarative tool definitions — single file per tool, framework handles registration and validation
121
+ - Unified error handling across all tools
122
+ - Pluggable auth (`none`, `jwt`, `oauth`)
123
+ - Swappable storage backends: `in-memory`, `filesystem`, `Supabase`, `Cloudflare KV/R2/D1`
124
+ - Structured logging with optional OpenTelemetry tracing
125
+ - Runs locally (stdio/HTTP) or on Cloudflare Workers from the same codebase
126
+
127
+ Nominatim/Overpass-specific:
128
+
129
+ - Nominatim usage policy compliance: configurable `User-Agent` via `OSM_USER_AGENT`, rate-limit-aware request handling
130
+ - OSM attribution on every response (`Data © OpenStreetMap contributors, ODbL 1.0`)
131
+ - Private instance support — override `OSM_NOMINATIM_BASE_URL` and `OSM_OVERPASS_BASE_URL` for self-hosted or mirror endpoints
132
+ - Structured error contracts: `no_results`, `no_coverage`, `invalid_id_format`, `invalid_tag`, `query_timeout`, `rate_limited`, `query_error`, `result_too_large` — all with actionable recovery hints
133
+
134
+ Agent-friendly output:
135
+
136
+ - Attribution on every response — agents can surface the ODbL license notice as required
137
+ - Structured output contracts — coordinates, OSM IDs, address fields, and tag maps in consistent shapes
138
+ - Cross-tool chaining: Overpass results carry `osm_type` + `osm_id` that feed directly into `openstreetmap_lookup` for full address records
139
+
140
+ ## Getting started
141
+
142
+ ### Self-Hosted / Local
143
+
144
+ Add the following to your MCP client configuration file.
145
+
146
+ ```json
147
+ {
148
+ "mcpServers": {
149
+ "openstreetmap": {
150
+ "type": "stdio",
151
+ "command": "bunx",
152
+ "args": ["@cyanheads/openstreetmap-mcp-server@latest"],
153
+ "env": {
154
+ "MCP_TRANSPORT_TYPE": "stdio",
155
+ "MCP_LOG_LEVEL": "info"
156
+ }
157
+ }
158
+ }
159
+ }
160
+ ```
161
+
162
+ Or with npx (no Bun required):
163
+
164
+ ```json
165
+ {
166
+ "mcpServers": {
167
+ "openstreetmap": {
168
+ "type": "stdio",
169
+ "command": "npx",
170
+ "args": ["-y", "@cyanheads/openstreetmap-mcp-server@latest"],
171
+ "env": {
172
+ "MCP_TRANSPORT_TYPE": "stdio",
173
+ "MCP_LOG_LEVEL": "info"
174
+ }
175
+ }
176
+ }
177
+ }
178
+ ```
179
+
180
+ For Streamable HTTP, set the transport and start the server:
181
+
182
+ ```sh
183
+ MCP_TRANSPORT_TYPE=http MCP_HTTP_PORT=3010 bun run start:http
184
+ # Server listens at http://localhost:3010/mcp
185
+ ```
186
+
187
+ ### Prerequisites
188
+
189
+ - [Bun v1.3.0](https://bun.sh/) or higher (or Node.js ≥24.0.0).
190
+ - No API key required — Nominatim and Overpass are public APIs. For heavy use, consider pointing `OSM_NOMINATIM_BASE_URL` and `OSM_OVERPASS_BASE_URL` at self-hosted or mirror instances.
191
+
192
+ ### Installation
193
+
194
+ 1. **Clone the repository:**
195
+
196
+ ```sh
197
+ git clone https://github.com/cyanheads/openstreetmap-mcp-server.git
198
+ ```
199
+
200
+ 2. **Navigate into the directory:**
201
+
202
+ ```sh
203
+ cd openstreetmap-mcp-server
204
+ ```
205
+
206
+ 3. **Install dependencies:**
207
+
208
+ ```sh
209
+ bun install
210
+ ```
211
+
212
+ ## Configuration
213
+
214
+ All configuration is validated at startup via Zod schemas in `src/config/server-config.ts`. Key environment variables:
215
+
216
+ | Variable | Description | Default |
217
+ |:---|:---|:---|
218
+ | `MCP_TRANSPORT_TYPE` | Transport: `stdio` or `http` | `stdio` |
219
+ | `MCP_HTTP_PORT` | HTTP server port | `3010` |
220
+ | `MCP_HTTP_ENDPOINT_PATH` | HTTP endpoint path where the MCP server is mounted | `/mcp` |
221
+ | `MCP_PUBLIC_URL` | Public origin override for TLS-terminating reverse-proxy deployments | none |
222
+ | `MCP_AUTH_MODE` | Authentication: `none`, `jwt`, or `oauth` | `none` |
223
+ | `MCP_LOG_LEVEL` | Log level (`debug`, `info`, `warning`, `error`, etc.) | `info` |
224
+ | `MCP_GC_PRESSURE_INTERVAL_MS` | Opt-in Bun-only forced-GC pressure loop (ms). Recommended starting point if heap growth is observed: `60000`. | `0` (disabled) |
225
+ | `STORAGE_PROVIDER_TYPE` | Storage backend: `in-memory`, `filesystem`, `supabase`, `cloudflare-kv/r2/d1` | `in-memory` |
226
+ | `OSM_NOMINATIM_BASE_URL` | Nominatim API base URL. Override for a private or mirror instance. | `https://nominatim.openstreetmap.org` |
227
+ | `OSM_OVERPASS_BASE_URL` | Overpass API endpoint URL. Override for a mirror or private instance. | `https://overpass-api.de/api/interpreter` |
228
+ | `OSM_USER_AGENT` | User-Agent sent to Nominatim and Overpass. Required by usage policy. | `openstreetmap-mcp-server/0.1.8` |
229
+ | `OTEL_ENABLED` | Enable OpenTelemetry | `false` |
230
+
231
+ ## Running the server
232
+
233
+ ### Local development
234
+
235
+ - **Build and run the production version**:
236
+
237
+ ```sh
238
+ # One-time build
239
+ bun run rebuild
240
+
241
+ # Run the built server
242
+ bun run start:http
243
+ # or
244
+ bun run start:stdio
245
+ ```
246
+
247
+ - **Run checks and tests**:
248
+ ```sh
249
+ bun run devcheck # Lints, formats, type-checks, and more
250
+ bun run test # Runs the test suite
251
+ ```
252
+
253
+ ## Project structure
254
+
255
+ | Directory | Purpose |
256
+ |:---|:---|
257
+ | `src/mcp-server/tools` | Tool definitions (`*.tool.ts`). Six tools across Nominatim and Overpass. |
258
+ | `src/services/nominatim` | Nominatim service layer — API client, search, reverse, lookup. |
259
+ | `src/services/overpass` | Overpass service layer — query builder, executor, element normalizer. |
260
+ | `src/config` | Server-specific environment variable parsing and validation with Zod. |
261
+
262
+ ## Development guide
263
+
264
+ See [`CLAUDE.md`](./CLAUDE.md) for development guidelines and architectural rules. The short version:
265
+
266
+ - Handlers throw, framework catches — no `try/catch` in tool logic
267
+ - Use `ctx.log` for logging, `ctx.state` for storage
268
+ - Register new tools and resources in the `createApp()` arrays
269
+
270
+ ## Contributing
271
+
272
+ Issues and pull requests are welcome. Run checks and tests before submitting:
273
+
274
+ ```sh
275
+ bun run devcheck
276
+ bun run test
277
+ ```
278
+
279
+ ## License
280
+
281
+ This project is licensed under the Apache 2.0 License. See the [LICENSE](./LICENSE) file for details.
282
+
283
+ Map data from [OpenStreetMap](https://www.openstreetmap.org/copyright) contributors, available under the [Open Database License (ODbL)](https://opendatacommons.org/licenses/odbl/).
@@ -0,0 +1,14 @@
1
+ /**
2
+ * @fileoverview Server-specific environment variable configuration.
3
+ * @module config/server-config
4
+ */
5
+ import { z } from '@cyanheads/mcp-ts-core';
6
+ declare const ServerConfigSchema: z.ZodObject<{
7
+ nominatimBaseUrl: z.ZodDefault<z.ZodString>;
8
+ overpassBaseUrl: z.ZodDefault<z.ZodString>;
9
+ nominatimUserAgent: z.ZodDefault<z.ZodString>;
10
+ }, z.core.$strip>;
11
+ export type ServerConfig = z.infer<typeof ServerConfigSchema>;
12
+ export declare function getServerConfig(): ServerConfig;
13
+ export {};
14
+ //# sourceMappingURL=server-config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server-config.d.ts","sourceRoot":"","sources":["../../src/config/server-config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAAE,CAAC,EAAE,MAAM,wBAAwB,CAAC;AAgB3C,QAAA,MAAM,kBAAkB;;;;iBAetB,CAAC;AAEH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAI9D,wBAAgB,eAAe,IAAI,YAAY,CAO9C"}
@@ -0,0 +1,47 @@
1
+ /**
2
+ * @fileoverview Server-specific environment variable configuration.
3
+ * @module config/server-config
4
+ */
5
+ import { readFileSync } from 'node:fs';
6
+ import { dirname, resolve } from 'node:path';
7
+ import { fileURLToPath } from 'node:url';
8
+ import { z } from '@cyanheads/mcp-ts-core';
9
+ import { parseEnvConfig } from '@cyanheads/mcp-ts-core/config';
10
+ /** Read version from package.json at startup so the User-Agent stays in sync. */
11
+ function readPackageVersion() {
12
+ try {
13
+ const pkgPath = resolve(dirname(fileURLToPath(import.meta.url)), '../../package.json');
14
+ const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8'));
15
+ return pkg.version ?? '0.0.0';
16
+ }
17
+ catch {
18
+ return '0.0.0';
19
+ }
20
+ }
21
+ const defaultUserAgent = `openstreetmap-mcp-server/${readPackageVersion()}`;
22
+ const ServerConfigSchema = z.object({
23
+ nominatimBaseUrl: z
24
+ .string()
25
+ .url()
26
+ .default('https://nominatim.openstreetmap.org')
27
+ .describe('Nominatim API base URL. Override to use a private or mirror instance.'),
28
+ overpassBaseUrl: z
29
+ .string()
30
+ .url()
31
+ .default('https://overpass-api.de/api/interpreter')
32
+ .describe('Overpass API endpoint URL. Override to use a mirror or private instance.'),
33
+ nominatimUserAgent: z
34
+ .string()
35
+ .default(defaultUserAgent)
36
+ .describe('User-Agent sent to Nominatim and Overpass. Required by usage policy.'),
37
+ });
38
+ let _config;
39
+ export function getServerConfig() {
40
+ _config ??= parseEnvConfig(ServerConfigSchema, {
41
+ nominatimBaseUrl: 'OSM_NOMINATIM_BASE_URL',
42
+ overpassBaseUrl: 'OSM_OVERPASS_BASE_URL',
43
+ nominatimUserAgent: 'OSM_USER_AGENT',
44
+ });
45
+ return _config;
46
+ }
47
+ //# sourceMappingURL=server-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server-config.js","sourceRoot":"","sources":["../../src/config/server-config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,CAAC,EAAE,MAAM,wBAAwB,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAE/D,iFAAiF;AACjF,SAAS,kBAAkB;IACzB,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,oBAAoB,CAAC,CAAC;QACvF,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,CAAyB,CAAC;QAC/E,OAAO,GAAG,CAAC,OAAO,IAAI,OAAO,CAAC;IAChC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,OAAO,CAAC;IACjB,CAAC;AACH,CAAC;AAED,MAAM,gBAAgB,GAAG,4BAA4B,kBAAkB,EAAE,EAAE,CAAC;AAE5E,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC;IAClC,gBAAgB,EAAE,CAAC;SAChB,MAAM,EAAE;SACR,GAAG,EAAE;SACL,OAAO,CAAC,qCAAqC,CAAC;SAC9C,QAAQ,CAAC,uEAAuE,CAAC;IACpF,eAAe,EAAE,CAAC;SACf,MAAM,EAAE;SACR,GAAG,EAAE;SACL,OAAO,CAAC,yCAAyC,CAAC;SAClD,QAAQ,CAAC,0EAA0E,CAAC;IACvF,kBAAkB,EAAE,CAAC;SAClB,MAAM,EAAE;SACR,OAAO,CAAC,gBAAgB,CAAC;SACzB,QAAQ,CAAC,sEAAsE,CAAC;CACpF,CAAC,CAAC;AAIH,IAAI,OAAiC,CAAC;AAEtC,MAAM,UAAU,eAAe;IAC7B,OAAO,KAAK,cAAc,CAAC,kBAAkB,EAAE;QAC7C,gBAAgB,EAAE,wBAAwB;QAC1C,eAAe,EAAE,uBAAuB;QACxC,kBAAkB,EAAE,gBAAgB;KACrC,CAAC,CAAC;IACH,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * @fileoverview openstreetmap-mcp-server MCP server entry point.
4
+ * @module index
5
+ */
6
+ export {};
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;GAGG"}
package/dist/index.js ADDED
@@ -0,0 +1,40 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * @fileoverview openstreetmap-mcp-server MCP server entry point.
4
+ * @module index
5
+ */
6
+ import { createApp } from '@cyanheads/mcp-ts-core';
7
+ import { openstreetmapGeocode } from './mcp-server/tools/definitions/openstreetmap-geocode.tool.js';
8
+ import { openstreetmapLookup } from './mcp-server/tools/definitions/openstreetmap-lookup.tool.js';
9
+ import { openstreetmapQueryBbox } from './mcp-server/tools/definitions/openstreetmap-query-bbox.tool.js';
10
+ import { openstreetmapQueryNearby } from './mcp-server/tools/definitions/openstreetmap-query-nearby.tool.js';
11
+ import { openstreetmapQueryRaw } from './mcp-server/tools/definitions/openstreetmap-query-raw.tool.js';
12
+ import { openstreetmapReverse } from './mcp-server/tools/definitions/openstreetmap-reverse.tool.js';
13
+ import { initNominatimService } from './services/nominatim/nominatim-service.js';
14
+ import { initOverpassService } from './services/overpass/overpass-service.js';
15
+ await createApp({
16
+ tools: [
17
+ openstreetmapGeocode,
18
+ openstreetmapReverse,
19
+ openstreetmapLookup,
20
+ openstreetmapQueryNearby,
21
+ openstreetmapQueryBbox,
22
+ openstreetmapQueryRaw,
23
+ ],
24
+ resources: [],
25
+ prompts: [],
26
+ instructions: 'OpenStreetMap geocoding and spatial query server. ' +
27
+ 'Use openstreetmap_geocode to resolve place names or addresses to coordinates. ' +
28
+ 'Use openstreetmap_reverse to convert coordinates to an address. ' +
29
+ 'Use openstreetmap_lookup to fetch details for known OSM IDs. ' +
30
+ 'Use openstreetmap_query_nearby for "what\'s near X?" queries. ' +
31
+ 'Use openstreetmap_query_bbox for area surveys. ' +
32
+ 'Use openstreetmap_query_raw for advanced Overpass QL. ' +
33
+ 'All data © OpenStreetMap contributors, ODbL 1.0. ' +
34
+ 'Override endpoints via OSM_NOMINATIM_BASE_URL or OSM_OVERPASS_BASE_URL for private instances.',
35
+ setup(core) {
36
+ initNominatimService(core.config, core.storage);
37
+ initOverpassService(core.config, core.storage);
38
+ },
39
+ });
40
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,8DAA8D,CAAC;AACpG,OAAO,EAAE,mBAAmB,EAAE,MAAM,6DAA6D,CAAC;AAClG,OAAO,EAAE,sBAAsB,EAAE,MAAM,iEAAiE,CAAC;AACzG,OAAO,EAAE,wBAAwB,EAAE,MAAM,mEAAmE,CAAC;AAC7G,OAAO,EAAE,qBAAqB,EAAE,MAAM,gEAAgE,CAAC;AACvG,OAAO,EAAE,oBAAoB,EAAE,MAAM,8DAA8D,CAAC;AACpG,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,mBAAmB,EAAE,MAAM,yCAAyC,CAAC;AAE9E,MAAM,SAAS,CAAC;IACd,KAAK,EAAE;QACL,oBAAoB;QACpB,oBAAoB;QACpB,mBAAmB;QACnB,wBAAwB;QACxB,sBAAsB;QACtB,qBAAqB;KACtB;IACD,SAAS,EAAE,EAAE;IACb,OAAO,EAAE,EAAE;IACX,YAAY,EACV,oDAAoD;QACpD,gFAAgF;QAChF,kEAAkE;QAClE,+DAA+D;QAC/D,gEAAgE;QAChE,iDAAiD;QACjD,wDAAwD;QACxD,mDAAmD;QACnD,+FAA+F;IACjG,KAAK,CAAC,IAAI;QACR,oBAAoB,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QAChD,mBAAmB,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;IACjD,CAAC;CACF,CAAC,CAAC"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * @fileoverview Shared formatting helpers for Nominatim place result rendering.
3
+ * @module mcp-server/tools/definitions/openstreetmap-format
4
+ */
5
+ /**
6
+ * Append formatted lines for the common fields shared across all three Nominatim
7
+ * tool format() functions: OSM ref, category, address breakdown, bounding box, extratags.
8
+ */
9
+ export declare function appendPlaceLines(lines: string[], r: {
10
+ osm_type?: 'node' | 'way' | 'relation' | undefined;
11
+ osm_id?: number | undefined;
12
+ category?: string | undefined;
13
+ type?: string | undefined;
14
+ address?: Record<string, string> | undefined;
15
+ boundingbox?: [string, string, string, string] | undefined;
16
+ extratags?: Record<string, string> | undefined;
17
+ }): void;
18
+ //# sourceMappingURL=openstreetmap-format.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openstreetmap-format.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/openstreetmap-format.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,MAAM,EAAE,EACf,CAAC,EAAE;IACD,QAAQ,CAAC,EAAE,MAAM,GAAG,KAAK,GAAG,UAAU,GAAG,SAAS,CAAC;IACnD,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAAC;IAC7C,WAAW,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAAC;IAC3D,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAAC;CAChD,GACA,IAAI,CAyBN"}