atlasfetch-mcp 0.1.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/LICENSE +21 -0
- package/README.md +90 -0
- package/dist/api.d.ts +79 -0
- package/dist/api.js +116 -0
- package/dist/api.js.map +1 -0
- package/dist/server.d.ts +2 -0
- package/dist/server.js +209 -0
- package/dist/server.js.map +1 -0
- package/dist/stdio.d.ts +2 -0
- package/dist/stdio.js +21 -0
- package/dist/stdio.js.map +1 -0
- package/package.json +53 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 ATLASIQ PTY LTD
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# atlasfetch-mcp
|
|
2
|
+
|
|
3
|
+
An [MCP](https://modelcontextprotocol.io) server for [AtlasFetch](https://atlasfetch.xyz) — **reverse geocoding to administrative boundaries, and geofencing**, as tools your AI assistant can call directly.
|
|
4
|
+
|
|
5
|
+
Ask "which municipality is -33.9249, 18.4241 in?" and get **Cape Town, Western Cape, South Africa** with ISO 3166 codes — from a real point-in-polygon lookup, not the model's memory.
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
country: United Kingdom (GB) · region: England (GB-ENG) · municipal: City of Westminster (GB-WSM)
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## What it does
|
|
12
|
+
|
|
13
|
+
| Tool | What it does |
|
|
14
|
+
| --- | --- |
|
|
15
|
+
| `lookup_location` | A coordinate becomes the country, region and municipality containing it, with ISO 3166-1 / 3166-2 codes, plus matches from your own boundary sets. Optionally returns the point as an H3 cell or Google Plus Code. |
|
|
16
|
+
| `list_boundary_sets` | Lists your boundary sets, their counts, and which API keys may query them. |
|
|
17
|
+
| `create_boundary_set` | Creates an empty set for your own polygons. |
|
|
18
|
+
| `add_boundary` | Adds one GeoJSON polygon, with properties returned on every match. |
|
|
19
|
+
|
|
20
|
+
**Good for:** reverse geocoding to administrative areas, geofencing against your own delivery zones or service areas, jurisdiction and region checks, tagging location data with region codes.
|
|
21
|
+
|
|
22
|
+
**Not for:** street addresses or postcodes (this is not forward geocoding — results stop at the municipality), routing, distances, map tiles, or downloading boundary geometry.
|
|
23
|
+
|
|
24
|
+
## Install
|
|
25
|
+
|
|
26
|
+
No signup needed to try it: without a key it falls back to a shared public demo key.
|
|
27
|
+
|
|
28
|
+
### Claude Code
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
claude mcp add atlasfetch -- npx -y atlasfetch-mcp
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Claude Desktop, Cursor, VS Code and other clients
|
|
35
|
+
|
|
36
|
+
Add to your MCP config (`claude_desktop_config.json`, `.cursor/mcp.json`, or your client's equivalent):
|
|
37
|
+
|
|
38
|
+
```json
|
|
39
|
+
{
|
|
40
|
+
"mcpServers": {
|
|
41
|
+
"atlasfetch": {
|
|
42
|
+
"command": "npx",
|
|
43
|
+
"args": ["-y", "atlasfetch-mcp"],
|
|
44
|
+
"env": {
|
|
45
|
+
"ATLASFETCH_API_KEY": "your-key-here"
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Requires Node 20 or newer.
|
|
53
|
+
|
|
54
|
+
## Getting a key
|
|
55
|
+
|
|
56
|
+
The demo key is shared by **every** anonymous user on the internet — one pooled quota and rate limit. Fine for a first look, wrong for anything real.
|
|
57
|
+
|
|
58
|
+
Create your own at [atlasfetch.xyz/dashboard](https://atlasfetch.xyz/dashboard) and set `ATLASFETCH_API_KEY`. The free Personal plan needs no card.
|
|
59
|
+
|
|
60
|
+
| Variable | Default | Purpose |
|
|
61
|
+
| --- | --- | --- |
|
|
62
|
+
| `ATLASFETCH_API_KEY` | *(demo key)* | Your API key. |
|
|
63
|
+
| `ATLASFETCH_API_URL` | `https://api.atlasfetch.xyz` | Override only for local or staging APIs. |
|
|
64
|
+
|
|
65
|
+
## Two things that surprise people
|
|
66
|
+
|
|
67
|
+
**`municipal` is the finest unit available, not a consistent kind of thing.** Los Angeles returns a city; rural Kansas returns a county; some places return a district. Where a country's fine tier is patchy, a coarser complete tier answers instead, because a county beats `null` for most uses. Don't assume the value names a city.
|
|
68
|
+
|
|
69
|
+
**A new boundary set cannot be made queryable from here.** Sets are created switched off and granted to no key, and granting is addressed by API key *id* — which only a signed-in browser session can list. So this server can create a set and fill it, but the last step happens in the [dashboard](https://atlasfetch.xyz/dashboard). `create_boundary_set` says so in its response rather than leaving you with a set that silently matches nothing.
|
|
70
|
+
|
|
71
|
+
## Billing
|
|
72
|
+
|
|
73
|
+
One call is one lookup, however many layers, sets or grid codes it touches. Metering happens before matching, so a lookup that matches nothing still counts. Requests rejected as invalid or rate-limited are not billed.
|
|
74
|
+
|
|
75
|
+
## Development
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
npm install
|
|
79
|
+
npm run build
|
|
80
|
+
node scripts/smoke.mjs # drives the built server with a real MCP client, against the live API
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Links
|
|
84
|
+
|
|
85
|
+
- [Documentation](https://atlasfetch.xyz/docs) · [OpenAPI spec](https://api.atlasfetch.xyz/openapi.json) · [llms.txt](https://atlasfetch.xyz/llms.txt)
|
|
86
|
+
- [Playground](https://atlasfetch.xyz/playground) — try a lookup with no signup
|
|
87
|
+
|
|
88
|
+
## Licence
|
|
89
|
+
|
|
90
|
+
MIT for this server. Reference boundaries derive from OpenStreetMap under the [ODbL](https://atlasfetch.xyz/attribution); attribution and share-alike obligations pass through to you. Coordinates you look up are not stored.
|
package/dist/api.d.ts
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Thin client for the AtlasFetch HTTP API.
|
|
3
|
+
*
|
|
4
|
+
* Holds no data and makes no decisions about geometry — it forwards requests and
|
|
5
|
+
* turns failures into sentences an assistant can act on. A raw "402" tells a
|
|
6
|
+
* model nothing; "monthly allowance exhausted, resets at the start of the next
|
|
7
|
+
* period" tells it to stop retrying and say so.
|
|
8
|
+
*/
|
|
9
|
+
export declare function baseUrl(): string;
|
|
10
|
+
/** A failure the caller should be told about verbatim, not retried blindly. */
|
|
11
|
+
export declare class ApiError extends Error {
|
|
12
|
+
readonly status: number;
|
|
13
|
+
/** Whether retrying the identical request could plausibly succeed later. */
|
|
14
|
+
readonly retryable: boolean;
|
|
15
|
+
constructor(message: string, status: number,
|
|
16
|
+
/** Whether retrying the identical request could plausibly succeed later. */
|
|
17
|
+
retryable?: boolean);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The key every request uses.
|
|
21
|
+
*
|
|
22
|
+
* `ATLASFETCH_API_KEY` if set; otherwise the shared public demo key, fetched
|
|
23
|
+
* once. The demo key belongs to ONE communal account whose quota, rate limit
|
|
24
|
+
* and single boundary set are pooled across every anonymous user on the
|
|
25
|
+
* internet — fine for a first look, wrong for anything real. `usingDemoKey`
|
|
26
|
+
* exists so every tool result can say so rather than letting someone build on
|
|
27
|
+
* it unawares.
|
|
28
|
+
*/
|
|
29
|
+
export declare function resolveKey(): Promise<string>;
|
|
30
|
+
export declare function usingDemoKey(): boolean;
|
|
31
|
+
/** One line appended to every result while the shared key is in use. */
|
|
32
|
+
export declare const DEMO_KEY_NOTICE: string;
|
|
33
|
+
/**
|
|
34
|
+
* Perform a request against the API, mapping each documented failure to an
|
|
35
|
+
* explanation. Status codes come from https://api.atlasfetch.xyz/openapi.json
|
|
36
|
+
*/
|
|
37
|
+
export declare function request<T>(path: string, init?: {
|
|
38
|
+
method?: string;
|
|
39
|
+
body?: unknown;
|
|
40
|
+
query?: Record<string, string | undefined>;
|
|
41
|
+
}): Promise<T>;
|
|
42
|
+
export interface LayerHit {
|
|
43
|
+
code: string | null;
|
|
44
|
+
name: string;
|
|
45
|
+
}
|
|
46
|
+
export interface LookupResponse {
|
|
47
|
+
base: Record<string, LayerHit | null>;
|
|
48
|
+
sets: Record<string, Array<{
|
|
49
|
+
name: string;
|
|
50
|
+
properties?: unknown;
|
|
51
|
+
}>>;
|
|
52
|
+
encoded?: {
|
|
53
|
+
h3?: string;
|
|
54
|
+
pluscode?: string;
|
|
55
|
+
};
|
|
56
|
+
/** Always present, empty or not. Per-set problems appear here WITH a 200. */
|
|
57
|
+
errors: Array<{
|
|
58
|
+
type: 'access' | 'usage';
|
|
59
|
+
message: string;
|
|
60
|
+
}>;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Shape confirmed against the live API on 2026-09-16, not guessed from the
|
|
64
|
+
* OpenAPI spec — the spec lists a subset of these fields, and an OpenAPI object
|
|
65
|
+
* is open by default, so it is incomplete rather than wrong.
|
|
66
|
+
*/
|
|
67
|
+
export interface BoundarySet {
|
|
68
|
+
id?: string;
|
|
69
|
+
name: string;
|
|
70
|
+
available?: boolean;
|
|
71
|
+
boundaryCount?: number;
|
|
72
|
+
/** Keys allowed to query this set — id AND label, not bare ids. */
|
|
73
|
+
grantedKeys?: Array<{
|
|
74
|
+
id: string;
|
|
75
|
+
label: string;
|
|
76
|
+
}>;
|
|
77
|
+
createdAt?: string;
|
|
78
|
+
updatedAt?: string;
|
|
79
|
+
}
|
package/dist/api.js
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Thin client for the AtlasFetch HTTP API.
|
|
3
|
+
*
|
|
4
|
+
* Holds no data and makes no decisions about geometry — it forwards requests and
|
|
5
|
+
* turns failures into sentences an assistant can act on. A raw "402" tells a
|
|
6
|
+
* model nothing; "monthly allowance exhausted, resets at the start of the next
|
|
7
|
+
* period" tells it to stop retrying and say so.
|
|
8
|
+
*/
|
|
9
|
+
const DEFAULT_BASE_URL = 'https://api.atlasfetch.xyz';
|
|
10
|
+
export function baseUrl() {
|
|
11
|
+
return (process.env.ATLASFETCH_API_URL ?? DEFAULT_BASE_URL).replace(/\/+$/, '');
|
|
12
|
+
}
|
|
13
|
+
/** A failure the caller should be told about verbatim, not retried blindly. */
|
|
14
|
+
export class ApiError extends Error {
|
|
15
|
+
status;
|
|
16
|
+
retryable;
|
|
17
|
+
constructor(message, status,
|
|
18
|
+
/** Whether retrying the identical request could plausibly succeed later. */
|
|
19
|
+
retryable = false) {
|
|
20
|
+
super(message);
|
|
21
|
+
this.status = status;
|
|
22
|
+
this.retryable = retryable;
|
|
23
|
+
this.name = 'ApiError';
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
let cachedDemoKey = null;
|
|
27
|
+
/**
|
|
28
|
+
* The key every request uses.
|
|
29
|
+
*
|
|
30
|
+
* `ATLASFETCH_API_KEY` if set; otherwise the shared public demo key, fetched
|
|
31
|
+
* once. The demo key belongs to ONE communal account whose quota, rate limit
|
|
32
|
+
* and single boundary set are pooled across every anonymous user on the
|
|
33
|
+
* internet — fine for a first look, wrong for anything real. `usingDemoKey`
|
|
34
|
+
* exists so every tool result can say so rather than letting someone build on
|
|
35
|
+
* it unawares.
|
|
36
|
+
*/
|
|
37
|
+
export async function resolveKey() {
|
|
38
|
+
const configured = process.env.ATLASFETCH_API_KEY?.trim();
|
|
39
|
+
if (configured)
|
|
40
|
+
return configured;
|
|
41
|
+
if (cachedDemoKey)
|
|
42
|
+
return cachedDemoKey;
|
|
43
|
+
const response = await fetch(`${baseUrl()}/demo/key`);
|
|
44
|
+
if (!response.ok) {
|
|
45
|
+
throw new ApiError('No ATLASFETCH_API_KEY is configured and the public demo key could not be fetched. ' +
|
|
46
|
+
'Create a key at https://atlasfetch.xyz/dashboard and set ATLASFETCH_API_KEY.', response.status);
|
|
47
|
+
}
|
|
48
|
+
const body = (await response.json());
|
|
49
|
+
if (!body.key) {
|
|
50
|
+
throw new ApiError('The demo key endpoint returned no key.', 502);
|
|
51
|
+
}
|
|
52
|
+
cachedDemoKey = body.key;
|
|
53
|
+
return cachedDemoKey;
|
|
54
|
+
}
|
|
55
|
+
export function usingDemoKey() {
|
|
56
|
+
return !process.env.ATLASFETCH_API_KEY?.trim();
|
|
57
|
+
}
|
|
58
|
+
/** One line appended to every result while the shared key is in use. */
|
|
59
|
+
export const DEMO_KEY_NOTICE = 'Note: using the shared public demo key. Its quota and rate limit are pooled across ' +
|
|
60
|
+
'every anonymous user, so it is unsuitable for production. Create your own at ' +
|
|
61
|
+
'https://atlasfetch.xyz/dashboard and set ATLASFETCH_API_KEY.';
|
|
62
|
+
async function readError(response) {
|
|
63
|
+
try {
|
|
64
|
+
const body = (await response.json());
|
|
65
|
+
return body.error ?? response.statusText;
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
return response.statusText;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Perform a request against the API, mapping each documented failure to an
|
|
73
|
+
* explanation. Status codes come from https://api.atlasfetch.xyz/openapi.json
|
|
74
|
+
*/
|
|
75
|
+
export async function request(path, init = {}) {
|
|
76
|
+
const key = await resolveKey();
|
|
77
|
+
const url = new URL(`${baseUrl()}${path}`);
|
|
78
|
+
for (const [name, value] of Object.entries(init.query ?? {})) {
|
|
79
|
+
if (value !== undefined)
|
|
80
|
+
url.searchParams.set(name, value);
|
|
81
|
+
}
|
|
82
|
+
const response = await fetch(url, {
|
|
83
|
+
method: init.method ?? 'GET',
|
|
84
|
+
headers: {
|
|
85
|
+
Authorization: `Bearer ${key}`,
|
|
86
|
+
...(init.body === undefined ? {} : { 'Content-Type': 'application/json' }),
|
|
87
|
+
},
|
|
88
|
+
body: init.body === undefined ? undefined : JSON.stringify(init.body),
|
|
89
|
+
});
|
|
90
|
+
if (response.ok)
|
|
91
|
+
return (await response.json());
|
|
92
|
+
const detail = await readError(response);
|
|
93
|
+
switch (response.status) {
|
|
94
|
+
case 400:
|
|
95
|
+
throw new ApiError(`The request was rejected: ${detail}`, 400);
|
|
96
|
+
case 401:
|
|
97
|
+
throw new ApiError(`The API key was rejected (${detail}). Check ATLASFETCH_API_KEY, or create a new key at ` +
|
|
98
|
+
'https://atlasfetch.xyz/dashboard — keys are shown once and stored hashed.', 401);
|
|
99
|
+
case 402:
|
|
100
|
+
throw new ApiError(`The monthly lookup allowance is exhausted (${detail}). It resets at the start of the next ` +
|
|
101
|
+
'billing period; retrying before then will fail the same way.', 402);
|
|
102
|
+
case 403:
|
|
103
|
+
throw new ApiError(`The current plan does not allow this, or a cap was exceeded: ${detail}`, 403);
|
|
104
|
+
case 404:
|
|
105
|
+
throw new ApiError(detail || 'Not found.', 404);
|
|
106
|
+
case 409:
|
|
107
|
+
throw new ApiError(detail || 'Conflict — something of that name already exists.', 409);
|
|
108
|
+
case 429: {
|
|
109
|
+
const retryAfter = response.headers.get('retry-after');
|
|
110
|
+
throw new ApiError(`Rate limited${retryAfter ? `; retry after ${retryAfter}s` : ''}. The limit is per key, per second.`, 429, true);
|
|
111
|
+
}
|
|
112
|
+
default:
|
|
113
|
+
throw new ApiError(`AtlasFetch returned ${response.status}: ${detail}`, response.status, response.status >= 500);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
//# sourceMappingURL=api.js.map
|
package/dist/api.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,gBAAgB,GAAG,4BAA4B,CAAA;AAErD,MAAM,UAAU,OAAO;IACrB,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,kBAAkB,IAAI,gBAAgB,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAA;AACjF,CAAC;AAED,+EAA+E;AAC/E,MAAM,OAAO,QAAS,SAAQ,KAAK;IAGtB;IAEA;IAJX,YACE,OAAe,EACN,MAAc;IACvB,4EAA4E;IACnE,YAAqB,KAAK;QAEnC,KAAK,CAAC,OAAO,CAAC,CAAA;QAJL,WAAM,GAAN,MAAM,CAAQ;QAEd,cAAS,GAAT,SAAS,CAAiB;QAGnC,IAAI,CAAC,IAAI,GAAG,UAAU,CAAA;IACxB,CAAC;CACF;AAED,IAAI,aAAa,GAAkB,IAAI,CAAA;AAEvC;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU;IAC9B,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,kBAAkB,EAAE,IAAI,EAAE,CAAA;IACzD,IAAI,UAAU;QAAE,OAAO,UAAU,CAAA;IAEjC,IAAI,aAAa;QAAE,OAAO,aAAa,CAAA;IAEvC,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,OAAO,EAAE,WAAW,CAAC,CAAA;IACrD,IAAI,CAAC,QAAQ,CAAC,EAAE,E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AAE,GAAG,CAAC,CAAA;QACjD,KAAK,GAAG;YACN,MAAM,IAAI,QAAQ,CAAC,MAAM,IAAI,mDAAmD,EAAE,GAAG,CAAC,CAAA;QACxF,KAAK,GAAG,CAAC,CAAC,CAAC;YACT,MAAM,UAAU,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,CAAA;YACtD,MAAM,IAAI,QAAQ,CAChB,eAAe,UAAU,CAAC,CAAC,CAAC,iBAAiB,UAAU,GAAG,CAAC,CAAC,CAAC,EAAE,qCAAqC,EACpG,GAAG,EACH,IAAI,CACL,CAAA;QACH,CAAC;QACD;YACE,MAAM,IAAI,QAAQ,CAAC,uBAAuB,QAAQ,CAAC,MAAM,KAAK,MAAM,EAAE,EAAE,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,IAAI,GAAG,CAAC,CAAA;IACpH,CAAC;AACH,CAAC"}
|
package/dist/server.d.ts
ADDED
package/dist/server.js
ADDED
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { ApiError, DEMO_KEY_NOTICE, request, usingDemoKey, } from './api.js';
|
|
4
|
+
/**
|
|
5
|
+
* The AtlasFetch tools.
|
|
6
|
+
*
|
|
7
|
+
* Kept apart from any transport so the same definitions serve the stdio entry
|
|
8
|
+
* point (`npx atlasfetch-mcp`, the published package) and, later, a hosted
|
|
9
|
+
* Streamable HTTP endpoint. A transport decides who is connected; it does not
|
|
10
|
+
* change what the tools do.
|
|
11
|
+
*
|
|
12
|
+
* Descriptions carry the caveats the API itself documents, because a model
|
|
13
|
+
* choosing a tool reads only these. The two that cause real mistakes:
|
|
14
|
+
* `municipal` is not always a city, and grid codes are output only.
|
|
15
|
+
*/
|
|
16
|
+
const VERSION = '0.1.0';
|
|
17
|
+
/** Every successful result carries the demo-key warning while one is in use. */
|
|
18
|
+
function ok(text) {
|
|
19
|
+
const body = usingDemoKey() ? `${text}\n\n${DEMO_KEY_NOTICE}` : text;
|
|
20
|
+
return { content: [{ type: 'text', text: body }] };
|
|
21
|
+
}
|
|
22
|
+
function fail(error) {
|
|
23
|
+
const message = error instanceof ApiError
|
|
24
|
+
? error.message
|
|
25
|
+
: error instanceof Error
|
|
26
|
+
? `Could not reach AtlasFetch: ${error.message}`
|
|
27
|
+
: 'Unknown error.';
|
|
28
|
+
return { content: [{ type: 'text', text: message }], isError: true };
|
|
29
|
+
}
|
|
30
|
+
const json = (value) => JSON.stringify(value, null, 2);
|
|
31
|
+
/** `{ country: {...}, region: null }` becomes "country: United Kingdom (GB) · region: no match". */
|
|
32
|
+
function summarise(result) {
|
|
33
|
+
const parts = Object.entries(result.base).map(([layer, hit]) => hit ? `${layer}: ${hit.name}${hit.code ? ` (${hit.code})` : ''}` : `${layer}: no match`);
|
|
34
|
+
const setNames = Object.entries(result.sets)
|
|
35
|
+
.filter(([, matches]) => matches.length > 0)
|
|
36
|
+
.map(([name, matches]) => `${name} -> ${matches.map(m => m.name).join(', ')}`);
|
|
37
|
+
if (setNames.length > 0)
|
|
38
|
+
parts.push(`sets: ${setNames.join('; ')}`);
|
|
39
|
+
return parts.join(' · ');
|
|
40
|
+
}
|
|
41
|
+
export function createServer() {
|
|
42
|
+
const server = new McpServer({ name: 'atlasfetch', version: VERSION }, {
|
|
43
|
+
instructions: 'AtlasFetch answers "which place is this coordinate in?" — the country, region and ' +
|
|
44
|
+
'municipality containing a point, plus the boundaries the caller has uploaded themselves. ' +
|
|
45
|
+
'It does not do street addresses, postcodes, routing or distances, and it does not return ' +
|
|
46
|
+
'boundary geometry for the reference layers.',
|
|
47
|
+
});
|
|
48
|
+
// ── The lookup ─────────────────────────────────────────────────────────────
|
|
49
|
+
server.registerTool('lookup_location', {
|
|
50
|
+
title: 'Look up the boundaries containing a coordinate',
|
|
51
|
+
description: [
|
|
52
|
+
'Reverse geocode a coordinate to the administrative areas that contain it — country,',
|
|
53
|
+
'region (state or province) and municipality — as names plus ISO 3166 codes, and match it',
|
|
54
|
+
'against boundary sets the account has uploaded, in the same call.',
|
|
55
|
+
'',
|
|
56
|
+
'Use for: which country, region or municipality a point is in; geofence checks against your',
|
|
57
|
+
'own polygons; tagging data with region codes.',
|
|
58
|
+
'Do NOT use for: street addresses or postcodes (this is not forward geocoding, and results',
|
|
59
|
+
'stop at the municipality), routing, distances, or fetching boundary geometry.',
|
|
60
|
+
'',
|
|
61
|
+
'Caveats worth repeating to the user: municipal is the finest unit AVAILABLE, not a',
|
|
62
|
+
'consistent kind of thing — Los Angeles returns a city, rural Kansas returns a county, so',
|
|
63
|
+
'do not assume it names a city. A layer that matched nothing comes back null. The errors',
|
|
64
|
+
'array is always present: a boundary set that is unavailable or not granted to this key is',
|
|
65
|
+
'skipped and reported there, while the call itself still succeeds.',
|
|
66
|
+
'',
|
|
67
|
+
'One call is one billed lookup however many layers, sets or grid codes it touches, and a',
|
|
68
|
+
'call that matches nothing still bills.',
|
|
69
|
+
].join('\n'),
|
|
70
|
+
inputSchema: {
|
|
71
|
+
lat: z.number().min(-90).max(90).describe('Latitude, -90 to 90.'),
|
|
72
|
+
lng: z.number().min(-180).max(180).describe('Longitude, -180 to 180.'),
|
|
73
|
+
base: z
|
|
74
|
+
.array(z.enum(['country', 'region', 'municipal']))
|
|
75
|
+
.optional()
|
|
76
|
+
.describe('Which reference layers to resolve. Defaults to all three.'),
|
|
77
|
+
sets: z
|
|
78
|
+
.array(z.string().max(64))
|
|
79
|
+
.optional()
|
|
80
|
+
.describe('Names of the boundary sets on this account to match against. Defaults to none.'),
|
|
81
|
+
encode: z
|
|
82
|
+
.array(z.enum(['h3', 'pluscode']))
|
|
83
|
+
.optional()
|
|
84
|
+
.describe('Also return the point as an H3 cell index and/or Google Plus Code. Output only — ' +
|
|
85
|
+
'neither can be used AS a location, because both name areas rather than points.'),
|
|
86
|
+
h3res: z.number().int().min(0).max(15).optional().describe('H3 resolution 0-15. 9 is about 400 m across.'),
|
|
87
|
+
pluslen: z
|
|
88
|
+
.union([
|
|
89
|
+
z.literal(2), z.literal(4), z.literal(6), z.literal(8), z.literal(10),
|
|
90
|
+
z.literal(11), z.literal(12), z.literal(13), z.literal(14), z.literal(15),
|
|
91
|
+
])
|
|
92
|
+
.optional()
|
|
93
|
+
.describe('Plus Code length. 9 is not a valid length. 10 is about 14 m.'),
|
|
94
|
+
},
|
|
95
|
+
annotations: { readOnlyHint: true, openWorldHint: true },
|
|
96
|
+
}, async ({ lat, lng, base, sets, encode, h3res, pluslen }) => {
|
|
97
|
+
try {
|
|
98
|
+
const result = await request('/location/lookup', {
|
|
99
|
+
query: {
|
|
100
|
+
lat: String(lat),
|
|
101
|
+
lng: String(lng),
|
|
102
|
+
base: base?.join(','),
|
|
103
|
+
set: sets?.join(','),
|
|
104
|
+
encode: encode?.join(','),
|
|
105
|
+
h3res: h3res === undefined ? undefined : String(h3res),
|
|
106
|
+
pluslen: pluslen === undefined ? undefined : String(pluslen),
|
|
107
|
+
},
|
|
108
|
+
});
|
|
109
|
+
const skipped = result.errors.length > 0
|
|
110
|
+
? `\n\nPartial problems (the lookup still succeeded):\n${result.errors.map(e => `- [${e.type}] ${e.message}`).join('\n')}`
|
|
111
|
+
: '';
|
|
112
|
+
return ok(`${summarise(result)}\n\n${json(result)}${skipped}`);
|
|
113
|
+
}
|
|
114
|
+
catch (error) {
|
|
115
|
+
return fail(error);
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
// ── Boundary sets ──────────────────────────────────────────────────────────
|
|
119
|
+
server.registerTool('list_boundary_sets', {
|
|
120
|
+
title: 'List the boundary sets on this account',
|
|
121
|
+
description: 'Lists the boundary sets on this account with their boundary counts and the API key ids ' +
|
|
122
|
+
'each is granted to. A set only matches during a lookup when it is available AND granted ' +
|
|
123
|
+
'to the key making the call.',
|
|
124
|
+
inputSchema: {},
|
|
125
|
+
annotations: { readOnlyHint: true, openWorldHint: true },
|
|
126
|
+
}, async () => {
|
|
127
|
+
try {
|
|
128
|
+
const result = await request('/boundaries/sets');
|
|
129
|
+
if (result.sets.length === 0) {
|
|
130
|
+
return ok('This account has no boundary sets yet. Create one with create_boundary_set.');
|
|
131
|
+
}
|
|
132
|
+
return ok(json(result.sets));
|
|
133
|
+
}
|
|
134
|
+
catch (error) {
|
|
135
|
+
return fail(error);
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
server.registerTool('create_boundary_set', {
|
|
139
|
+
title: 'Create a boundary set',
|
|
140
|
+
description: [
|
|
141
|
+
'Creates an empty named set to hold your own polygons: delivery zones, service areas,',
|
|
142
|
+
'sales territories.',
|
|
143
|
+
'',
|
|
144
|
+
'IMPORTANT, and not a bug: a new set is created unavailable and granted to no key, so it',
|
|
145
|
+
'matches nothing until both are changed. Granting is addressed by API key id, and the only',
|
|
146
|
+
'endpoint that lists key ids needs a browser session — which this server does not have. So',
|
|
147
|
+
'this tool can create the set and add boundaries to it, but CANNOT make it queryable. Tell',
|
|
148
|
+
'the user to finish that at https://atlasfetch.xyz/dashboard.',
|
|
149
|
+
].join('\n'),
|
|
150
|
+
inputSchema: {
|
|
151
|
+
name: z.string().min(1).max(32).describe('A short name, used to reference the set in lookups.'),
|
|
152
|
+
},
|
|
153
|
+
annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: true },
|
|
154
|
+
}, async ({ name }) => {
|
|
155
|
+
try {
|
|
156
|
+
const set = await request('/boundaries/sets', { method: 'POST', body: { name } });
|
|
157
|
+
return ok(`Created the set "${set.name}". It is not queryable yet: switch it on and grant it to an ` +
|
|
158
|
+
'API key at https://atlasfetch.xyz/dashboard — that step needs a signed-in browser.' +
|
|
159
|
+
`\n\n${json(set)}`);
|
|
160
|
+
}
|
|
161
|
+
catch (error) {
|
|
162
|
+
return fail(error);
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
server.registerTool('add_boundary', {
|
|
166
|
+
title: 'Add a boundary to a set',
|
|
167
|
+
description: 'Adds one GeoJSON polygon to a set on this account, with optional flat properties that come ' +
|
|
168
|
+
'back on every match. Plan caps limit vertices per boundary, properties per boundary, and ' +
|
|
169
|
+
'boundaries per set.',
|
|
170
|
+
inputSchema: {
|
|
171
|
+
set: z.string().min(1).max(32).describe('The set to add it to. It must already exist.'),
|
|
172
|
+
name: z.string().min(1).max(100).describe('A name for this boundary, returned on a match.'),
|
|
173
|
+
geometry: z
|
|
174
|
+
.record(z.string(), z.unknown())
|
|
175
|
+
.describe('GeoJSON geometry, e.g. {"type":"Polygon","coordinates":[[[lng,lat],...]]}. ' +
|
|
176
|
+
'Longitude comes first. A Feature or FeatureCollection is not accepted.'),
|
|
177
|
+
properties: z
|
|
178
|
+
.record(z.string(), z.unknown())
|
|
179
|
+
.optional()
|
|
180
|
+
.describe('Flat key/value pairs returned with every match of this boundary.'),
|
|
181
|
+
},
|
|
182
|
+
annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: true },
|
|
183
|
+
}, async ({ set, name, geometry, properties }) => {
|
|
184
|
+
// Caught here rather than at the API, so the message can name the actual
|
|
185
|
+
// mistake — passing a whole Feature is the common one.
|
|
186
|
+
if (typeof geometry.type !== 'string' || !('coordinates' in geometry)) {
|
|
187
|
+
return {
|
|
188
|
+
content: [{
|
|
189
|
+
type: 'text',
|
|
190
|
+
text: 'geometry must be a GeoJSON geometry object with "type" and "coordinates" — a ' +
|
|
191
|
+
'Feature or FeatureCollection is not accepted. Coordinates are [longitude, latitude].',
|
|
192
|
+
}],
|
|
193
|
+
isError: true,
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
try {
|
|
197
|
+
const created = await request('/boundaries', {
|
|
198
|
+
method: 'POST',
|
|
199
|
+
body: { set, name, geometry, properties },
|
|
200
|
+
});
|
|
201
|
+
return ok(`Added "${name}" to set "${set}".\n\n${json(created)}`);
|
|
202
|
+
}
|
|
203
|
+
catch (error) {
|
|
204
|
+
return fail(error);
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
return server;
|
|
208
|
+
}
|
|
209
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAA;AACnE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EACL,QAAQ,EAAE,eAAe,EAAE,OAAO,EAAE,YAAY,GAEjD,MAAM,UAAU,CAAA;AAEjB;;;;;;;;;;;GAWG;AAEH,MAAM,OAAO,GAAG,OAAO,CAAA;AAQvB,gFAAgF;AAChF,SAAS,EAAE,CAAC,IAAY;IACtB,MAAM,IAAI,GAAG,YAAY,EAAE,CAAC,CAAC,CAAC,GAAG,IAAI,OAAO,eAAe,EAAE,CAAC,CAAC,CAAC,IAAI,CAAA;IACpE,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,EAAE,CAAA;AACpD,CAAC;AAED,SAAS,IAAI,CAAC,KAAc;IAC1B,MAAM,OAAO,GAAG,KAAK,YAAY,QAAQ;QACvC,CAAC,CAAC,KAAK,CAAC,OAAO;QACf,CAAC,CAAC,KAAK,YAAY,KAAK;YACtB,CAAC,CAAC,+BAA+B,KAAK,CAAC,OAAO,EAAE;YAChD,CAAC,CAAC,gBAAgB,CAAA;IACtB,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAA;AACtE,CAAC;AAED,MAAM,IAAI,GAAG,CAAC,KAAc,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;AAE/D,oGAAoG;AACpG,SAAS,SAAS,CAAC,MAAsB;IACvC,MAAM,KAAK,G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,EAAE,CAAC,UAAU,IAAI,aAAa,GAAG,SAAS,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;QACnE,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,IAAI,CAAC,KAAK,CAAC,CAAA;QACpB,CAAC;IACH,CAAC,CACF,CAAA;IAED,OAAO,MAAM,CAAA;AACf,CAAC"}
|
package/dist/stdio.d.ts
ADDED
package/dist/stdio.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
3
|
+
import { createServer } from './server.js';
|
|
4
|
+
/**
|
|
5
|
+
* The published entry point: `npx atlasfetch-mcp`, launched by the MCP client
|
|
6
|
+
* as a child process and spoken to over stdin/stdout.
|
|
7
|
+
*
|
|
8
|
+
* NOTHING may be written to stdout except protocol messages — a stray
|
|
9
|
+
* console.log corrupts the stream and the client drops the connection. Logging
|
|
10
|
+
* goes to stderr, which clients surface as server logs.
|
|
11
|
+
*/
|
|
12
|
+
async function main() {
|
|
13
|
+
const server = createServer();
|
|
14
|
+
await server.connect(new StdioServerTransport());
|
|
15
|
+
console.error('atlasfetch-mcp ready on stdio');
|
|
16
|
+
}
|
|
17
|
+
main().catch(error => {
|
|
18
|
+
console.error('atlasfetch-mcp failed to start:', error);
|
|
19
|
+
process.exit(1);
|
|
20
|
+
});
|
|
21
|
+
//# sourceMappingURL=stdio.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stdio.js","sourceRoot":"","sources":["../src/stdio.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAA;AAChF,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE1C;;;;;;;GAOG;AACH,KAAK,UAAU,IAAI;IACjB,MAAM,MAAM,GAAG,YAAY,EAAE,CAAA;IAC7B,MAAM,MAAM,CAAC,OAAO,CAAC,IAAI,oBAAoB,EAAE,CAAC,CAAA;IAChD,OAAO,CAAC,KAAK,CAAC,+BAA+B,CAAC,CAAA;AAChD,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE;IACnB,OAAO,CAAC,KAAK,CAAC,iCAAiC,EAAE,KAAK,CAAC,CAAA;IACvD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AACjB,CAAC,CAAC,CAAA"}
|
package/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "atlasfetch-mcp",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "MCP server for AtlasFetch — reverse geocode a coordinate to its country, region and municipality (ISO 3166 codes), and match it against your own geofences.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"mcp",
|
|
7
|
+
"modelcontextprotocol",
|
|
8
|
+
"reverse-geocoding",
|
|
9
|
+
"geocoding",
|
|
10
|
+
"geofencing",
|
|
11
|
+
"point-in-polygon",
|
|
12
|
+
"administrative-boundaries",
|
|
13
|
+
"iso-3166",
|
|
14
|
+
"geojson",
|
|
15
|
+
"gis"
|
|
16
|
+
],
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"author": "ATLASIQ PTY LTD",
|
|
19
|
+
"homepage": "https://atlasfetch.xyz",
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "git+https://github.com/AtlasIq-dev/atlasfetch-mcp.git"
|
|
23
|
+
},
|
|
24
|
+
"bugs": {
|
|
25
|
+
"url": "https://github.com/AtlasIq-dev/atlasfetch-mcp/issues"
|
|
26
|
+
},
|
|
27
|
+
"type": "module",
|
|
28
|
+
"bin": {
|
|
29
|
+
"atlasfetch-mcp": "dist/stdio.js"
|
|
30
|
+
},
|
|
31
|
+
"files": [
|
|
32
|
+
"dist",
|
|
33
|
+
"README.md",
|
|
34
|
+
"LICENSE"
|
|
35
|
+
],
|
|
36
|
+
"engines": {
|
|
37
|
+
"node": ">=20"
|
|
38
|
+
},
|
|
39
|
+
"scripts": {
|
|
40
|
+
"build": "tsc",
|
|
41
|
+
"prepublishOnly": "npm run build",
|
|
42
|
+
"start": "node dist/stdio.js",
|
|
43
|
+
"typecheck": "tsc --noEmit"
|
|
44
|
+
},
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"@modelcontextprotocol/sdk": "^1.30.0",
|
|
47
|
+
"zod": "^4.6.5"
|
|
48
|
+
},
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"@types/node": "^24.0.0",
|
|
51
|
+
"typescript": "^5.9.0"
|
|
52
|
+
}
|
|
53
|
+
}
|