mapnetwork-mcp 1.2.3__tar.gz → 2.0.0__tar.gz
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.
- mapnetwork_mcp-2.0.0/.github/workflows/workflow.yml +33 -0
- {mapnetwork_mcp-1.2.3 → mapnetwork_mcp-2.0.0}/PKG-INFO +2 -1
- {mapnetwork_mcp-1.2.3 → mapnetwork_mcp-2.0.0}/RELEASING.md +88 -86
- {mapnetwork_mcp-1.2.3 → mapnetwork_mcp-2.0.0}/manifest.json +1 -1
- {mapnetwork_mcp-1.2.3 → mapnetwork_mcp-2.0.0}/mapnetwork_mcp/server.py +46 -164
- {mapnetwork_mcp-1.2.3 → mapnetwork_mcp-2.0.0}/pyproject.toml +6 -2
- {mapnetwork_mcp-1.2.3 → mapnetwork_mcp-2.0.0}/.gitignore +0 -0
- {mapnetwork_mcp-1.2.3 → mapnetwork_mcp-2.0.0}/.mcpbignore +0 -0
- {mapnetwork_mcp-1.2.3 → mapnetwork_mcp-2.0.0}/LICENSE +0 -0
- {mapnetwork_mcp-1.2.3 → mapnetwork_mcp-2.0.0}/README.md +0 -0
- {mapnetwork_mcp-1.2.3 → mapnetwork_mcp-2.0.0}/images/Kanazawa21Museum-black.png +0 -0
- {mapnetwork_mcp-1.2.3 → mapnetwork_mcp-2.0.0}/images/Kanazawa21Museum-darkGreen.png +0 -0
- {mapnetwork_mcp-1.2.3 → mapnetwork_mcp-2.0.0}/images/Kanazawa21Museum-grey.png +0 -0
- {mapnetwork_mcp-1.2.3 → mapnetwork_mcp-2.0.0}/images/Kanazawa21Museum-lightGreen.png +0 -0
- {mapnetwork_mcp-1.2.3 → mapnetwork_mcp-2.0.0}/images/Kanazawa21Museum-popArt.png +0 -0
- {mapnetwork_mcp-1.2.3 → mapnetwork_mcp-2.0.0}/images/Kanazawa21Museum-white.png +0 -0
- {mapnetwork_mcp-1.2.3 → mapnetwork_mcp-2.0.0}/mapnetwork_mcp/__init__.py +0 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- "v*"
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
contents: read
|
|
10
|
+
id-token: write
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
build-and-publish:
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@v4
|
|
17
|
+
|
|
18
|
+
- uses: actions/setup-python@v5
|
|
19
|
+
with:
|
|
20
|
+
python-version: "3.x"
|
|
21
|
+
|
|
22
|
+
- name: Build package
|
|
23
|
+
run: |
|
|
24
|
+
python -m pip install --upgrade build
|
|
25
|
+
python -m build
|
|
26
|
+
|
|
27
|
+
- name: Check package
|
|
28
|
+
run: |
|
|
29
|
+
python -m pip install --upgrade twine
|
|
30
|
+
twine check dist/*
|
|
31
|
+
|
|
32
|
+
- name: Publish to PyPI
|
|
33
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mapnetwork-mcp
|
|
3
|
-
Version:
|
|
3
|
+
Version: 2.0.0
|
|
4
4
|
Summary: MCP server — generate styled map images via mapnetwork.app
|
|
5
5
|
Project-URL: Homepage, https://mapnetwork.app
|
|
6
6
|
Project-URL: Repository, https://github.com/toruproject/mapnetwork-mcp
|
|
7
|
+
License-Expression: MIT
|
|
7
8
|
License-File: LICENSE
|
|
8
9
|
Requires-Python: >=3.11
|
|
9
10
|
Requires-Dist: httpx>=0.27.0
|
|
@@ -1,87 +1,89 @@
|
|
|
1
|
-
# Releasing a new version
|
|
2
|
-
|
|
3
|
-
This project's version number is declared in **three places** that must stay in sync:
|
|
4
|
-
|
|
5
|
-
| File | Field(s) |
|
|
6
|
-
|---|---|
|
|
7
|
-
| `pyproject.toml` | `[project] version` |
|
|
8
|
-
| `server.json` | `version`, `packages[0].version` |
|
|
9
|
-
| `manifest.json` | `version` |
|
|
10
|
-
|
|
11
|
-
## Steps
|
|
12
|
-
|
|
13
|
-
1. **Bump the version** in all three files above (same value).
|
|
14
|
-
|
|
15
|
-
2. **
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
1
|
+
# Releasing a new version
|
|
2
|
+
|
|
3
|
+
This project's version number is declared in **three places** that must stay in sync:
|
|
4
|
+
|
|
5
|
+
| File | Field(s) |
|
|
6
|
+
|---|---|
|
|
7
|
+
| `pyproject.toml` | `[project] version` |
|
|
8
|
+
| `server.json` | `version`, `packages[0].version` |
|
|
9
|
+
| `manifest.json` | `version` |
|
|
10
|
+
|
|
11
|
+
## Steps
|
|
12
|
+
|
|
13
|
+
1. **Bump the version** in all three files above (same value).
|
|
14
|
+
|
|
15
|
+
2. **(Optional) Local build sanity check** — the real publish now happens
|
|
16
|
+
unattended in CI (see step 3), so this is just a pre-flight check to catch
|
|
17
|
+
build errors before tagging:
|
|
18
|
+
```bash
|
|
19
|
+
rm -f dist/*.whl dist/*.tar.gz
|
|
20
|
+
.venv/Scripts/python -m build
|
|
21
|
+
.venv/Scripts/python -m twine check dist/mapnetwork_mcp-<version>*
|
|
22
|
+
```
|
|
23
|
+
Use the version-specific glob, not `dist/*` — a leftover `.mcpb` from a
|
|
24
|
+
previous release sits in the same `dist/` folder and `twine check` errors
|
|
25
|
+
out on it ("Unknown distribution format") even though the actual wheel/
|
|
26
|
+
sdist are fine.
|
|
27
|
+
|
|
28
|
+
3. **Commit, tag, and push** (moved up — pushing the tag is what triggers the release)
|
|
29
|
+
```bash
|
|
30
|
+
git add pyproject.toml server.json manifest.json mapnetwork_mcp/server.py # plus any other source files changed for this release
|
|
31
|
+
git commit -m "Bump version to <version>"
|
|
32
|
+
git push origin main
|
|
33
|
+
git tag -a v<version> -m "v<version>"
|
|
34
|
+
git push origin v<version>
|
|
35
|
+
```
|
|
36
|
+
Pushing the `v<version>` tag triggers `.github/workflows/workflow.yml`,
|
|
37
|
+
which builds the package and publishes it to PyPI via [Trusted
|
|
38
|
+
Publishing](https://docs.pypi.org/trusted-publishers/) (OIDC) —
|
|
39
|
+
**no `twine upload`, no PyPI API token needed anymore.** The trusted
|
|
40
|
+
publisher is registered on PyPI's project settings (repo:
|
|
41
|
+
`toruproject/mapnetwork-mcp`, workflow: `workflow.yml`); if the workflow
|
|
42
|
+
filename ever changes, that registration must be updated to match.
|
|
43
|
+
|
|
44
|
+
4. **Confirm the release landed**
|
|
45
|
+
Watch the workflow run in the repo's Actions tab, then verify PyPI has it:
|
|
46
|
+
```bash
|
|
47
|
+
curl -s https://pypi.org/pypi/mapnetwork-mcp/json | grep -o '"<version>"'
|
|
48
|
+
```
|
|
49
|
+
If the workflow fails after the tag was already pushed, fix the issue and
|
|
50
|
+
push a new patch version — PyPI rejects re-uploading a version that
|
|
51
|
+
already exists, and tags shouldn't be deleted/reused once pushed.
|
|
52
|
+
|
|
53
|
+
5. **Publish to the MCP registry**
|
|
54
|
+
```bash
|
|
55
|
+
./mcp-publisher.exe validate server.json
|
|
56
|
+
./mcp-publisher.exe login github # only needed if the session expired
|
|
57
|
+
./mcp-publisher.exe publish server.json
|
|
58
|
+
```
|
|
59
|
+
The registry entry's `packages[0].version` must match the version actually live on PyPI (the registry does not host the code itself).
|
|
60
|
+
|
|
61
|
+
⚠️ `login github` opens an interactive device-confirmation flow in the
|
|
62
|
+
browser — it cannot be automated or run on someone's behalf. Run it
|
|
63
|
+
yourself in your own terminal (not delegated to an agent) and confirm
|
|
64
|
+
it's done before continuing to `publish`.
|
|
65
|
+
|
|
66
|
+
6. **Rebuild the MCPB bundle**
|
|
67
|
+
```bash
|
|
68
|
+
npx --yes @anthropic-ai/mcpb validate manifest.json
|
|
69
|
+
npx --yes @anthropic-ai/mcpb pack . dist/mapnetwork-mcp.mcpb
|
|
70
|
+
```
|
|
71
|
+
The output filename is literally `mapnetwork-mcp.mcpb` — **not**
|
|
72
|
+
version-suffixed (the `mcpb pack` tool's own summary output shows a
|
|
73
|
+
version-suffixed "Archive Details > filename" field, which is just a
|
|
74
|
+
display label and does not match the actual file written to disk). Use
|
|
75
|
+
`dist/mapnetwork-mcp.mcpb` verbatim in step 7, not a guessed
|
|
76
|
+
`mapnetwork-mcp-<version>.mcpb`.
|
|
77
|
+
|
|
78
|
+
7. **Create the GitHub Release** with the `.mcpb` bundle attached
|
|
79
|
+
```bash
|
|
80
|
+
gh release create v<version> dist/mapnetwork-mcp.mcpb --title "v<version>" --notes "..."
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Notes
|
|
84
|
+
|
|
85
|
+
- `.mcpregistry_github_token` / `.mcpregistry_registry_token` hold the `mcp-publisher` login session — they are git-ignored and must never be committed.
|
|
86
|
+
- `dist/` is git-ignored; build artifacts and the `.mcpb` bundle are distributed only via PyPI / the GitHub Release, not via the repository. Old files from a
|
|
87
|
+
previous release aren't cleaned up automatically (step 2 only removes
|
|
88
|
+
`*.whl`/`*.tar.gz`) — the stray `.mcpb` from the last run stays there, which
|
|
87
89
|
is exactly what trips up the `twine check dist/*` glob above.
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"manifest_version": "0.4",
|
|
3
3
|
"name": "mapnetwork-mcp",
|
|
4
4
|
"display_name": "MapNetwork",
|
|
5
|
-
"version": "
|
|
5
|
+
"version": "2.0.0",
|
|
6
6
|
"description": "Generate styled PNG/SVG map images of any location with 11 customizable color themes.",
|
|
7
7
|
"long_description": "MCP server for MapNetwork — generate styled map images (PNG / SVG) for any location on Earth, directly from Claude.\n\n- Generate maps from a place name, coordinates, or a list of markers\n- 11 color themes (white, darkBlue, darkGreen, popArt, lightBlue, lightGreen, beige, magenta, gray, black, brawn)\n- Overlay walking / driving routes on the map\n- PNG or SVG output, saved to your Downloads folder\n- Re-download a previously generated map in a different theme or format without regenerating\n- Open any generated map in the MapNetwork web editor for manual customization",
|
|
8
8
|
"author": {
|
|
@@ -34,8 +34,8 @@ _LAYER_PRESETS: dict[str, list[str]] = {
|
|
|
34
34
|
|
|
35
35
|
|
|
36
36
|
class Location(BaseModel):
|
|
37
|
-
lat: float
|
|
38
|
-
lng: float
|
|
37
|
+
lat: float = Field(description="Latitude.")
|
|
38
|
+
lng: float = Field(description="Longitude.")
|
|
39
39
|
|
|
40
40
|
|
|
41
41
|
class Marker(BaseModel):
|
|
@@ -58,25 +58,12 @@ class RouteInput(BaseModel):
|
|
|
58
58
|
coords: list[list[float]] | None = Field(
|
|
59
59
|
default=None, description="Ordered list of [lat, lng] pairs along the route."
|
|
60
60
|
)
|
|
61
|
-
mode: Literal["walking", "driving"] | None = None
|
|
61
|
+
mode: Literal["walking", "driving"] | None = Field(default=None, description="'walking' or 'driving'.")
|
|
62
62
|
from_: RouteEndpoint | None = Field(default=None, alias="from", description="Route start point.")
|
|
63
63
|
to: RouteEndpoint | None = Field(default=None, description="Route end point.")
|
|
64
64
|
color: str | None = Field(default=None, description="Optional line color as a CSS hex color (e.g. '#FF4500').")
|
|
65
65
|
|
|
66
66
|
|
|
67
|
-
class MapConfig(BaseModel):
|
|
68
|
-
patchworked: bool | None = Field(
|
|
69
|
-
default=None, description="Auto-color closed areas and building shapes on the drawing. Default true."
|
|
70
|
-
)
|
|
71
|
-
withBuilding: bool | None = Field(
|
|
72
|
-
default=None, description="Draw building shapes. Default true when building data is available."
|
|
73
|
-
)
|
|
74
|
-
withSeaRibbon: bool | None = Field(
|
|
75
|
-
default=None,
|
|
76
|
-
description="Draw a band representing the sea along the coastline. Default true when coastline data is available.",
|
|
77
|
-
)
|
|
78
|
-
|
|
79
|
-
|
|
80
67
|
mcp = FastMCP(
|
|
81
68
|
"MapNetwork",
|
|
82
69
|
instructions=(
|
|
@@ -150,8 +137,7 @@ def _make_filename(label: str, format: str) -> Path:
|
|
|
150
137
|
|
|
151
138
|
|
|
152
139
|
async def _download(client: httpx.AsyncClient, data_key: str, format: str,
|
|
153
|
-
color_set: str | None, canvas_width: int | None, canvas_height: int | None
|
|
154
|
-
edge_weight: int | None = None) -> bytes:
|
|
140
|
+
color_set: str | None, canvas_width: int | None, canvas_height: int | None) -> bytes:
|
|
155
141
|
params: dict = {"dataKey": data_key, "format": format}
|
|
156
142
|
if color_set is not None:
|
|
157
143
|
params["colorSet"] = color_set
|
|
@@ -159,8 +145,6 @@ async def _download(client: httpx.AsyncClient, data_key: str, format: str,
|
|
|
159
145
|
params["canvasWidth"] = canvas_width
|
|
160
146
|
if canvas_height is not None:
|
|
161
147
|
params["canvasHeight"] = canvas_height
|
|
162
|
-
if edge_weight is not None:
|
|
163
|
-
params["edgeWeight"] = edge_weight
|
|
164
148
|
resp = await client.get(f"{BASE_URL}/download", params=params, timeout=60)
|
|
165
149
|
if resp.status_code != 200:
|
|
166
150
|
raise RuntimeError(f"Download failed ({resp.status_code}): {resp.text}")
|
|
@@ -224,34 +208,15 @@ def _still_in_progress_result(data_key: str) -> list:
|
|
|
224
208
|
@mcp.tool()
|
|
225
209
|
async def compute_route(
|
|
226
210
|
from_location: Annotated[
|
|
227
|
-
RouteEndpoint,
|
|
228
|
-
"Start point of the route. Provide 'location' for explicit coordinates (no geocoding), "
|
|
229
|
-
"or only 'label' to geocode server-side. Both may be provided — 'location' takes precedence, "
|
|
230
|
-
"'label' is used for display. Example: {\"label\": \"赤坂駅\"}",
|
|
211
|
+
RouteEndpoint, Field(description="Route start. 'location' for coordinates, or 'label' to geocode.")
|
|
231
212
|
],
|
|
232
|
-
to_location: Annotated[
|
|
233
|
-
|
|
234
|
-
"End point of the route. Same format as from_location. "
|
|
235
|
-
"Example: {\"label\": \"赤坂氷川神社\"}",
|
|
236
|
-
],
|
|
237
|
-
mode: Annotated[
|
|
238
|
-
str,
|
|
239
|
-
"Routing mode: 'walking' (default, footpaths and streets) or 'driving' (car-accessible roads).",
|
|
240
|
-
] = "walking",
|
|
213
|
+
to_location: Annotated[RouteEndpoint, Field(description="Route end. Same format as from_location.")],
|
|
214
|
+
mode: Annotated[Literal["walking", "driving"], Field(description="Default 'walking'.")] = "walking",
|
|
241
215
|
) -> dict:
|
|
242
|
-
"""Compute a
|
|
216
|
+
"""Compute a route. Returns {coords, from, to} — pass directly to generate_map(route=...).
|
|
243
217
|
|
|
244
|
-
|
|
245
|
-
Pass the result directly to generate_map's `route` parameter to overlay it on a map image.
|
|
246
|
-
Use from/to as `markers` in generate_map to place pins at the start and end points.
|
|
247
|
-
|
|
248
|
-
Typical flow:
|
|
249
|
-
1. route = compute_route(from_location={"label": "A"}, to_location={"label": "B"})
|
|
250
|
-
2. generate_map(route=route, markers=[route["from"], route["to"]], ...)
|
|
218
|
+
Example: compute_route(from_location={"label": "Tokyo Station"}, to_location={"label": "Tokyo Tower"})
|
|
251
219
|
"""
|
|
252
|
-
if mode not in ("walking", "driving"):
|
|
253
|
-
raise ValueError("mode must be 'walking' or 'driving'")
|
|
254
|
-
|
|
255
220
|
body = {
|
|
256
221
|
"from": from_location.model_dump(exclude_none=True),
|
|
257
222
|
"to": to_location.model_dump(exclude_none=True),
|
|
@@ -279,109 +244,47 @@ async def compute_route(
|
|
|
279
244
|
@mcp.tool()
|
|
280
245
|
async def generate_map(
|
|
281
246
|
place: Annotated[
|
|
282
|
-
str | None,
|
|
283
|
-
"Place name to center the map on (e.g. 'Shibuya Station', '東京駅', 'Eiffel Tower'). "
|
|
284
|
-
"A red pin is placed at the resolved location. Use this OR lat/lng, not both. "
|
|
285
|
-
"Omit when using markers-only mode.",
|
|
286
|
-
] = None,
|
|
287
|
-
lat: Annotated[
|
|
288
|
-
float | None,
|
|
289
|
-
"Latitude of the map center. Must be combined with lng. "
|
|
290
|
-
"ONLY set this when you have a precise, verified coordinate value — never guess or estimate. "
|
|
291
|
-
"If the location is known only by name, use `place` instead and let the server geocode it. "
|
|
292
|
-
"Omit when using markers-only mode.",
|
|
293
|
-
] = None,
|
|
294
|
-
lng: Annotated[
|
|
295
|
-
float | None,
|
|
296
|
-
"Longitude of the map center. Must be combined with lat. "
|
|
297
|
-
"ONLY set this when you have a precise, verified coordinate value — never guess or estimate. "
|
|
298
|
-
"If the location is known only by name, use `place` instead and let the server geocode it. "
|
|
299
|
-
"Omit when using markers-only mode.",
|
|
300
|
-
] = None,
|
|
301
|
-
markers: Annotated[
|
|
302
|
-
list[Marker] | None,
|
|
303
|
-
"List of locations to pin on the map as blue markers. "
|
|
304
|
-
"Each item needs only a 'label' (geocoded automatically); explicit 'location' {lat, lng} is optional. "
|
|
305
|
-
"When markers are provided without place/lat/lng, the server derives the map center from their centroid "
|
|
306
|
-
"and sets radius automatically. "
|
|
307
|
-
"Example for two stations: [{\"label\": \"東京駅\"}, {\"label\": \"新宿駅\"}]",
|
|
308
|
-
] = None,
|
|
309
|
-
name: Annotated[
|
|
310
|
-
str | None,
|
|
311
|
-
"Map name stored in the data file. Used as the default download filename. "
|
|
312
|
-
"Omit to leave unnamed.",
|
|
247
|
+
str | None, Field(description="Place name to center the map on. Use this OR lat/lng, not both.")
|
|
313
248
|
] = None,
|
|
249
|
+
lat: Annotated[float | None, Field(description="Latitude of the map center. Must be combined with lng.")] = None,
|
|
250
|
+
lng: Annotated[float | None, Field(description="Longitude of the map center. Must be combined with lat.")] = None,
|
|
251
|
+
markers: Annotated[list[Marker] | None, Field(description="Locations to pin on the map.")] = None,
|
|
252
|
+
name: Annotated[str | None, Field(description="Map name stored in the data file.")] = None,
|
|
314
253
|
radius: Annotated[
|
|
315
254
|
int | None,
|
|
316
|
-
"Circular
|
|
317
|
-
"Mutually exclusive with size_ew/size_ns. "
|
|
318
|
-
"ONLY set this when the user has explicitly requested a specific coverage range. "
|
|
319
|
-
"If the user has not specified a range, omit it — the server applies a sensible default (500 m).",
|
|
255
|
+
Field(description="Circular radius in meters (default 500, max 2500). Exclusive with size_ew/size_ns."),
|
|
320
256
|
] = None,
|
|
321
257
|
size_ew: Annotated[
|
|
322
258
|
float | None,
|
|
323
|
-
"
|
|
324
|
-
"Must be combined with size_ns. Mutually exclusive with radius. "
|
|
325
|
-
"ONLY set this when the user has explicitly requested a rectangular area of specific dimensions. "
|
|
326
|
-
"Do not infer dimensions — omit and let the server use its default if the user has not specified.",
|
|
259
|
+
Field(description="Rectangular area width (east-west), meters. Must pair with size_ns; exclusive with radius."),
|
|
327
260
|
] = None,
|
|
328
261
|
size_ns: Annotated[
|
|
329
262
|
float | None,
|
|
330
|
-
"
|
|
331
|
-
"Must be combined with size_ew. Mutually exclusive with radius. "
|
|
332
|
-
"ONLY set this when the user has explicitly requested a rectangular area of specific dimensions.",
|
|
263
|
+
Field(description="Rectangular area height (north-south), meters. Must pair with size_ew."),
|
|
333
264
|
] = None,
|
|
334
265
|
layers: Annotated[
|
|
335
266
|
Literal["default", "road_and_railway", "only_driving_road", "fully_detailed"] | None,
|
|
336
|
-
"
|
|
337
|
-
"'only_driving_road': car-accessible roads only, nothing else. "
|
|
338
|
-
"'road_and_railway': roads + railway lines, no POI. "
|
|
339
|
-
"'fully_detailed': roads + railway + waterline + greenarea + POI "
|
|
340
|
-
"(waterline/greenarea only apply within Japan; ignored elsewhere). "
|
|
341
|
-
"Omit for 'default'.",
|
|
267
|
+
Field(description="Layer preset — see server instructions for what each preset includes. Omit for 'default'."),
|
|
342
268
|
] = None,
|
|
343
269
|
route: Annotated[
|
|
344
270
|
RouteInput | None,
|
|
345
|
-
"Route to overlay
|
|
346
|
-
"the server uses coords and (optionally) color from it. "
|
|
347
|
-
"To customise the line color, set/override the 'color' field (e.g. '#FF4500'). "
|
|
348
|
-
"Omit to generate a map without a route overlay.",
|
|
349
|
-
] = None,
|
|
350
|
-
config: Annotated[
|
|
351
|
-
MapConfig | None,
|
|
352
|
-
"Overrides for automatic layer-visibility defaults. Omit any field to keep the default. "
|
|
353
|
-
"Example to turn off buildings: {\"withBuilding\": false}.",
|
|
271
|
+
Field(description="Route to overlay — pass compute_route()'s result directly. Add/override 'color' (hex) to customize."),
|
|
354
272
|
] = None,
|
|
355
273
|
color_set: Annotated[
|
|
356
274
|
str | None,
|
|
357
|
-
"Color theme for the
|
|
358
|
-
"Baked into the stored map data so redownload_map uses the same theme by default. "
|
|
359
|
-
"Can be overridden per-download by passing color_set to redownload_map. "
|
|
360
|
-
"Available themes: white, darkBlue, darkGreen, popArt, lightBlue, lightGreen, beige, magenta, gray, black, brawn.",
|
|
275
|
+
Field(description="Color theme name — see server instructions for the list. Only set when explicitly requested."),
|
|
361
276
|
] = None,
|
|
362
|
-
format: Annotated[
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
] = "png",
|
|
366
|
-
canvas_width: Annotated[int | None, "Canvas width in pixels. Omit to use server default (1000)."] = None,
|
|
367
|
-
canvas_height: Annotated[int | None, "Canvas height in pixels. Omit to use server default (600)."] = None,
|
|
277
|
+
format: Annotated[Literal["png", "svg"], Field(description="'png' (default) or 'svg'.")] = "png",
|
|
278
|
+
canvas_width: Annotated[int | None, Field(description="Canvas width in pixels (default 1000).")] = None,
|
|
279
|
+
canvas_height: Annotated[int | None, Field(description="Canvas height in pixels (default 600).")] = None,
|
|
368
280
|
ctx: Context = None,
|
|
369
281
|
) -> list:
|
|
370
|
-
"""Generate a styled map image
|
|
282
|
+
"""Generate a styled map image and save it to Downloads.
|
|
371
283
|
|
|
372
|
-
|
|
373
|
-
-
|
|
374
|
-
- radius=N: circular, N meters
|
|
375
|
-
- size_ew + size_ns: rectangular bounding box
|
|
284
|
+
May return a pending dataKey instead of the image — see server instructions for the
|
|
285
|
+
check_map_status follow-up flow.
|
|
376
286
|
|
|
377
|
-
|
|
378
|
-
Use redownload_map(dataKey=...) to get the same map in a different color or format
|
|
379
|
-
without waiting for regeneration.
|
|
380
|
-
|
|
381
|
-
If generation is still running after a short wait, this returns a dataKey and asks
|
|
382
|
-
you to call check_map_status(dataKey=...) after a delay instead of returning the
|
|
383
|
-
image directly — do not call generate_map again for the same location in that case,
|
|
384
|
-
it would just start a redundant duplicate job.
|
|
287
|
+
Example: generate_map(place="Tokyo Station")
|
|
385
288
|
"""
|
|
386
289
|
has_center = place or (lat is not None and lng is not None)
|
|
387
290
|
has_route_coords = route is not None and route.coords is not None and len(route.coords) >= 2
|
|
@@ -411,8 +314,6 @@ async def generate_map(
|
|
|
411
314
|
body["size"] = {"ew": size_ew, "ns": size_ns}
|
|
412
315
|
if route is not None:
|
|
413
316
|
body["route"] = route.model_dump(by_alias=True, exclude_none=True)
|
|
414
|
-
if config is not None:
|
|
415
|
-
body["config"] = config.model_dump(exclude_none=True)
|
|
416
317
|
|
|
417
318
|
async with httpx.AsyncClient() as client:
|
|
418
319
|
# 1. Enqueue
|
|
@@ -463,26 +364,24 @@ async def generate_map(
|
|
|
463
364
|
async def check_map_status(
|
|
464
365
|
data_key: Annotated[
|
|
465
366
|
str,
|
|
466
|
-
"The dataKey returned by a generate_map call that reported it was still in progress.",
|
|
367
|
+
Field(description="The dataKey returned by a generate_map call that reported it was still in progress."),
|
|
467
368
|
],
|
|
468
369
|
color_set: Annotated[
|
|
469
370
|
str | None,
|
|
470
|
-
"Color theme, matching what generate_map was called with, if any.",
|
|
371
|
+
Field(description="Color theme, matching what generate_map was called with, if any."),
|
|
372
|
+
] = None,
|
|
373
|
+
format: Annotated[Literal["png", "svg"], Field(description="Matching what generate_map was called with.")] = "png",
|
|
374
|
+
canvas_width: Annotated[
|
|
375
|
+
int | None, Field(description="Canvas width, matching what generate_map was called with, if any.")
|
|
376
|
+
] = None,
|
|
377
|
+
canvas_height: Annotated[
|
|
378
|
+
int | None, Field(description="Canvas height, matching what generate_map was called with, if any.")
|
|
471
379
|
] = None,
|
|
472
|
-
format: Annotated[
|
|
473
|
-
str,
|
|
474
|
-
"'png' or 'svg', matching what generate_map was called with.",
|
|
475
|
-
] = "png",
|
|
476
|
-
canvas_width: Annotated[int | None, "Canvas width, matching what generate_map was called with, if any."] = None,
|
|
477
|
-
canvas_height: Annotated[int | None, "Canvas height, matching what generate_map was called with, if any."] = None,
|
|
478
380
|
ctx: Context = None,
|
|
479
381
|
) -> list:
|
|
480
|
-
"""
|
|
382
|
+
"""Poll a pending generate_map job and download it once ready. Wait ~20-30s between calls.
|
|
481
383
|
|
|
482
|
-
|
|
483
|
-
dataKey to check. Wait about 20-30 seconds between calls to this tool — do not call
|
|
484
|
-
it in a tight loop, and do not call generate_map again for the same location while a
|
|
485
|
-
job with this dataKey is still pending; that just starts a redundant duplicate job.
|
|
384
|
+
Example: check_map_status(data_key="20260618aBcDeFgHiJ")
|
|
486
385
|
"""
|
|
487
386
|
async with httpx.AsyncClient() as client:
|
|
488
387
|
# 連打されても機械的に間隔が空くようにする最低限のスロットル
|
|
@@ -511,39 +410,22 @@ async def check_map_status(
|
|
|
511
410
|
|
|
512
411
|
@mcp.tool()
|
|
513
412
|
async def redownload_map(
|
|
514
|
-
data_key: Annotated[
|
|
515
|
-
str,
|
|
516
|
-
"The dataKey returned by a previous generate_map call (e.g. '20260618aBcDeFgHiJ'). "
|
|
517
|
-
"The map data is reused — no regeneration occurs.",
|
|
518
|
-
],
|
|
413
|
+
data_key: Annotated[str, Field(description="The dataKey returned by a previous generate_map call.")],
|
|
519
414
|
color_set: Annotated[
|
|
520
415
|
str | None,
|
|
521
|
-
"Color theme for the
|
|
522
|
-
"Available: white, darkBlue, darkGreen, popArt, lightBlue, lightGreen, beige, magenta, gray, black, brawn.",
|
|
523
|
-
] = None,
|
|
524
|
-
format: Annotated[
|
|
525
|
-
str,
|
|
526
|
-
"'png' (raster) or 'svg' (vector, infinitely scalable).",
|
|
527
|
-
] = "png",
|
|
528
|
-
canvas_width: Annotated[int | None, "Canvas width in pixels. Omit to use server default (1000)."] = None,
|
|
529
|
-
canvas_height: Annotated[int | None, "Canvas height in pixels. Omit to use server default (600)."] = None,
|
|
530
|
-
edge_weight: Annotated[
|
|
531
|
-
int | None,
|
|
532
|
-
"Road and line width adjustment. Positive values thicken lines, negative values thin them. "
|
|
533
|
-
"Default 0 (no adjustment).",
|
|
416
|
+
Field(description="Color theme — see server instructions for the list. Only set when explicitly requested."),
|
|
534
417
|
] = None,
|
|
418
|
+
format: Annotated[Literal["png", "svg"], Field(description="'png' (raster) or 'svg' (vector).")] = "png",
|
|
419
|
+
canvas_width: Annotated[int | None, Field(description="Canvas width in pixels (default 1000).")] = None,
|
|
420
|
+
canvas_height: Annotated[int | None, Field(description="Canvas height in pixels (default 600).")] = None,
|
|
535
421
|
) -> list:
|
|
536
|
-
"""Re-download a
|
|
422
|
+
"""Re-download a prior map in a different color theme, format, or size — instant, no regeneration.
|
|
537
423
|
|
|
538
|
-
|
|
539
|
-
so this is instant. Use this when the user wants to:
|
|
540
|
-
- Try a different color theme (e.g. 'black' for dark mode, 'lightBlue', 'popArt')
|
|
541
|
-
- Get an SVG version of a map already generated as PNG
|
|
542
|
-
- Get a larger or smaller canvas size
|
|
424
|
+
Example: redownload_map(data_key="20260618aBcDeFgHiJ", color_set="black")
|
|
543
425
|
"""
|
|
544
426
|
async with httpx.AsyncClient() as client:
|
|
545
427
|
image_bytes = await _download(client, data_key, format, color_set,
|
|
546
|
-
canvas_width, canvas_height
|
|
428
|
+
canvas_width, canvas_height)
|
|
547
429
|
|
|
548
430
|
out_path = _make_filename(data_key, format)
|
|
549
431
|
out_path.write_bytes(image_bytes)
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "mapnetwork-mcp"
|
|
3
|
-
version = "
|
|
3
|
+
version = "2.0.0"
|
|
4
4
|
description = "MCP server — generate styled map images via mapnetwork.app"
|
|
5
5
|
readme = "README.md"
|
|
6
|
+
license = "MIT"
|
|
7
|
+
license-files = ["LICENSE"]
|
|
6
8
|
requires-python = ">=3.11"
|
|
7
9
|
dependencies = [
|
|
8
10
|
# mcp 2.0.0はmcp.server.fastmcp(Context/FastMCP/Image)を含む破壊的変更が入っており、
|
|
@@ -26,5 +28,7 @@ exclude = ["/.idea", "/dist", "__pycache__", "/mcp-publisher*.exe", "/server.jso
|
|
|
26
28
|
exclude = ["/.idea", "__pycache__"]
|
|
27
29
|
|
|
28
30
|
[build-system]
|
|
29
|
-
|
|
31
|
+
# hatchling>=1.32はMetadata-Version 2.5を出力するが、現行のpackaging/twineが
|
|
32
|
+
# まだ認識せず"twine check"が壊れる(2.4を出力する1.31系に固定して回避)
|
|
33
|
+
requires = ["hatchling<1.32"]
|
|
30
34
|
build-backend = "hatchling.build"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|