mapnetwork-mcp 1.2.3__tar.gz → 3.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.
@@ -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: 1.2.3
3
+ Version: 3.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. **Build the PyPI package**
16
- ```bash
17
- rm -f dist/*.whl dist/*.tar.gz
18
- .venv/Scripts/python -m build
19
- .venv/Scripts/python -m twine check dist/mapnetwork_mcp-<version>*
20
- ```
21
- Use the version-specific glob, not `dist/*` — a leftover `.mcpb` from a
22
- previous release sits in the same `dist/` folder and `twine check` errors
23
- out on it ("Unknown distribution format") even though the actual wheel/
24
- sdist are fine.
25
-
26
- 3. **Upload to PyPI**
27
- ```bash
28
- .venv/Scripts/python -m twine upload --disable-progress-bar dist/mapnetwork_mcp-<version>*
29
- ```
30
- Requires a PyPI API token (via `~/.pypirc` or `TWINE_USERNAME=__token__` / `TWINE_PASSWORD=...`).
31
-
32
- ⚠️ On Windows, omitting `--disable-progress-bar` can crash twine with
33
- `UnicodeEncodeError: 'cp932' codec can't encode character '•'`
34
- (the legacy console can't render `rich`'s progress-bar glyphs). The crash
35
- happens in the display code, not the upload itself, so **check whether the
36
- upload actually went through before retrying** — re-uploading a version
37
- that already landed is rejected by PyPI:
38
- ```bash
39
- curl -s https://pypi.org/pypi/mapnetwork-mcp/json | grep -o '"<version>"'
40
- ```
41
-
42
- 4. **Publish to the MCP registry**
43
- ```bash
44
- ./mcp-publisher.exe validate server.json
45
- ./mcp-publisher.exe login github # only needed if the session expired
46
- ./mcp-publisher.exe publish server.json
47
- ```
48
- The registry entry's `packages[0].version` must match the version actually live on PyPI (the registry does not host the code itself).
49
-
50
- ⚠️ `login github` opens an interactive device-confirmation flow in the
51
- browser — it cannot be automated or run on someone's behalf. Run it
52
- yourself in your own terminal (not delegated to an agent) and confirm
53
- it's done before continuing to `publish`.
54
-
55
- 5. **Rebuild the MCPB bundle**
56
- ```bash
57
- npx --yes @anthropic-ai/mcpb validate manifest.json
58
- npx --yes @anthropic-ai/mcpb pack . dist/mapnetwork-mcp.mcpb
59
- ```
60
- The output filename is literally `mapnetwork-mcp.mcpb` — **not**
61
- version-suffixed (the `mcpb pack` tool's own summary output shows a
62
- version-suffixed "Archive Details > filename" field, which is just a
63
- display label and does not match the actual file written to disk). Use
64
- `dist/mapnetwork-mcp.mcpb` verbatim in step 7, not a guessed
65
- `mapnetwork-mcp-<version>.mcpb`.
66
-
67
- 6. **Commit, tag, and push**
68
- ```bash
69
- git add pyproject.toml server.json manifest.json mapnetwork_mcp/server.py # plus any other source files changed for this release
70
- git commit -m "Bump version to <version>"
71
- git push origin main
72
- git tag -a v<version> -m "v<version>"
73
- git push origin v<version>
74
- ```
75
-
76
- 7. **Create the GitHub Release** with the `.mcpb` bundle attached
77
- ```bash
78
- gh release create v<version> dist/mapnetwork-mcp.mcpb --title "v<version>" --notes "..."
79
- ```
80
-
81
- ## Notes
82
-
83
- - `.mcpregistry_github_token` / `.mcpregistry_registry_token` hold the `mcp-publisher` login session — they are git-ignored and must never be committed.
84
- - `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
85
- previous release aren't cleaned up automatically (step 2 only removes
86
- `*.whl`/`*.tar.gz`) — the stray `.mcpb` from the last run stays there, which
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.
@@ -0,0 +1,22 @@
1
+ # Security Policy
2
+
3
+ ## Supported Versions
4
+
5
+ Only the latest major version receives security fixes.
6
+
7
+ | Version | Supported |
8
+ | ------- | ------------------ |
9
+ | 2.x | :white_check_mark: |
10
+ | < 2.0 | :x: |
11
+
12
+ ## Reporting a Vulnerability
13
+
14
+ Please report security vulnerabilities privately through
15
+ [GitHub Private Vulnerability Reporting](https://github.com/toruproject/mapnetwork-mcp/security/advisories/new).
16
+ This opens a private advisory visible only to the maintainer and you, so the
17
+ issue is not disclosed publicly before a fix is available.
18
+
19
+ Do not report security vulnerabilities through public GitHub issues.
20
+
21
+ We aim to respond as quickly as possible on a best-effort basis; we do not
22
+ currently commit to a fixed response-time SLA.
@@ -2,7 +2,7 @@
2
2
  "manifest_version": "0.4",
3
3
  "name": "mapnetwork-mcp",
4
4
  "display_name": "MapNetwork",
5
- "version": "1.2.3",
5
+ "version": "3.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": {
@@ -22,20 +22,9 @@ INITIAL_WAIT_SEC = 40.0
22
22
  # check_map_statusをモデルが連打しても機械的に間隔が空くようにする最低待機時間
23
23
  CHECK_THROTTLE_SEC = 5.0
24
24
 
25
- # layersは自由な多値配列にすると、モデルが「roadはhighway/driving/walkingの上位互換」
26
- # といった内部の組み合わせルールを知らないまま組み合わせを選んでしまう。
27
- # 人間側で意味のある4パターンだけに絞り込み、モデルにはこのプリセット名だけを選ばせる。
28
- _LAYER_PRESETS: dict[str, list[str]] = {
29
- "default": ["road", "poi"],
30
- "road_and_railway": ["road", "railway", "poi"],
31
- "only_driving_road": ["driving"],
32
- "fully_detailed": ["road", "railway", "poi", "waterline", "greenarea"],
33
- }
34
-
35
-
36
25
  class Location(BaseModel):
37
- lat: float
38
- lng: float
26
+ lat: float = Field(description="Latitude.")
27
+ lng: float = Field(description="Longitude.")
39
28
 
40
29
 
41
30
  class Marker(BaseModel):
@@ -58,44 +47,35 @@ class RouteInput(BaseModel):
58
47
  coords: list[list[float]] | None = Field(
59
48
  default=None, description="Ordered list of [lat, lng] pairs along the route."
60
49
  )
61
- mode: Literal["walking", "driving"] | None = None
50
+ mode: Literal["walking", "driving"] | None = Field(default=None, description="'walking' or 'driving'.")
62
51
  from_: RouteEndpoint | None = Field(default=None, alias="from", description="Route start point.")
63
52
  to: RouteEndpoint | None = Field(default=None, description="Route end point.")
64
53
  color: str | None = Field(default=None, description="Optional line color as a CSS hex color (e.g. '#FF4500').")
65
54
 
66
55
 
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
56
  mcp = FastMCP(
81
57
  "MapNetwork",
82
58
  instructions=(
83
59
  "You have access to MapNetwork, which generates styled map images (PNG or SVG) "
84
60
  "for any location on Earth.\n\n"
85
61
  "## Key capabilities\n"
86
- "- **Single location**: pass `place` (geocoded server-side) or `lat`/`lng` as the map center\n"
62
+ "- **Single location**: pass `place` (geocoded server-side). If you already know the "
63
+ "coordinates, pair it with `location` ({lat, lng}) to skip geocoding — same pattern as a "
64
+ "marker's `label`+`location`. `location` alone (without `place`) also works, but places no "
65
+ "labeled pin. `location` is not necessarily the final map center — see below.\n"
87
66
  "- **Multiple locations**: pass `markers` — a list of places to pin on the map. "
88
- "Each marker needs only a `label` (geocoded automatically); explicit `lat`/`lng` is optional. "
89
- "When `markers` are given without a `place`/`lat`/`lng` center, the server derives the center "
90
- "from the centroid of the markers and sets the radius automatically (1.2× farthest marker distance). "
67
+ "Each marker needs only a `label` (geocoded automatically); explicit `location` is optional. "
91
68
  "Use this whenever the user asks to show multiple places on a single map.\n"
92
- "- **Circular area**: specify `radius` in meters (default 500, max 2500) around the center\n"
93
- "- **Rectangular area**: specify `size_ew` (east-west) and `size_ns` (north-south) in meters "
94
- "instead of radius — useful when the area of interest is not square\n"
95
- "- **Layers**: choose a preset via `layers` — 'default' (roads + POI), "
96
- "'only_driving_road' (car-accessible roads only), 'road_and_railway' (roads + railway, no POI), "
97
- "or 'fully_detailed' (roads + railway + waterline + greenarea + POI; waterline/greenarea only "
98
- "apply within Japan). Omit for 'default'.\n"
69
+ "- **Map shape and size are fully automatic**: with a single input location (`place`/`location`, "
70
+ "or one marker), the server centers a circular map on it with a small default radius. "
71
+ "With multiple input locations (`markers`, or a `route`), the server fits a rectangle (or square) "
72
+ "around all of them, and the center becomes the midpoint of that rectangle — not any single "
73
+ "input coordinate. There is no way to manually set the radius or rectangle size (the exact "
74
+ "defaults and limits are server-side details that may change).\n"
75
+ "- **Layers are fully automatic**: roads and POI icons are always included. The server picks "
76
+ "walkable roads vs. car-only roads based on the route or the map's east-west extent, and adds "
77
+ "railway/waterline/aerialway layers automatically when POIs like stations, harbours, beaches, or "
78
+ "ropeways are detected nearby (Japan only). There is no way to manually choose layers.\n"
99
79
  "- **Color themes** via `color_set`: "
100
80
  "white (clean, default), darkBlue (navy bg), darkGreen (dark teal bg), "
101
81
  "popArt (blue bg, bold contrast), lightBlue (pale blue bg), lightGreen (pale green bg), "
@@ -130,10 +110,8 @@ mcp = FastMCP(
130
110
  "Mention this when relevant, but do not ask the user unprompted. "
131
111
  "Only set color_set when the user explicitly requests a theme.\n\n"
132
112
  "## Parameter discipline\n"
133
- "- **lat/lng**: Never guess or estimate coordinates from training data. "
134
- "If the location is known only by name, use `place` and let the server geocode it.\n"
135
- "- **radius / size_ew / size_ns**: Do not set these unless the user has explicitly asked for "
136
- "a specific map range or shape. Omit them to let the server apply its default (500 m radius)."
113
+ "- **location**: Never guess or estimate coordinates from training data. "
114
+ "If the location is known only by name, use `place` and let the server geocode it."
137
115
  ),
138
116
  )
139
117
 
@@ -150,8 +128,7 @@ def _make_filename(label: str, format: str) -> Path:
150
128
 
151
129
 
152
130
  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:
131
+ color_set: str | None, canvas_width: int | None, canvas_height: int | None) -> bytes:
155
132
  params: dict = {"dataKey": data_key, "format": format}
156
133
  if color_set is not None:
157
134
  params["colorSet"] = color_set
@@ -159,8 +136,6 @@ async def _download(client: httpx.AsyncClient, data_key: str, format: str,
159
136
  params["canvasWidth"] = canvas_width
160
137
  if canvas_height is not None:
161
138
  params["canvasHeight"] = canvas_height
162
- if edge_weight is not None:
163
- params["edgeWeight"] = edge_weight
164
139
  resp = await client.get(f"{BASE_URL}/download", params=params, timeout=60)
165
140
  if resp.status_code != 200:
166
141
  raise RuntimeError(f"Download failed ({resp.status_code}): {resp.text}")
@@ -224,34 +199,15 @@ def _still_in_progress_result(data_key: str) -> list:
224
199
  @mcp.tool()
225
200
  async def compute_route(
226
201
  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\": \"赤坂駅\"}",
231
- ],
232
- to_location: Annotated[
233
- RouteEndpoint,
234
- "End point of the route. Same format as from_location. "
235
- "Example: {\"label\": \"赤坂氷川神社\"}",
202
+ RouteEndpoint, Field(description="Route start. 'location' for coordinates, or 'label' to geocode.")
236
203
  ],
237
- mode: Annotated[
238
- str,
239
- "Routing mode: 'walking' (default, footpaths and streets) or 'driving' (car-accessible roads).",
240
- ] = "walking",
204
+ to_location: Annotated[RouteEndpoint, Field(description="Route end. Same format as from_location.")],
205
+ mode: Annotated[Literal["walking", "driving"], Field(description="Default 'walking'.")] = "walking",
241
206
  ) -> dict:
242
- """Compute a walking or driving route between two locations.
243
-
244
- Returns the route as an ordered list of coordinates, plus the resolved from/to locations.
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.
207
+ """Compute a route. Returns {coords, from, to} — pass directly to generate_map(route=...).
247
208
 
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"]], ...)
209
+ Example: compute_route(from_location={"label": "Tokyo Station"}, to_location={"label": "Tokyo Tower"})
251
210
  """
252
- if mode not in ("walking", "driving"):
253
- raise ValueError("mode must be 'walking' or 'driving'")
254
-
255
211
  body = {
256
212
  "from": from_location.model_dump(exclude_none=True),
257
213
  "to": to_location.model_dump(exclude_none=True),
@@ -279,140 +235,52 @@ async def compute_route(
279
235
  @mcp.tool()
280
236
  async def generate_map(
281
237
  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.",
238
+ str | None, Field(description="Place name to center the map on (geocoded server-side unless 'location' is also given).")
286
239
  ] = 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.",
313
- ] = None,
314
- radius: Annotated[
315
- int | None,
316
- "Circular coverage radius in meters (max 2500). "
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).",
320
- ] = None,
321
- size_ew: Annotated[
322
- float | None,
323
- "East-west width of a rectangular coverage area in meters. "
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.",
327
- ] = None,
328
- size_ns: Annotated[
329
- float | None,
330
- "North-south height of a rectangular coverage area in meters. "
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.",
333
- ] = None,
334
- layers: Annotated[
335
- Literal["default", "road_and_railway", "only_driving_road", "fully_detailed"] | None,
336
- "Preset combination of map layers. 'default': roads + POI icons. "
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'.",
240
+ location: Annotated[
241
+ Location | None,
242
+ Field(description="Explicit coordinates for 'place'. If given, geocoding of 'place' is skipped. Not necessarily the map's final center — see server instructions."),
342
243
  ] = None,
244
+ markers: Annotated[list[Marker] | None, Field(description="Locations to pin on the map.")] = None,
245
+ name: Annotated[str | None, Field(description="Map name stored in the data file.")] = None,
343
246
  route: Annotated[
344
247
  RouteInput | None,
345
- "Route to overlay on the map. Pass the full response from compute_route() directly — "
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}.",
248
+ Field(description="Route to overlay — pass compute_route()'s result directly. Add/override 'color' (hex) to customize."),
354
249
  ] = None,
355
250
  color_set: Annotated[
356
251
  str | None,
357
- "Color theme for the map. Only set when the user explicitly requests one. "
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.",
252
+ Field(description="Color theme name — see server instructions for the list. Only set when explicitly requested."),
361
253
  ] = None,
362
- format: Annotated[
363
- str,
364
- "Output file format: 'png' (default, raster image) or 'svg' (vector, scalable to any size).",
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,
254
+ format: Annotated[Literal["png", "svg"], Field(description="'png' (default) or 'svg'.")] = "png",
255
+ canvas_width: Annotated[int | None, Field(description="Canvas width in pixels (default 1000).")] = None,
256
+ canvas_height: Annotated[int | None, Field(description="Canvas height in pixels (default 600).")] = None,
368
257
  ctx: Context = None,
369
258
  ) -> list:
370
- """Generate a styled map image for a given location and save it to Downloads.
259
+ """Generate a styled map image and save it to Downloads.
371
260
 
372
- Coverage shape:
373
- - Default (no radius, no size): circular 500 m radius
374
- - radius=N: circular, N meters
375
- - size_ew + size_ns: rectangular bounding box
261
+ May return a pending dataKey instead of the image — see server instructions for the
262
+ check_map_status follow-up flow.
376
263
 
377
- After generation the dataKey is returned in the text result.
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.
264
+ Example: generate_map(place="Tokyo Station")
385
265
  """
386
- has_center = place or (lat is not None and lng is not None)
266
+ has_center = place or location is not None
387
267
  has_route_coords = route is not None and route.coords is not None and len(route.coords) >= 2
388
268
  if not has_center and not markers and not has_route_coords:
389
- raise ValueError("Specify 'place', both 'lat'+'lng', 'markers', or a 'route' with coords.")
390
- if radius is not None and (size_ew is not None or size_ns is not None):
391
- raise ValueError("Specify either 'radius' or 'size_ew'+'size_ns', not both.")
392
- if (size_ew is None) != (size_ns is None):
393
- raise ValueError("'size_ew' and 'size_ns' must be specified together.")
269
+ raise ValueError("Specify 'place', 'location', 'markers', or a 'route' with coords.")
394
270
 
395
271
  body: dict = {}
396
- if layers is not None:
397
- body["layers"] = _LAYER_PRESETS[layers]
398
272
  if place:
399
273
  body["place"] = place
400
- elif lat is not None and lng is not None:
401
- body["center"] = {"lat": lat, "lng": lng}
274
+ if location is not None:
275
+ body["center"] = location.model_dump()
402
276
  if markers is not None:
403
277
  body["markers"] = [m.model_dump(exclude_none=True) for m in markers]
404
278
  if name is not None:
405
279
  body["name"] = name
406
280
  if color_set is not None:
407
281
  body["colorSet"] = color_set
408
- if radius is not None:
409
- body["radius"] = radius
410
- elif size_ew is not None:
411
- body["size"] = {"ew": size_ew, "ns": size_ns}
412
282
  if route is not None:
413
283
  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
284
 
417
285
  async with httpx.AsyncClient() as client:
418
286
  # 1. Enqueue
@@ -435,7 +303,7 @@ async def generate_map(
435
303
  if status == "failed":
436
304
  raise RuntimeError(
437
305
  f"Map generation failed (dataKey={data_key}). "
438
- "Try a different location or smaller radius."
306
+ "Try a different location."
439
307
  )
440
308
  if status == "pending":
441
309
  return _still_in_progress_result(data_key)
@@ -446,8 +314,8 @@ async def generate_map(
446
314
 
447
315
  if place:
448
316
  label = place
449
- elif lat is not None and lng is not None:
450
- label = f"{lat}_{lng}"
317
+ elif location is not None:
318
+ label = f"{location.lat}_{location.lng}"
451
319
  elif markers:
452
320
  label = "_".join(m.label or "" for m in markers)[:40]
453
321
  else:
@@ -463,26 +331,24 @@ async def generate_map(
463
331
  async def check_map_status(
464
332
  data_key: Annotated[
465
333
  str,
466
- "The dataKey returned by a generate_map call that reported it was still in progress.",
334
+ Field(description="The dataKey returned by a generate_map call that reported it was still in progress."),
467
335
  ],
468
336
  color_set: Annotated[
469
337
  str | None,
470
- "Color theme, matching what generate_map was called with, if any.",
338
+ Field(description="Color theme, matching what generate_map was called with, if any."),
339
+ ] = None,
340
+ format: Annotated[Literal["png", "svg"], Field(description="Matching what generate_map was called with.")] = "png",
341
+ canvas_width: Annotated[
342
+ int | None, Field(description="Canvas width, matching what generate_map was called with, if any.")
343
+ ] = None,
344
+ canvas_height: Annotated[
345
+ int | None, Field(description="Canvas height, matching what generate_map was called with, if any.")
471
346
  ] = 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
347
  ctx: Context = None,
479
348
  ) -> list:
480
- """Check whether a still-in-progress generate_map job has finished, and download it if so.
349
+ """Poll a pending generate_map job and download it once ready. Wait ~20-30s between calls.
481
350
 
482
- Only call this after generate_map reports it is still processing and gives you a
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.
351
+ Example: check_map_status(data_key="20260618aBcDeFgHiJ")
486
352
  """
487
353
  async with httpx.AsyncClient() as client:
488
354
  # 連打されても機械的に間隔が空くようにする最低限のスロットル
@@ -492,7 +358,7 @@ async def check_map_status(
492
358
  if status == "failed":
493
359
  raise RuntimeError(
494
360
  f"Map generation failed (dataKey={data_key}). "
495
- "Try a different location or smaller radius."
361
+ "Try a different location."
496
362
  )
497
363
  if status != "ready":
498
364
  if ctx is not None:
@@ -511,39 +377,22 @@ async def check_map_status(
511
377
 
512
378
  @mcp.tool()
513
379
  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
- ],
380
+ data_key: Annotated[str, Field(description="The dataKey returned by a previous generate_map call.")],
519
381
  color_set: Annotated[
520
382
  str | None,
521
- "Color theme for the map. Only set when the user explicitly requests one. "
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).",
383
+ Field(description="Color theme — see server instructions for the list. Only set when explicitly requested."),
534
384
  ] = None,
385
+ format: Annotated[Literal["png", "svg"], Field(description="'png' (raster) or 'svg' (vector).")] = "png",
386
+ canvas_width: Annotated[int | None, Field(description="Canvas width in pixels (default 1000).")] = None,
387
+ canvas_height: Annotated[int | None, Field(description="Canvas height in pixels (default 600).")] = None,
535
388
  ) -> list:
536
- """Re-download a previously generated map with a different color theme or format.
389
+ """Re-download a prior map in a different color theme, format, or size — instant, no regeneration.
537
390
 
538
- Uses the dataKey from a prior generate_map call. The map data is NOT regenerated,
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
391
+ Example: redownload_map(data_key="20260618aBcDeFgHiJ", color_set="black")
543
392
  """
544
393
  async with httpx.AsyncClient() as client:
545
394
  image_bytes = await _download(client, data_key, format, color_set,
546
- canvas_width, canvas_height, edge_weight)
395
+ canvas_width, canvas_height)
547
396
 
548
397
  out_path = _make_filename(data_key, format)
549
398
  out_path.write_bytes(image_bytes)
@@ -1,8 +1,10 @@
1
1
  [project]
2
2
  name = "mapnetwork-mcp"
3
- version = "1.2.3"
3
+ version = "3.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
- requires = ["hatchling"]
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"
@@ -0,0 +1,158 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "title": "MapNetwork MCP - 入力JSON仕様",
4
+ "description": "mapnetwork_mcp/server.py で定義されている4つのMCPツールの入力パラメータ仕様。各属性の型・デフォルト値・設定可能値(enum)・制約を示す。",
5
+ "definitions": {
6
+ "Location": {
7
+ "type": "object",
8
+ "description": "明示的な緯度経度座標",
9
+ "properties": {
10
+ "lat": { "type": "number", "description": "緯度" },
11
+ "lng": { "type": "number", "description": "経度" }
12
+ },
13
+ "required": ["lat", "lng"]
14
+ },
15
+ "Marker": {
16
+ "type": "object",
17
+ "description": "地図上にピン留めする地点",
18
+ "properties": {
19
+ "label": { "type": ["string", "null"], "default": null, "description": "地名(ジオコーディング・表示用)" },
20
+ "location": { "oneOf": [{ "$ref": "#/definitions/Location" }, { "type": "null" }], "default": null, "description": "明示的な座標。指定するとlabelのジオコーディングは省略される" }
21
+ }
22
+ },
23
+ "RouteEndpoint": {
24
+ "type": "object",
25
+ "description": "ルートの始点/終点",
26
+ "properties": {
27
+ "label": { "type": ["string", "null"], "default": null, "description": "地名(ジオコーディング・表示用)" },
28
+ "location": { "oneOf": [{ "$ref": "#/definitions/Location" }, { "type": "null" }], "default": null, "description": "明示的な座標" }
29
+ }
30
+ },
31
+ "RouteInput": {
32
+ "type": "object",
33
+ "description": "generate_mapのrouteパラメータ。compute_routeの戻り値をそのまま渡せる",
34
+ "properties": {
35
+ "coords": {
36
+ "type": ["array", "null"],
37
+ "default": null,
38
+ "description": "ルート上の[lat, lng]座標列",
39
+ "items": { "type": "array", "items": { "type": "number" }, "minItems": 2, "maxItems": 2 }
40
+ },
41
+ "mode": { "oneOf": [{ "type": "string", "enum": ["walking", "driving"] }, { "type": "null" }], "default": null },
42
+ "from": { "oneOf": [{ "$ref": "#/definitions/RouteEndpoint" }, { "type": "null" }], "default": null, "description": "ルート始点" },
43
+ "to": { "oneOf": [{ "$ref": "#/definitions/RouteEndpoint" }, { "type": "null" }], "default": null, "description": "ルート終点" },
44
+ "color": { "type": ["string", "null"], "default": null, "description": "ルート線の色(CSS16進カラー、例: '#FF4500')" }
45
+ }
46
+ },
47
+ "ColorSet": {
48
+ "type": "string",
49
+ "description": "カラーテーマ",
50
+ "enum": ["white", "darkBlue", "darkGreen", "popArt", "lightBlue", "lightGreen", "beige", "magenta", "gray", "black", "brawn"],
51
+ "default": "white"
52
+ },
53
+ "Format": {
54
+ "type": "string",
55
+ "enum": ["png", "svg"],
56
+ "default": "png"
57
+ }
58
+ },
59
+ "tools": {
60
+ "generate_map": {
61
+ "description": "指定した場所のスタイル付き地図画像を生成し、Downloadsフォルダに保存する",
62
+ "type": "object",
63
+ "properties": {
64
+ "place": { "type": ["string", "null"], "default": null, "description": "地図に表示する地名。locationが未指定ならサーバー側でジオコーディングする" },
65
+ "location": {
66
+ "oneOf": [{ "$ref": "#/definitions/Location" }, { "type": "null" }],
67
+ "default": null,
68
+ "description": "placeの明示的な座標。指定するとplaceのジオコーディングは省略される(Markerのlabel+locationと同じパターン)。locationのみの指定も可能(ただしその場合ピンは表示されない)。地図の最終的な中心(center)と必ずしも一致しない点に注意(markers/routeで複数座標がある場合、centerはそれらを包含する範囲の中点になる)"
69
+ },
70
+ "markers": {
71
+ "type": ["array", "null"],
72
+ "default": null,
73
+ "description": "地図上にピン留めする地点リスト",
74
+ "items": { "$ref": "#/definitions/Marker" }
75
+ },
76
+ "name": { "type": ["string", "null"], "default": null, "description": "データファイルに保存する地図名" },
77
+ "route": {
78
+ "oneOf": [{ "$ref": "#/definitions/RouteInput" }, { "type": "null" }],
79
+ "default": null,
80
+ "description": "地図に重ねるルート。compute_routeの戻り値をそのまま渡せる"
81
+ },
82
+ "color_set": {
83
+ "oneOf": [{ "$ref": "#/definitions/ColorSet" }, { "type": "null" }],
84
+ "default": null,
85
+ "description": "カラーテーマ。ユーザーが明示的に要求した場合のみ設定"
86
+ },
87
+ "format": { "allOf": [{ "$ref": "#/definitions/Format" }], "description": "出力形式" },
88
+ "canvas_width": { "type": ["integer", "null"], "default": null, "description": "キャンバス幅(ピクセル)。未指定時サーバー側デフォルト1000" },
89
+ "canvas_height": { "type": ["integer", "null"], "default": null, "description": "キャンバス高さ(ピクセル)。未指定時サーバー側デフォルト600" }
90
+ },
91
+ "constraints": [
92
+ "place / location / markers / route.coords(2点以上) のいずれか1つ以上を指定する必要がある",
93
+ "地図の形状・サイズ(円形/矩形)、および取得レイヤー(道路・POI・鉄道・水域・索道)はサーバー側で入力座標から自動決定され、手動指定はできない。入力座標が1点のみなら円形、2点以上ならそれらを包含する矩形(または正方形)になる。具体的な半径・サイズの初期値や上限はサーバー側の実装詳細であり、将来変更されうる"
94
+ ],
95
+ "example": { "place": "Tokyo Station" }
96
+ },
97
+ "compute_route": {
98
+ "description": "2地点間の徒歩/車ルートを計算する。戻り値はgenerate_mapのrouteパラメータにそのまま渡せる",
99
+ "type": "object",
100
+ "properties": {
101
+ "from_location": {
102
+ "allOf": [{ "$ref": "#/definitions/RouteEndpoint" }],
103
+ "description": "ルート始点。'location'で座標指定、または'label'でジオコーディング",
104
+ "required": true
105
+ },
106
+ "to_location": {
107
+ "allOf": [{ "$ref": "#/definitions/RouteEndpoint" }],
108
+ "description": "ルート終点。from_locationと同じ形式",
109
+ "required": true
110
+ },
111
+ "mode": {
112
+ "allOf": [{ "type": "string", "enum": ["walking", "driving"] }],
113
+ "default": "walking",
114
+ "description": "移動手段"
115
+ }
116
+ },
117
+ "required": ["from_location", "to_location"],
118
+ "example": {
119
+ "from_location": { "label": "Tokyo Station" },
120
+ "to_location": { "label": "Tokyo Tower" }
121
+ }
122
+ },
123
+ "check_map_status": {
124
+ "description": "generate_mapが未完了(pending)を返した場合のジョブをポーリングし、完了していればダウンロードする",
125
+ "type": "object",
126
+ "properties": {
127
+ "data_key": { "type": "string", "description": "generate_mapが返したdataKey", "required": true },
128
+ "color_set": {
129
+ "oneOf": [{ "$ref": "#/definitions/ColorSet" }, { "type": "null" }],
130
+ "default": null,
131
+ "description": "generate_map呼び出し時と同じ値を指定"
132
+ },
133
+ "format": { "allOf": [{ "$ref": "#/definitions/Format" }], "description": "generate_map呼び出し時と同じ値を指定" },
134
+ "canvas_width": { "type": ["integer", "null"], "default": null, "description": "generate_map呼び出し時と同じ値を指定" },
135
+ "canvas_height": { "type": ["integer", "null"], "default": null, "description": "generate_map呼び出し時と同じ値を指定" }
136
+ },
137
+ "required": ["data_key"],
138
+ "example": { "data_key": "20260618aBcDeFgHiJ" }
139
+ },
140
+ "redownload_map": {
141
+ "description": "生成済みの地図を、再生成せずに別のカラーテーマ/形式/サイズで再ダウンロードする",
142
+ "type": "object",
143
+ "properties": {
144
+ "data_key": { "type": "string", "description": "以前のgenerate_map呼び出しが返したdataKey", "required": true },
145
+ "color_set": {
146
+ "oneOf": [{ "$ref": "#/definitions/ColorSet" }, { "type": "null" }],
147
+ "default": null,
148
+ "description": "ユーザーが明示的に要求した場合のみ設定"
149
+ },
150
+ "format": { "allOf": [{ "$ref": "#/definitions/Format" }], "description": "'png'(ラスター)または'svg'(ベクター)" },
151
+ "canvas_width": { "type": ["integer", "null"], "default": null, "description": "キャンバス幅(ピクセル)。未指定時サーバー側デフォルト1000" },
152
+ "canvas_height": { "type": ["integer", "null"], "default": null, "description": "キャンバス高さ(ピクセル)。未指定時サーバー側デフォルト600" }
153
+ },
154
+ "required": ["data_key"],
155
+ "example": { "data_key": "20260618aBcDeFgHiJ", "color_set": "black" }
156
+ }
157
+ }
158
+ }
File without changes
File without changes