mapnetwork-mcp 5.0.0__tar.gz → 6.1.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.
Files changed (22) hide show
  1. mapnetwork_mcp-6.1.0/LOCALTEST.md +62 -0
  2. {mapnetwork_mcp-5.0.0 → mapnetwork_mcp-6.1.0}/PKG-INFO +14 -14
  3. {mapnetwork_mcp-5.0.0 → mapnetwork_mcp-6.1.0}/README.md +13 -13
  4. {mapnetwork_mcp-5.0.0 → mapnetwork_mcp-6.1.0}/manifest.json +4 -4
  5. {mapnetwork_mcp-5.0.0 → mapnetwork_mcp-6.1.0}/mapnetwork_mcp/server.py +99 -73
  6. {mapnetwork_mcp-5.0.0 → mapnetwork_mcp-6.1.0}/pyproject.toml +1 -1
  7. {mapnetwork_mcp-5.0.0 → mapnetwork_mcp-6.1.0}/spec/input_schema.json +12 -9
  8. {mapnetwork_mcp-5.0.0 → mapnetwork_mcp-6.1.0}/spec/output_schema.json +8 -8
  9. {mapnetwork_mcp-5.0.0 → mapnetwork_mcp-6.1.0}/.github/workflows/workflow.yml +0 -0
  10. {mapnetwork_mcp-5.0.0 → mapnetwork_mcp-6.1.0}/.gitignore +0 -0
  11. {mapnetwork_mcp-5.0.0 → mapnetwork_mcp-6.1.0}/.mcpbignore +0 -0
  12. {mapnetwork_mcp-5.0.0 → mapnetwork_mcp-6.1.0}/LICENSE +0 -0
  13. {mapnetwork_mcp-5.0.0 → mapnetwork_mcp-6.1.0}/RELEASING.md +0 -0
  14. {mapnetwork_mcp-5.0.0 → mapnetwork_mcp-6.1.0}/SECURITY.md +0 -0
  15. {mapnetwork_mcp-5.0.0 → mapnetwork_mcp-6.1.0}/images/Kanazawa21Museum-black.png +0 -0
  16. {mapnetwork_mcp-5.0.0 → mapnetwork_mcp-6.1.0}/images/Kanazawa21Museum-darkGreen.png +0 -0
  17. {mapnetwork_mcp-5.0.0 → mapnetwork_mcp-6.1.0}/images/Kanazawa21Museum-grey.png +0 -0
  18. {mapnetwork_mcp-5.0.0 → mapnetwork_mcp-6.1.0}/images/Kanazawa21Museum-lightGreen.png +0 -0
  19. {mapnetwork_mcp-5.0.0 → mapnetwork_mcp-6.1.0}/images/Kanazawa21Museum-popArt.png +0 -0
  20. {mapnetwork_mcp-5.0.0 → mapnetwork_mcp-6.1.0}/images/Kanazawa21Museum-white.png +0 -0
  21. {mapnetwork_mcp-5.0.0 → mapnetwork_mcp-6.1.0}/mapnetwork_mcp/__init__.py +0 -0
  22. {mapnetwork_mcp-5.0.0 → mapnetwork_mcp-6.1.0}/uv.lock +0 -0
@@ -0,0 +1,62 @@
1
+ # Building a local-test `.mcpb`
2
+
3
+ For testing changes against a local backend (e.g. the `map-network-app-nodejs`
4
+ dev docker-compose stack) before publishing, build a **local-test** `.mcpb`
5
+ bundle instead of the official one. It must never be named or displayed the
6
+ same as the real release — Claude Desktop's extension list identifies
7
+ extensions by `name`/`display_name`, not filename, so both need to differ,
8
+ not just the output path.
9
+
10
+ ## Steps
11
+
12
+ 1. **Temporarily edit `manifest.json`** (under git control, so it's easy to
13
+ revert cleanly):
14
+ - `name`: `mapnetwork-mcp` → `mapnetwork-mcp-localtest`
15
+ - `display_name`: `MapNetwork` → `MapNetwork (Local Test)`
16
+ - Add an `env` block under `server.mcp_config` pointing at the local
17
+ backend:
18
+ ```json
19
+ "mcp_config": {
20
+ "command": "uv",
21
+ "args": ["run", "--directory", "${__dirname}", "mapnetwork_mcp/server.py"],
22
+ "env": {
23
+ "MAPNETWORK_BASE_URL": "http://localhost"
24
+ }
25
+ }
26
+ ```
27
+ Adjust the URL/port to match wherever the local stack's nginx is
28
+ actually listening (see `docker-compose.dev.yml` in
29
+ `map-network-app-nodejs` — by default port 80).
30
+
31
+ 2. **Validate and pack**:
32
+ ```bash
33
+ npx --yes @anthropic-ai/mcpb validate manifest.json
34
+ npx --yes @anthropic-ai/mcpb pack . dist/mapnetwork-mcp-localtest.mcpb
35
+ ```
36
+ The `-localtest` suffix in the output path is not enough by itself (see
37
+ above) — it only matters together with the `name`/`display_name` edit in
38
+ step 1.
39
+
40
+ 3. **Revert `manifest.json`** back to the official version:
41
+ ```bash
42
+ git restore manifest.json
43
+ git status --short # confirm no unintended diff remains
44
+ ```
45
+ The env/name/display_name overrides only need to exist inside the packed
46
+ `.mcpb` (which is git-ignored, `dist/`), not in the committed source.
47
+
48
+ 4. **Load it in Claude Desktop** (drag-and-drop the `.mcpb`, or via the
49
+ Extensions screen). It will show up as a separate "MapNetwork (Local
50
+ Test)" extension, distinct from any installed official "MapNetwork" one.
51
+
52
+ ## Why
53
+
54
+ - `MAPNETWORK_BASE_URL` (read in `mapnetwork_mcp/server.py`) is what points
55
+ the client at a backend other than the default `https://mapnetwork.app`.
56
+ There's no other way to set it for a Claude-Desktop-launched extension —
57
+ it isn't inherited from any project `.env` file, since Claude Desktop
58
+ launches the `uv run ...` subprocess with its own environment, not this
59
+ repo's (or `map-network-app-nodejs`'s) shell/dotenv state.
60
+ - Reusing the official name/filename risks Claude Desktop's extension list
61
+ showing two indistinguishable "MapNetwork" entries, or a locally-packed
62
+ build silently overwriting/being confused with the real release artifact.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mapnetwork-mcp
3
- Version: 5.0.0
3
+ Version: 6.1.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
@@ -17,10 +17,10 @@ MCP server for [MapNetwork](https://mapnetwork.app) — generate styled map imag
17
17
 
18
18
  ## Features
19
19
 
20
- - Generate maps from a place name, coordinates, or a list of markers
21
- - 11 color themes (white, darkBlue, darkGreen, popArt, lightBlue, lightGreen, beige, magenta, gray, black, brawn)
22
- - Overlay walking / driving routes on the map
20
+ - Generate maps from a place name, a list of markers, or a walking/driving route
21
+ - 11 color themes (white, darkBlue, darkGreen, popArt, lightBlue, lightGreen, beige, magenta, gray, black, brown)
23
22
  - PNG or SVG output, saved to your Downloads folder
23
+ - Slow-to-generate maps are handled automatically — `generate_*` tools poll internally, and `download_map` can pick up a job later if needed
24
24
  - Re-download a previously generated map in a different theme or format without regenerating
25
25
  - Open any generated map in the MapNetwork web editor for manual customization
26
26
 
@@ -61,7 +61,7 @@ Add the following to your `claude_desktop_config.json`:
61
61
  "mapnetwork": {
62
62
  "command": "uvx",
63
63
  "args": ["mapnetwork-mcp"],
64
- "alwaysAllow": ["generate_map", "compute_route", "redownload_map"]
64
+ "alwaysAllow": ["generate_map", "generate_markers_map", "generate_route_map", "download_map", "redownload_map"]
65
65
  }
66
66
  }
