android-mock-location-mcp 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +76 -3
- package/dist/geocode.js +16 -12
- package/dist/geocode.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -32,11 +32,30 @@ npm start
|
|
|
32
32
|
| Variable | Description | Required |
|
|
33
33
|
|----------|-------------|----------|
|
|
34
34
|
| `PROVIDER` | Provider for geocoding + routing: `osm` (default), `google`, `mapbox` | No (defaults to `osm`) |
|
|
35
|
-
| `GOOGLE_API_KEY` | Google
|
|
35
|
+
| `GOOGLE_API_KEY` | Google Places + Routes API key | When `PROVIDER=google` |
|
|
36
36
|
| `MAPBOX_ACCESS_TOKEN` | Mapbox Geocoding + Directions access token | When `PROVIDER=mapbox` |
|
|
37
37
|
|
|
38
38
|
Set environment variables in your MCP client configuration:
|
|
39
39
|
|
|
40
|
+
<details>
|
|
41
|
+
<summary><b>Claude Desktop (default OSM provider)</b></summary>
|
|
42
|
+
|
|
43
|
+
Edit `~/Library/Application Support/Claude/claude_desktop_config.json` (macOS) or `%APPDATA%\Claude\claude_desktop_config.json` (Windows):
|
|
44
|
+
|
|
45
|
+
```json
|
|
46
|
+
{
|
|
47
|
+
"mcpServers": {
|
|
48
|
+
"android-mock-location-mcp": {
|
|
49
|
+
"command": "npx",
|
|
50
|
+
"args": ["-y", "android-mock-location-mcp"]
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
No API key required. Uses free Nominatim geocoding and OSRM routing (car profile only).
|
|
57
|
+
</details>
|
|
58
|
+
|
|
40
59
|
<details>
|
|
41
60
|
<summary><b>Claude Desktop with Google provider</b></summary>
|
|
42
61
|
|
|
@@ -56,6 +75,8 @@ Edit `~/Library/Application Support/Claude/claude_desktop_config.json` (macOS) o
|
|
|
56
75
|
}
|
|
57
76
|
}
|
|
58
77
|
```
|
|
78
|
+
|
|
79
|
+
**Prerequisites:** Enable both the [Places API (New)](https://console.cloud.google.com/apis/library/places.googleapis.com) and [Routes API](https://console.cloud.google.com/apis/library/routes.googleapis.com) in your Google Cloud project.
|
|
59
80
|
</details>
|
|
60
81
|
|
|
61
82
|
<details>
|
|
@@ -79,14 +100,66 @@ Edit `~/Library/Application Support/Claude/claude_desktop_config.json` (macOS) o
|
|
|
79
100
|
```
|
|
80
101
|
</details>
|
|
81
102
|
|
|
103
|
+
After editing the config, restart the MCP server and Claude Desktop for changes to take effect.
|
|
104
|
+
|
|
105
|
+
<details>
|
|
106
|
+
<summary><b>Claude Code (default OSM provider)</b></summary>
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
claude mcp add android-mock-location-mcp -- npx -y android-mock-location-mcp
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
No API key required. Uses free Nominatim geocoding and OSRM routing (car profile only).
|
|
113
|
+
</details>
|
|
114
|
+
|
|
82
115
|
<details>
|
|
83
116
|
<summary><b>Claude Code with Google provider</b></summary>
|
|
84
117
|
|
|
85
118
|
```bash
|
|
86
|
-
GOOGLE_API_KEY=your-google-api-key
|
|
119
|
+
GOOGLE_API_KEY=your-google-api-key
|
|
120
|
+
claude mcp add android-mock-location-mcp \
|
|
121
|
+
-e PROVIDER=google \
|
|
122
|
+
-e GOOGLE_API_KEY=$GOOGLE_API_KEY \
|
|
123
|
+
-- npx -y android-mock-location-mcp
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
**Prerequisites:** Enable both the [Places API (New)](https://console.cloud.google.com/apis/library/places.googleapis.com) and [Routes API](https://console.cloud.google.com/apis/library/routes.googleapis.com) in your Google Cloud project.
|
|
127
|
+
</details>
|
|
128
|
+
|
|
129
|
+
<details>
|
|
130
|
+
<summary><b>Claude Code with Mapbox provider</b></summary>
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
MAPBOX_ACCESS_TOKEN=your-mapbox-access-token
|
|
134
|
+
claude mcp add android-mock-location-mcp \
|
|
135
|
+
-e PROVIDER=mapbox \
|
|
136
|
+
-e MAPBOX_ACCESS_TOKEN=$MAPBOX_ACCESS_TOKEN \
|
|
137
|
+
-- npx -y android-mock-location-mcp
|
|
87
138
|
```
|
|
88
139
|
</details>
|
|
89
140
|
|
|
141
|
+
<details>
|
|
142
|
+
<summary><b>Claude Code — switching providers</b></summary>
|
|
143
|
+
|
|
144
|
+
To switch from one provider to another (e.g. `osm` → `google`), remove and re-add the server with new env vars, then restart the server and Claude Code:
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
# 1. Remove existing server
|
|
148
|
+
claude mcp remove android-mock-location-mcp
|
|
149
|
+
|
|
150
|
+
# 2. Re-add with new provider
|
|
151
|
+
GOOGLE_API_KEY=your-google-api-key
|
|
152
|
+
claude mcp add android-mock-location-mcp \
|
|
153
|
+
-e PROVIDER=google \
|
|
154
|
+
-e GOOGLE_API_KEY=$GOOGLE_API_KEY \
|
|
155
|
+
-- npx -y android-mock-location-mcp
|
|
156
|
+
|
|
157
|
+
# 3. Restart the MCP server and Claude Code
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
Environment variables are baked into the MCP server config at initialization time. Changing providers requires restarting the server.
|
|
161
|
+
</details>
|
|
162
|
+
|
|
90
163
|
### Providers
|
|
91
164
|
|
|
92
165
|
Google and Mapbox providers produce better results than the default OSM provider — more accurate geocoding, full routing profile support (car/foot/bike), and higher rate limits. Both offer free tiers.
|
|
@@ -94,7 +167,7 @@ Google and Mapbox providers produce better results than the default OSM provider
|
|
|
94
167
|
| `PROVIDER` | Geocoding Service | Routing Service | Profiles Supported | API Key | Cost |
|
|
95
168
|
| ------------- | --------------------------- | --------------- | ------------------ | ---------------------- | -------------------- |
|
|
96
169
|
| `osm` (default) | Nominatim (OpenStreetMap) | OSRM | `car` only* | None | Free (rate-limited) |
|
|
97
|
-
| `google` | Google
|
|
170
|
+
| `google` | Google Places API | Google Routes API | `car`, `foot`, `bike` | `GOOGLE_API_KEY` | Paid ([free tier](https://developers.google.com/maps/get-started)) |
|
|
98
171
|
| `mapbox` | Mapbox Geocoding | Mapbox Directions | `car`, `foot`, `bike` | `MAPBOX_ACCESS_TOKEN` | Paid ([free tier](https://account.mapbox.com/access-tokens/)) |
|
|
99
172
|
|
|
100
173
|
**\*OSRM limitation:** The public OSRM demo server (`router.project-osrm.org`) only supports the `car` profile. Requesting `foot` or `bike` silently returns a driving route. For walking/cycling routing, use `google` or `mapbox`.
|
package/dist/geocode.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
// All providers use a 10-second fetch timeout to prevent indefinite hangs.
|
|
6
6
|
//
|
|
7
7
|
// PROVIDER=osm → Nominatim (default, free, no API key)
|
|
8
|
-
// PROVIDER=google → Google
|
|
8
|
+
// PROVIDER=google → Google Places API (requires GOOGLE_API_KEY)
|
|
9
9
|
// PROVIDER=mapbox → Mapbox Geocoding (requires MAPBOX_ACCESS_TOKEN)
|
|
10
10
|
//
|
|
11
11
|
// To add a new provider, implement the GeocodeProvider signature and add a
|
|
@@ -28,24 +28,28 @@ const nominatimGeocode = async (place) => {
|
|
|
28
28
|
return null;
|
|
29
29
|
return { lat: parseFloat(data[0].lat), lng: parseFloat(data[0].lon), displayName: data[0].display_name };
|
|
30
30
|
};
|
|
31
|
-
// ── Google
|
|
31
|
+
// ── Google Places API (Text Search) ─────────────────────────────────────────
|
|
32
32
|
const googleGeocode = async (place) => {
|
|
33
33
|
const apiKey = process.env.GOOGLE_API_KEY; // Validated by selectProvider()
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
34
|
+
const res = await fetchWithTimeout("https://places.googleapis.com/v1/places:searchText", {
|
|
35
|
+
method: "POST",
|
|
36
|
+
headers: {
|
|
37
|
+
"Content-Type": "application/json",
|
|
38
|
+
"X-Goog-Api-Key": apiKey,
|
|
39
|
+
"X-Goog-FieldMask": "places.location,places.displayName,places.formattedAddress",
|
|
40
|
+
},
|
|
41
|
+
body: JSON.stringify({ textQuery: place }),
|
|
42
|
+
}, 10_000);
|
|
39
43
|
if (!res.ok)
|
|
40
44
|
return null;
|
|
41
45
|
const data = (await res.json());
|
|
42
|
-
if (
|
|
46
|
+
if (!data.places?.length)
|
|
43
47
|
return null;
|
|
44
|
-
const result = data.
|
|
48
|
+
const result = data.places[0];
|
|
45
49
|
return {
|
|
46
|
-
lat: result.
|
|
47
|
-
lng: result.
|
|
48
|
-
displayName: result.
|
|
50
|
+
lat: result.location.latitude,
|
|
51
|
+
lng: result.location.longitude,
|
|
52
|
+
displayName: result.formattedAddress,
|
|
49
53
|
};
|
|
50
54
|
};
|
|
51
55
|
// ── Mapbox Geocoding API ─────────────────────────────────────────────────────
|
package/dist/geocode.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geocode.js","sourceRoot":"","sources":["../src/geocode.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,EAAE;AACF,mFAAmF;AACnF,EAAE;AACF,2EAA2E;AAC3E,EAAE;AACF,8DAA8D;AAC9D,
|
|
1
|
+
{"version":3,"file":"geocode.js","sourceRoot":"","sources":["../src/geocode.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,EAAE;AACF,mFAAmF;AACnF,EAAE;AACF,2EAA2E;AAC3E,EAAE;AACF,8DAA8D;AAC9D,oEAAoE;AACpE,wEAAwE;AACxE,EAAE;AACF,2EAA2E;AAC3E,4BAA4B;AAE5B,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAUpD,gFAAgF;AAEhF,MAAM,gBAAgB,GAAoB,KAAK,EAAE,KAAK,EAAE,EAAE;IACxD,MAAM,GAAG,GAAG,8CAA8C,IAAI,eAAe,CAAC;QAC5E,CAAC,EAAE,KAAK;QACR,MAAM,EAAE,MAAM;QACd,KAAK,EAAE,GAAG;KACX,CAAC,EAAE,CAAC;IACL,MAAM,GAAG,GAAG,MAAM,gBAAgB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