67
67
  }
@@ -99,25 +99,25 @@ The key difference from this local server is how you receive the generated map i
99
99
 
100
100
  | Tool | Description |
101
101
  |---|---|
102
- | `generate_map` | Generate a styled map image for a location and save it to Downloads |
103
- | `compute_route` | Compute a walking or driving route between two locations |
104
- | `redownload_map` | Re-download a previously generated map in a different color theme or format |
102
+ | `generate_map` | Generate a styled map image centered on a single place and save it to Downloads |
103
+ | `generate_markers_map` | Generate a map with multiple pinned locations |
104
+ | `generate_route_map` | Compute a walking or driving route between two places and generate a map with it overlaid |
105
+ | `download_map` | Check a pending `generate_*` job and download it once ready |
106
+ | `redownload_map` | Re-download a previously generated map in a different color theme or format — instant, no regeneration |
105
107
 
106
108
  ## Example prompts
107
109
 
108
110
  **Japanese**
109
- - "渋谷駅周辺の地図を作って"
111
+ - "東京タワー周辺の地図を作って"
112
+ - "上野駅が最寄りの美術館・博物館を地図にして"
110
113
  - "赤坂駅から赤坂氷川神社までの徒歩ルートを地図にして"
111
- - "東京駅・日本橋駅・京橋駅を1枚の地図に表示して"
112
- - "日比谷公園の1キロ四方の地図を出して"
113
114
  - "その地図を darkBlue テーマでSVG画像で出し直して"
114
115
  - "生成した地図の編集用リンクをください"
115
116
 
116
117
  **English**
117
- - "Generate a map around Shibuya Station"
118
+ - "Generate a map around Tokyo Tower"
119
+ - "Show a map of the museums near Ueno Station"
118
120
  - "Show a walking route from Akasaka Station to Akasaka Hikawa Shrine on a map"
119
- - "Put Tokyo Station, Nihonbashi Station, and Kyobashi Station on a single map"
120
- - "Show a 1km square map of Hibiya Park"
121
121
  - "Redownload that map as an SVG in the darkBlue theme"
122
122
  - "Give me a link to edit the generated map"
123
123
 
@@ -4,10 +4,10 @@ MCP server for [MapNetwork](https://mapnetwork.app) — generate styled map imag
4
4
 
5
5
  ## Features
6
6
 
7
- - Generate maps from a place name, coordinates, or a list of markers
8
- - 11 color themes (white, darkBlue, darkGreen, popArt, lightBlue, lightGreen, beige, magenta, gray, black, brawn)
9
- - Overlay walking / driving routes on the map
7
+ - Generate maps from a place name, a list of markers, or a walking/driving route
8
+ - 11 color themes (white, darkBlue, darkGreen, popArt, lightBlue, lightGreen, beige, magenta, gray, black, brown)
10
9
  - PNG or SVG output, saved to your Downloads folder
10
+ - Slow-to-generate maps are handled automatically — `generate_*` tools poll internally, and `download_map` can pick up a job later if needed
11
11
  - Re-download a previously generated map in a different theme or format without regenerating
12
12
  - Open any generated map in the MapNetwork web editor for manual customization
13
13
 
@@ -48,7 +48,7 @@ Add the following to your `claude_desktop_config.json`:
48
48
  "mapnetwork": {
49
49
  "command": "uvx",
50
50
  "args": ["mapnetwork-mcp"],
51
- "alwaysAllow": ["generate_map", "compute_route", "redownload_map"]
51
+ "alwaysAllow": ["generate_map", "generate_markers_map", "generate_route_map", "download_map", "redownload_map"]
52
52
  }
53
53
  }
54
54
  }
@@ -86,25 +86,25 @@ The key difference from this local server is how you receive the generated map i
86
86
 
87
87
  | Tool | Description |
88
88
  |---|---|
89
- | `generate_map` | Generate a styled map image for a location and save it to Downloads |
90
- | `compute_route` | Compute a walking or driving route between two locations |
91
- | `redownload_map` | Re-download a previously generated map in a different color theme or format |
89
+ | `generate_map` | Generate a styled map image centered on a single place and save it to Downloads |
90
+ | `generate_markers_map` | Generate a map with multiple pinned locations |
91
+ | `generate_route_map` | Compute a walking or driving route between two places and generate a map with it overlaid |
92
+ | `download_map` | Check a pending `generate_*` job and download it once ready |
93
+ | `redownload_map` | Re-download a previously generated map in a different color theme or format — instant, no regeneration |
92
94
 
93
95
  ## Example prompts
94
96
 
95
97
  **Japanese**
96
- - "渋谷駅周辺の地図を作って"
98
+ - "東京タワー周辺の地図を作って"
99
+ - "上野駅が最寄りの美術館・博物館を地図にして"
97
100
  - "赤坂駅から赤坂氷川神社までの徒歩ルートを地図にして"
98
- - "東京駅・日本橋駅・京橋駅を1枚の地図に表示して"
99
- - "日比谷公園の1キロ四方の地図を出して"
100
101
  - "その地図を darkBlue テーマでSVG画像で出し直して"
101
102
  - "生成した地図の編集用リンクをください"
102
103
 
103
104
  **English**
104
- - "Generate a map around Shibuya Station"
105
+ - "Generate a map around Tokyo Tower"
106
+ - "Show a map of the museums near Ueno Station"
105
107
  - "Show a walking route from Akasaka Station to Akasaka Hikawa Shrine on a map"
106
- - "Put Tokyo Station, Nihonbashi Station, and Kyobashi Station on a single map"
107
- - "Show a 1km square map of Hibiya Park"
108
108
  - "Redownload that map as an SVG in the darkBlue theme"
109
109
  - "Give me a link to edit the generated map"
110
110
 
@@ -2,9 +2,9 @@
2
2
  "manifest_version": "0.4",
3
3
  "name": "mapnetwork-mcp",
4
4
  "display_name": "MapNetwork",
5
- "version": "5.0.0",
5
+ "version": "6.1.0",
6
6
  "description": "Generate styled PNG/SVG map images of any location with 11 customizable color themes.",
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",
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, brown)\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": {
9
9
  "name": "toruproject",
10
10
  "url": "https://github.com/toruproject"
@@ -36,8 +36,8 @@
36
36
  "description": "Compute a walking or driving route between two places and generate a map with it overlaid"
37
37
  },
38
38
  {
39
- "name": "check_map_status",
40
- "description": "Poll a pending map generation job and download it once ready"
39
+ "name": "download_map",
40
+ "description": "Check a pending map generation job and download it once ready"
41
41
  },
42
42
  {
43
43
  "name": "redownload_map",
@@ -19,11 +19,10 @@ POLL_INTERVAL_SEC = 10.0
19
19
  MAX_WAIT_SEC = 600
20
20
  # MCPクライアントによっては、report_progressで進捗通知を送ってもtools/call自体の
21
21
  # クライアント側タイムアウトを延長してくれない(60秒固定のクライアントで実測確認済み)。
22
- # そのため generate_* は内部ポーリングをこの秒数までに打ち切り、まだ終わっていなければ
23
- # dataKeyを返してcheck_map_statusでの確認をモデルに促す。60秒に対して十分な余裕を残す値にする。
24
- INITIAL_WAIT_SEC = 40.0
25
- # check_map_statusをモデルが連打しても機械的に間隔が空くようにする最低待機時間
26
- CHECK_THROTTLE_SEC = 5.0
22
+ # そのため generate_*・download_mapは1回の呼び出しで内部ポーリングをこの秒数までに
23
+ # 打ち切り、まだ終わっていなければdataKeyを返してdownload_mapを再度呼ぶようモデルに
24
+ # 促す。60秒に対して十分な余裕を残す値にする(両ツールで共用する1回あたりの待機予算)。
25
+ POLL_BUDGET_SEC = 40.0
27
26
 
28
27
 
29
28
  # extra="forbid": 未知のキー(例えばmarkerの'label'と紛れて'place'を書いてしまう等)を
@@ -64,17 +63,18 @@ mcp = FastMCP(
64
63
  "re-download without regenerating' below to change the theme or format without regenerating.\n\n"
65
64
  "## If generation is still in progress\n"
66
65
  "For busy areas, any generate_* tool may return before the map is ready, with a `dataKey` "
67
- "and a message asking you to check back. In that case, wait about 10-20 seconds and "
68
- "call `check_map_status(data_key=...)` — do not call the generate_* tool again for the same "
69
- "request, that only starts a redundant duplicate job. Repeat `check_map_status` "
70
- "(with the same wait between calls) until it returns the image.\n\n"
66
+ "and a message asking you to check back. In that case, call `download_map(data_key=...)` — "
67
+ "it waits internally and returns the image as soon as it's ready, or asks you to call it "
68
+ "again if it's still not done. Do not call the generate_* tool again for the same "
69
+ "request, that only starts a redundant duplicate job. Just repeat `download_map` "
70
+ "with the same `dataKey` until it returns the image.\n\n"
71
71
  "## Important: re-download without regenerating\n"
72
72
  "After generating a map, the tool returns a `dataKey`. "
73
73
  "You can call `redownload_map` with that `dataKey` to get the same map in a different "
74
74
  "color theme or format (png/svg) — **no regeneration needed**. "
75
75
  "Use this when the user asks to change only the appearance after already generating the map. "
76
76
  "MapNetwork supports 11 color themes (white, darkBlue, darkGreen, popArt, lightBlue, "
77
- "lightGreen, beige, magenta, gray, black, brawn).\n\n"
77
+ "lightGreen, beige, magenta, gray, black, brown).\n\n"
78
78
  "## Sharing the generated map\n"
79
79
  "Every successful result includes a Download link and an 'Open in editor' link — "
80
80
  "mention both to the user.\n\n"
@@ -82,7 +82,10 @@ mcp = FastMCP(
82
82
  "- **place/label**: `place`, a marker's `label`, and route's `from`/`to` must each be a "
83
83
  "place name specific enough for the server to geocode it to a single, unambiguous "
84
84
  "location (e.g. a full venue or station name, not a vague or generic term like "
85
- "\"the station\" or \"a nearby cafe\")."
85
+ "\"the station\" or \"a nearby cafe\").\n"
86
+ "- **name**: every generate_* tool also accepts an optional `name` to set the map's "
87
+ "display name explicitly. If omitted, the server derives one automatically from "
88
+ "place/markers/route."
86
89
  ),
87
90
  )
88
91
 
@@ -109,54 +112,43 @@ async def _download(client: httpx.AsyncClient, data_key: str, format: str,
109
112
  return resp.content
110
113
 
111
114
 
112
- async def _has_any_link(client: httpx.AsyncClient, data_key: str) -> bool:
113
- """dataKeyの生成結果(placeDict)にlinkを持つエントリが1つでもあるか判定する。
114
- Web UIの共有リンク機能が使うAPIを流用する(MCP生成データも同じSTORE_DIR配下に
115
- 保存されるため、dataKeyを指定すればWeb UI側からも同じデータが取得できる)。
116
- どのツールを呼んだかではなく、実際に生成されたデータで判定する。"""
117
- try:
118
- resp = await client.get(f"{BASE_URL}/api/upd/download", params={"dataKey": data_key}, timeout=10)
119
- if resp.status_code != 200:
120
- return False
121
- place_dict = resp.json().get("placeDict", {})
122
- return any(isinstance(p, dict) and p.get("link") for p in place_dict.values())
123
- except Exception:
124
- return False
125
-
126
-
127
115
  async def _poll_with_budget(
128
116
  client: httpx.AsyncClient, data_key: str, budget_sec: float, ctx: Context | None,
129
- ) -> str:
117
+ sleep_first: bool,
118
+ ) -> dict:
130
119
  """dataKeyの状態をPOLL_INTERVAL_SEC間隔でbudget_sec以内までポーリングする。
131
- "ready"/"failed"になればその時点で返す。budget_sec内に決着しなければ"pending"を
132
- 返す(例外は投げない、呼び出し側で分岐する)。"""
120
+ "ready"/"failed"になればその時点の/statusレスポンス全体(downloadUrl/editorUrlを含む)を
121
+ 返す。budget_sec内に決着しなければ{"status": "pending"}を返す(例外は投げない、
122
+ 呼び出し側で分岐する)。
123
+ sleep_first=True: 最初のチェック前にPOLL_INTERVAL_SEC待つ(generate_*用 — enqueueした
124
+ 直後なので、すぐ完了している見込みは薄い)。
125
+ sleep_first=False: 即座に1回目のチェックを行う(download_map用 — 呼ばれた時点で既に
126
+ 完了している可能性があるため、無駄な初回待ちを避ける)。"""
133
127
  if ctx is not None:
134
128
  await ctx.report_progress(0, budget_sec, "Map generation queued...")
135
129
  elapsed = 0.0
136
- while elapsed < budget_sec:
130
+ if sleep_first:
137
131
  await asyncio.sleep(POLL_INTERVAL_SEC)
138
132
  elapsed += POLL_INTERVAL_SEC
133
+ while True:
139
134
  status_resp = await client.get(
140
135
  f"{BASE_URL}/status", params={"dataKey": data_key}, timeout=10
141
136
  )
142
- status = status_resp.json().get("status")
143
- if status in ("ready", "failed"):
144
- return status
137
+ status_json = status_resp.json()
138
+ if status_json.get("status") in ("ready", "failed"):
139
+ return status_json
140
+ if elapsed >= budget_sec:
141
+ return {"status": "pending"}
145
142
  if ctx is not None:
146
143
  await ctx.report_progress(
147
144
  elapsed, budget_sec, f"Map generation in progress... ({elapsed:.0f}s elapsed)"
148
145
  )
149
- return "pending"
146
+ await asyncio.sleep(POLL_INTERVAL_SEC)
147
+ elapsed += POLL_INTERVAL_SEC
150
148
 
151
149
 
152
- def _build_success_result(image_bytes: bytes, out_path: Path, data_key: str, has_link: bool) -> list:
150
+ def _build_success_result(image_bytes: bytes, out_path: Path, data_key: str, download_url: str, editor_url: str) -> list:
153
151
  out_path.write_bytes(image_bytes)
154
- # linkを持つマーカーが1つでもあれば、"Open in editor"を閲覧専用(lock)モードのURLにする。
155
- # どのツールを呼んだかではなく実際に生成されたplaceDictの中身で判定している(_has_any_link)。
156
- editor_url = f"https://mapnetwork.app/generate?dataKey={data_key}"
157
- if has_link:
158
- editor_url += "&lock=true"
159
- download_url = f"https://mapnetwork.app/download?dataKey={data_key}"
160
152
  return [
161
153
  Image(data=image_bytes, format="png"),
162
154
  (
@@ -170,20 +162,35 @@ def _build_success_result(image_bytes: bytes, out_path: Path, data_key: str, has
170
162
  ]
171
163
 
172
164
 
165
+ def _failed_message(data_key: str, status_json: dict) -> str:
166
+ """/statusが返す"failed"レスポンスからメッセージを組み立てる。バックエンド(worker.py)が
167
+ 失敗理由を"error"フィールドに書き込めていればそれを含める(具体的な原因をClaudeが
168
+ ユーザーに伝えたり、再試行の判断材料にできるようにするため)。無ければ(古いバージョンの
169
+ バックエンド、書き込み自体が失敗した等)従来通りの汎用メッセージにフォールバックする。"""
170
+ reason = status_json.get("error")
171
+ if reason:
172
+ return f"Map generation failed (dataKey={data_key}): {reason}"
173
+ return f"Map generation failed (dataKey={data_key}). Try a different location."
174
+
175
+
173
176
  def _still_in_progress_result(data_key: str) -> list:
174
177
  return [(
175
178
  f"Map generation is still in progress (dataKey={data_key}). This can take a few "
176
- "minutes for busy areas. Wait about 20-30 seconds, then call "
177
- f"check_map_status(data_key='{data_key}') to check again. "
179
+ f"minutes for busy areas. Call download_map(data_key='{data_key}') again to check and "
180
+ "download once ready. "
178
181
  "Do NOT call the generate_* tool again for the same request — that starts a redundant "
179
182
  "duplicate job and wastes time."
180
183
  )]
181
184
 
182
185
 
183
186
  async def _generate_map_common(body: dict, ctx: Context | None, label: str | None = None) -> list:
184
- """3つのgenerate_*ツール共通のenqueue→poll→download→has_link判定→結果構築フロー。
185
- labelはダウンロードファイル名の元にのみ使う(バックエンド側もplace/markers/routeから
186
- 同じ表示名をconfigDict.nameとして独自に導出するため、bodyには含めない)。
187
+ """3つのgenerate_*ツール共通のenqueue→poll→download→結果構築フロー。
188
+ downloadUrl/editorUrlは/statusレスポンスに含まれるものをそのまま使う(自前で組み立てない)。
189
+ ダウンロードファイル名は、/statusレスポンスの"name"(バックエンドが決めたconfigDict.name。
190
+ quereq.py validate_and_prepare/_build_name参照)を優先して使う。呼び出し元がname引数を
191
+ 明示していればbody["name"]としてバックエンドへ渡り、そのままconfigDict.nameになる。
192
+ 省略時はバックエンド側がplace/markers/routeから同じ表示名を自動で導出する。labelは
193
+ /statusにnameが含まれない場合(古いバックエンド等)だけのフォールバックとして使う。
187
194
  常にformat="png"・デフォルトcolor_setでダウンロードする(別の見た目が欲しければ
188
195
  redownload_mapで取り直す)。"""
189
196
  async with httpx.AsyncClient() as client:
@@ -197,26 +204,28 @@ async def _generate_map_common(body: dict, ctx: Context | None, label: str | Non
197
204
  raise RuntimeError(f"Request rejected ({resp.status_code}): {detail}")
198
205
  data_key = resp.json()["dataKey"]
199
206
 
200
- # 2. Poll, but only up to INITIAL_WAIT_SEC (安全のためMCPクライアントの典型的な
207
+ # 2. Poll, but only up to POLL_BUDGET_SEC (安全のためMCPクライアントの典型的な
201
208
  # 60秒タイムアウトより十分短くしてある)。多くの地図生成はこの範囲で終わるため、
202
209
  # その場合はこの1回の呼び出しだけで完結する。間に合わなければ、ここで打ち切って
203
- # dataKeyを返し、check_map_statusでの確認をモデルに促す(生成自体はバックエンドで
204
- # 継続しているので、ここで諦めても失敗にはならない)。
205
- status = await _poll_with_budget(client, data_key, INITIAL_WAIT_SEC, ctx)
210
+ # dataKeyを返し、download_mapでの確認をモデルに促す(生成自体はバックエンドで
211
+ # 継続しているので、ここで諦めても失敗にはならない)。enqueueした直後なので
212
+ # 最初のチェック前にも1回分待つ(sleep_first=True)。
213
+ status_json = await _poll_with_budget(client, data_key, POLL_BUDGET_SEC, ctx, sleep_first=True)
214
+ status = status_json.get("status")
206
215
 
207
216
  if status == "failed":
208
- raise RuntimeError(
209
- f"Map generation failed (dataKey={data_key}). "
210
- "Try a different location."
211
- )
217
+ raise RuntimeError(_failed_message(data_key, status_json))
212
218
  if status == "pending":
213
219
  return _still_in_progress_result(data_key)
214
220
 
215
- # 3. Download + linkの有無判定
221
+ # 3. Download(downloadUrl/editorUrlは/statusレスポンスに既に含まれている)
216
222
  image_bytes = await _download(client, data_key, "png", None)
217
- has_link = await _has_any_link(client, data_key)
218
223
 
219
- return _build_success_result(image_bytes, _make_filename(label or data_key, "png"), data_key, has_link)
224
+ filename_base = status_json.get("name") or label or data_key
225
+ return _build_success_result(
226
+ image_bytes, _make_filename(filename_base, "png"), data_key,
227
+ status_json["downloadUrl"], status_json["editorUrl"],
228
+ )
220
229
 
221
230
 
222
231
  # ---------------------------------------------------------------------------
@@ -226,6 +235,10 @@ async def _generate_map_common(body: dict, ctx: Context | None, label: str | Non
226
235
  @mcp.tool()
227
236
  async def generate_map(
228
237
  place: Annotated[str, Field(description="Place name to center the map on (geocoded server-side).")],
238
+ name: Annotated[
239
+ str | None,
240
+ Field(description="Optional: display name for the map. If omitted, the server derives one automatically from place."),
241
+ ] = None,
229
242
  ctx: Context = None,
230
243
  ) -> list:
231
244
  """Generate a styled map centered on a single place.
@@ -233,6 +246,8 @@ async def generate_map(
233
246
  Example: generate_map(place="Tokyo Station")
234
247
  """
235
248
  body: dict = {"place": place}
249
+ if name:
250
+ body["name"] = name
236
251
  return await _generate_map_common(body, ctx, label=place)
237
252
 
238
253
 
@@ -249,6 +264,10 @@ async def generate_markers_map(
249
264
  str | None,
250
265
  Field(description="Optional: place to center the map on. If omitted, the center is computed automatically from the markers."),
251
266
  ] = None,
267
+ name: Annotated[
268
+ str | None,
269
+ Field(description="Optional: display name for the map. If omitted, the server derives one automatically from place/markers."),
270
+ ] = None,
252
271
  ctx: Context = None,
253
272
  ) -> list:
254
273
  """Generate a map with multiple pinned locations.
@@ -261,6 +280,8 @@ async def generate_markers_map(
261
280
  body: dict = {"markers": [m.model_dump(exclude_none=True) for m in markers]}
262
281
  if place:
263
282
  body["place"] = place
283
+ if name:
284
+ body["name"] = name
264
285
  return await _generate_map_common(body, ctx, label=label)
265
286
 
266
287
 
@@ -280,6 +301,10 @@ async def generate_route_map(
280
301
  str | None,
281
302
  Field(description="Optional: place to center the map on. If omitted, the center is computed automatically from the route."),
282
303
  ] = None,
304
+ name: Annotated[
305
+ str | None,
306
+ Field(description="Optional: display name for the map. If omitted, the server derives one automatically from place/route."),
307
+ ] = None,
283
308
  ctx: Context = None,
284
309
  ) -> list:
285
310
  """Compute a walking/driving route between two places and generate a map with it overlaid.
@@ -295,44 +320,45 @@ async def generate_route_map(
295
320
  body: dict = {"route": {"from": {"label": from_}, "to": {"label": to}, "mode": mode}}
296
321
  if place:
297
322
  body["place"] = place
323
+ if name:
324
+ body["name"] = name
298
325
  return await _generate_map_common(body, ctx, label=label)
299
326
 
300
327
 
301
328
  # ---------------------------------------------------------------------------
302
- # Tool: check_map_status
329
+ # Tool: download_map
303
330
  # ---------------------------------------------------------------------------
304
331
 
305
332
  @mcp.tool()
306
- async def check_map_status(
333
+ async def download_map(
307
334
  data_key: Annotated[
308
335
  str,
309
336
  Field(description="The dataKey returned by a generate_* call that reported it was still in progress."),
310
337
  ],
311
338
  ctx: Context = None,
312
339
  ) -> list:
313
- """Poll a pending generate_* job and download it once ready. Wait ~20-30s between calls.
340
+ """Check a pending generate_* job and download it once ready. If it's already done, returns
341
+ the image immediately; otherwise waits internally (checking periodically) before returning —
342
+ no need to wait between calls yourself. If still not ready when it returns, call it again
343
+ with the same dataKey.
314
344
 
315
- Example: check_map_status(data_key="20260618aBcDeFgHiJ")
345
+ Example: download_map(data_key="20260618aBcDeFgHiJ")
316
346
  """
317
347
  async with httpx.AsyncClient() as client:
318
- # 連打されても機械的に間隔が空くようにする最低限のスロットル
319
- await asyncio.sleep(CHECK_THROTTLE_SEC)
320
- status_resp = await client.get(f"{BASE_URL}/status", params={"dataKey": data_key}, timeout=10)
321
- status = status_resp.json().get("status")
348
+ status_json = await _poll_with_budget(client, data_key, POLL_BUDGET_SEC, ctx, sleep_first=False)
349
+ status = status_json.get("status")
322
350
  if status == "failed":
323
- raise RuntimeError(
324
- f"Map generation failed (dataKey={data_key}). "
325
- "Try a different location."
326
- )
351
+ raise RuntimeError(_failed_message(data_key, status_json))
327
352
  if status != "ready":
328
- if ctx is not None:
329
- await ctx.report_progress(0, 1, "Map generation still in progress...")
330
353
  return _still_in_progress_result(data_key)
331
354
 
332
355
  image_bytes = await _download(client, data_key, "png", None)
333
- has_link = await _has_any_link(client, data_key)
334
356
 
335
- return _build_success_result(image_bytes, _make_filename(data_key, "png"), data_key, has_link)
357
+ filename_base = status_json.get("name") or data_key
358
+ return _build_success_result(
359
+ image_bytes, _make_filename(filename_base, "png"), data_key,
360
+ status_json["downloadUrl"], status_json["editorUrl"],
361
+ )
336
362
 
337
363
 
338
364
  # ---------------------------------------------------------------------------
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "mapnetwork-mcp"
3
- version = "5.0.0"
3
+ version = "6.1.0"
4
4
  description = "MCP server — generate styled map images via mapnetwork.app"
5
5
  readme = "README.md"
6
6
  license = "MIT"
@@ -15,7 +15,7 @@
15
15
  "ColorSet": {
16
16
  "type": "string",
17
17
  "description": "カラーテーマ",
18
- "enum": ["white", "darkBlue", "darkGreen", "popArt", "lightBlue", "lightGreen", "beige", "magenta", "gray", "black", "brawn"],
18
+ "enum": ["white", "darkBlue", "darkGreen", "popArt", "lightBlue", "lightGreen", "beige", "magenta", "gray", "black", "brown"],
19
19
  "default": "white"
20
20
  },
21
21
  "Format": {
@@ -29,10 +29,11 @@
29
29
  "description": "単一の地名を中心にしたスタイル付き地図画像を生成し、Downloadsフォルダに保存する。地図サイズ・取得レイヤーは座標から自動決定される。常にデフォルトのカラーテーマ・PNG形式でダウンロードする(別の見た目が欲しければredownload_mapで取り直す)",
30
30
  "type": "object",
31
31
  "properties": {
32
- "place": { "type": "string", "description": "地図の中心とする地名(サーバー側でジオコーディング)", "required": true }
32
+ "place": { "type": "string", "description": "地図の中心とする地名(サーバー側でジオコーディング)", "required": true },
33
+ "name": { "type": ["string", "null"], "default": null, "description": "地図の表示名(任意)。未指定ならバックエンド側がplaceの値をそのまま使う" }
33
34
  },
34
35
  "required": ["place"],
35
- "constraints": ["configDict.nameにはサーバー側がplaceの値をそのまま設定する(このツールにname引数はない)"],
36
+ "constraints": ["nameを指定すればそのままconfigDict.nameに使われる。未指定ならバックエンド側がplaceの値をそのまま設定する"],
36
37
  "example": { "place": "Tokyo Station" }
37
38
  },
38
39
  "generate_markers_map": {
@@ -45,13 +46,14 @@
45
46
  "items": { "$ref": "#/definitions/Marker" },
46
47
  "minItems": 1
47
48
  },
48
- "place": { "type": ["string", "null"], "default": null, "description": "地図の中心とする地名。未指定ならmarkersの座標群から自動計算される" }
49
+ "place": { "type": ["string", "null"], "default": null, "description": "地図の中心とする地名。未指定ならmarkersの座標群から自動計算される" },
50
+ "name": { "type": ["string", "null"], "default": null, "description": "地図の表示名(任意)。未指定ならバックエンド側がplace/markersから自動導出する" }
49
51
  },
50
52
  "required": ["markers"],
51
53
  "constraints": [
52
54
  "markersは1件以上必須(link有無は問わない。1件もlinkを持たないのが通常のケース)",
53
55
  "markersのいずれかがlink(明示指定またはバックエンド側のPlaces API自動補完)を持つ場合、成功レスポンスの'Open in editor'リンクに&lock=trueが付き、閲覧専用モードでそのmarkerがクリック可能になる(判定はどのツールを呼んだかではなく実データによる)",
54
- "configDict.nameにはサーバー側がplace(未指定ならmarkersのlabelを連結した文字列)を自動設定する"
56
+ "nameを指定すればそのままconfigDict.nameに使われる。未指定ならバックエンド側がplace(未指定ならmarkersのlabelを連結した文字列)を自動設定する"
55
57
  ],
56
58
  "example": { "markers": [{ "label": "Tokyo Tower", "link": "https://www.tokyotower.co.jp/" }, { "label": "Zojoji Temple" }] }
57
59
  },
@@ -66,19 +68,20 @@
66
68
  "default": "walking",
67
69
  "description": "移動手段"
68
70
  },
69
- "place": { "type": ["string", "null"], "default": null, "description": "地図の中心とする地名。未指定ならルートの座標群から自動計算される" }
71
+ "place": { "type": ["string", "null"], "default": null, "description": "地図の中心とする地名。未指定ならルートの座標群から自動計算される" },
72
+ "name": { "type": ["string", "null"], "default": null, "description": "地図の表示名(任意)。未指定ならバックエンド側がplace/routeから自動導出する" }
70
73
  },
71
74
  "required": ["from", "to"],
72
75
  "constraints": [
73
76
  "from/toは地名の文字列のみ。座標を自分で計算・推測して渡してはならない(サーバー側でジオコーディング・ルート探索の両方を行う)",
74
77
  "ルートの両端点は自動でピン留めされるため、別途generate_markers_mapを呼ぶ必要はない",
75
78
  "ルート探索はバックエンドのワーカー内(地図生成と同じジョブ)で、地図生成用に取得した道路データをそのまま再利用して行われる(別エンドポイントでの事前ルート探索は廃止済み、道路データの二重取得を避けるため)。そのため「ルートが見つからない」等の失敗は、呼び出し時点では分からず、地図生成ジョブ自体の失敗(dataKeyのstatusがfailed)として遅れて判明する",
76
- "configDict.nameにはサーバー側がplace(未指定なら'route'固定文字列)を自動設定する"
79
+ "nameを指定すればそのままconfigDict.nameに使われる。未指定ならバックエンド側がplace(未指定なら'route'固定文字列)を自動設定する"
77
80
  ],
78
81
  "example": { "from": "Tokyo Station", "to": "Tokyo Tower", "mode": "walking" }
79
82
  },
80
- "check_map_status": {
81
- "description": "generate_*ツールが未完了(pending)を返した場合のジョブをポーリングし、完了していればデフォルトのカラーテーマ・PNG形式でダウンロードする",
83
+ "download_map": {
84
+ "description": "generate_*ツールが未完了(pending)を返した場合のジョブを確認し、完了していればデフォルトのカラーテーマ・PNG形式でダウンロードする。まだ完了していなければ内部で待機してから再確認するため、呼び出し側で待つ必要はない",
82
85
  "type": "object",
83
86
  "properties": {
84
87
  "data_key": { "type": "string", "description": "generate_*ツールが返したdataKey", "required": true }
@@ -54,7 +54,7 @@
54
54
  },
55
55
  "PendingResult": {
56
56
  "type": "object",
57
- "description": "generate_*が内部ポーリング予算内に完了しなかった場合、またはcheck_map_statusで確認したがまだreadyでない場合",
57
+ "description": "generate_*・download_mapともに、内部ポーリング予算(POLL_BUDGET_SEC=40秒)内に完了しなかった場合に返る",
58
58
  "properties": {
59
59
  "isError": { "const": false },
60
60
  "structuredContent": { "const": null },
@@ -67,7 +67,7 @@
67
67
  "properties": {
68
68
  "text": {
69
69
  "type": "string",
70
- "description": "'Map generation is still in progress (dataKey=<dataKey>). ... call check_map_status(data_key=\\'<dataKey>\\') to check again. Do NOT call the generate_* tool again ...'"
70
+ "description": "'Map generation is still in progress (dataKey=<dataKey>). ... Call download_map(data_key=\\'<dataKey>\\') again to check and download once ready. Do NOT call the generate_* tool again ...'"
71
71
  }
72
72
  }
73
73
  }
@@ -77,7 +77,7 @@
77
77
  },
78
78
  "MapSuccessResult": {
79
79
  "type": "object",
80
- "description": "地図が生成/取得できた場合の共通の成功形。generate_*系3ツール・check_map_status・redownload_mapすべてがこの形で返す",
80
+ "description": "地図が生成/取得できた場合の共通の成功形。generate_*系3ツール・download_map・redownload_mapすべてがこの形で返す",
81
81
  "properties": {
82
82
  "isError": { "const": false },
83
83
  "structuredContent": { "const": null },
@@ -92,7 +92,7 @@
92
92
  "properties": {
93
93
  "text": {
94
94
  "type": "string",
95
- "description": "'Map saved: <ローカル保存パス>\\ndataKey: <dataKey>\\n\\nDownload: .../download?dataKey=...\\nOpen in editor: .../generate?dataKey=...[&lock=true]\\n\\nTip: call redownload_map(...) ...' の形式(generate_*/check_map_statusの場合)。&lock=trueはlinkを持つmarkerが1件でもある場合にのみ付く。redownload_mapのみ形式が異なる(下記参照)"
95
+ "description": "'Map saved: <ローカル保存パス>\\ndataKey: <dataKey>\\n\\nDownload: .../download?dataKey=...\\nOpen in editor: .../generate?dataKey=...[&lock=true]\\n\\nTip: call redownload_map(...) ...' の形式(generate_*/download_mapの場合)。&lock=trueはlinkを持つmarkerが1件でもある場合にのみ付く。redownload_mapのみ形式が異なる(下記参照)"
96
96
  }
97
97
  }
98
98
  }
@@ -147,7 +147,7 @@
147
147
  "notes": [
148
148
  "compute_routeという別ツールは存在せず(廃止済み)、専用のルート探索エンドポイントも存在しない(こちらも廃止済み)。generate_route_mapは{\"from\":{\"label\":...}, \"to\":{\"label\":...}, \"mode\":...}をそのままバックエンドの/requestのrouteフィールドに詰めて1回だけ送るだけで、ジオコード・ルート探索・地図生成は全てバックエンドのワーカー内(build_map_data)で行われる。ルート探索は地図生成用に取得した道路データをそのまま再利用するため、道路網の二重取得が発生しない。",
149
149
  "from/toはmarkerとして自動でピン留めされるが、linkを持たせる手段は無い。そのため生成データにlinkを持つエントリは発生せず、成功時のOpen in editorリンクに'&lock=true'は付かない。",
150
- "ルート探索がバックエンド内(ワーカー)で行われるため、「ルートが見つからない」等の失敗はgenerate_route_map呼び出し時点では判明せず、他のgenerate_*ツールと同じ一般的な地図生成失敗('Map generation failed (dataKey=...). Try a different location.')として現れる。INITIAL_WAIT_SEC(40秒)以内に失敗が判明すればそのままエラーとして返るが、それより時間がかかる場合は一旦pendingが返り、check_map_status経由で最終的に失敗が判明する。"
150
+ "ルート探索がバックエンド内(ワーカー)で行われるため、「ルートが見つからない」等の失敗はgenerate_route_map呼び出し時点では判明せず、他のgenerate_*ツールと同じ一般的な地図生成失敗('Map generation failed (dataKey=...). Try a different location.')として現れる。POLL_BUDGET_SEC(40秒)以内に失敗が判明すればそのままエラーとして返るが、それより時間がかかる場合は一旦pendingが返り、download_map経由で最終的に失敗が判明する。"
151
151
  ],
152
152
  "example_error_texts": [
153
153
  "Error executing tool generate_route_map: All connection attempts failed",
@@ -156,7 +156,7 @@
156
156
  "Error executing tool generate_route_map: 1 validation error for generate_route_mapArguments\nmode\n Input should be 'walking' or 'driving' [type=literal_error, input_value='flying', input_type=str]\n For further information visit https://errors.pydantic.dev/2.13/v/literal_error"
157
157
  ]
158
158
  },
159
- "check_map_status": {
159
+ "download_map": {
160
160
  "returns": {
161
161
  "success": { "$ref": "#/definitions/MapSuccessResult" },
162
162
  "pending": { "$ref": "#/definitions/PendingResult" },
@@ -164,8 +164,8 @@
164
164
  },
165
165
  "notes": [
166
166
  "successの場合、_make_filename(data_key, \"png\")でファイル名を作るため、保存パスのslugにはdataKeyがそのまま使われる(generate_*の成功時はplace/markerラベル由来のslugになるのと異なる)。",
167
- "Open in editorリンクへの&lock=true付与は、check_map_status呼び出し時点で実データのplaceDictを再取得して判定する(元のgenerate_*ツール呼び出しの引数には依存しない)。",
168
- "呼び出しごとにCHECK_THROTTLE_SEC(5秒)のスリープが必ず入るため、pending応答であっても即座には返らない。"
167
+ "Open in editorリンクへの&lock=true付与は、download_map呼び出し時点で実データのplaceDictを再取得して判定する(元のgenerate_*ツール呼び出しの引数には依存しない)。",
168
+ "呼び出し側で待つ必要はない。_poll_with_budget(sleep_first=False)により、呼び出された時点でまず即座に/statusを1回確認し(既に完了していれば待たずにそのまま画像を返す)、未完了ならPOLL_INTERVAL_SEC(10秒)間隔でPOLL_BUDGET_SEC(40秒)まで内部でポーリングを続ける。それでも完了しなければpendingを返す(generate_*と異なりsleep_firstがFalseなので、40秒間隔で最大5回/statusを叩く計算になる)。呼び出し間隔の連打対策(旧CHECK_THROTTLE_SEC)は廃止された — 1回の呼び出しが最短でも次のready/failed確定か40秒経過までブロックするため、連打しても機械的に無駄が生じない。"
169
169
  ]
170
170
  },
171
171
  "redownload_map": {
File without changes
File without changes