mapnetwork-mcp 4.0.0__tar.gz → 6.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-6.0.0/LOCALTEST.md +62 -0
- {mapnetwork_mcp-4.0.0 → mapnetwork_mcp-6.0.0}/PKG-INFO +1 -1
- {mapnetwork_mcp-4.0.0 → mapnetwork_mcp-6.0.0}/manifest.json +3 -7
- {mapnetwork_mcp-4.0.0 → mapnetwork_mcp-6.0.0}/mapnetwork_mcp/server.py +106 -129
- {mapnetwork_mcp-4.0.0 → mapnetwork_mcp-6.0.0}/pyproject.toml +1 -1
- {mapnetwork_mcp-4.0.0 → mapnetwork_mcp-6.0.0}/spec/input_schema.json +16 -33
- {mapnetwork_mcp-4.0.0 → mapnetwork_mcp-6.0.0}/spec/output_schema.json +21 -36
- {mapnetwork_mcp-4.0.0 → mapnetwork_mcp-6.0.0}/.github/workflows/workflow.yml +0 -0
- {mapnetwork_mcp-4.0.0 → mapnetwork_mcp-6.0.0}/.gitignore +0 -0
- {mapnetwork_mcp-4.0.0 → mapnetwork_mcp-6.0.0}/.mcpbignore +0 -0
- {mapnetwork_mcp-4.0.0 → mapnetwork_mcp-6.0.0}/LICENSE +0 -0
- {mapnetwork_mcp-4.0.0 → mapnetwork_mcp-6.0.0}/README.md +0 -0
- {mapnetwork_mcp-4.0.0 → mapnetwork_mcp-6.0.0}/RELEASING.md +0 -0
- {mapnetwork_mcp-4.0.0 → mapnetwork_mcp-6.0.0}/SECURITY.md +0 -0
- {mapnetwork_mcp-4.0.0 → mapnetwork_mcp-6.0.0}/images/Kanazawa21Museum-black.png +0 -0
- {mapnetwork_mcp-4.0.0 → mapnetwork_mcp-6.0.0}/images/Kanazawa21Museum-darkGreen.png +0 -0
- {mapnetwork_mcp-4.0.0 → mapnetwork_mcp-6.0.0}/images/Kanazawa21Museum-grey.png +0 -0
- {mapnetwork_mcp-4.0.0 → mapnetwork_mcp-6.0.0}/images/Kanazawa21Museum-lightGreen.png +0 -0
- {mapnetwork_mcp-4.0.0 → mapnetwork_mcp-6.0.0}/images/Kanazawa21Museum-popArt.png +0 -0
- {mapnetwork_mcp-4.0.0 → mapnetwork_mcp-6.0.0}/images/Kanazawa21Museum-white.png +0 -0
- {mapnetwork_mcp-4.0.0 → mapnetwork_mcp-6.0.0}/mapnetwork_mcp/__init__.py +0 -0
- {mapnetwork_mcp-4.0.0 → mapnetwork_mcp-6.0.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:
|
|
3
|
+
Version: 6.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
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"manifest_version": "0.4",
|
|
3
3
|
"name": "mapnetwork-mcp",
|
|
4
4
|
"display_name": "MapNetwork",
|
|
5
|
-
"version": "
|
|
5
|
+
"version": "6.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": {
|
|
@@ -36,12 +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": "
|
|
40
|
-
"description": "
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
"name": "check_map_status",
|
|
44
|
-
"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"
|
|
45
41
|
},
|
|
46
42
|
{
|
|
47
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を返して
|
|
24
|
-
|
|
25
|
-
|
|
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'を書いてしまう等)を
|
|
@@ -33,9 +32,9 @@ CHECK_THROTTLE_SEC = 5.0
|
|
|
33
32
|
# extra="ignore"がデフォルトのため気づかれずに黙って無視されていたことが判明した)。
|
|
34
33
|
|
|
35
34
|
class Marker(BaseModel):
|
|
36
|
-
"""generate_markers_map
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
"""generate_markers_mapのマーカー。labelは必須、linkは任意で公式サイトURLを付けられる
|
|
36
|
+
(バックエンド側がPlaces APIで自動補完する場合も多いが、モデルが確度高く知っている場合は
|
|
37
|
+
明示的に渡してもよい)。link無しのマーカーが混在してもよい(むしろ通常はこちら)。"""
|
|
39
38
|
model_config = ConfigDict(extra="forbid")
|
|
40
39
|
|
|
41
40
|
label: str = Field(description="Place name to geocode and display.")
|
|
@@ -53,25 +52,22 @@ mcp = FastMCP(
|
|
|
53
52
|
"## Key capabilities — pick the tool that matches what you need\n"
|
|
54
53
|
"- **Single location**: `generate_map(place=...)` — centers a map on one place.\n"
|
|
55
54
|
"- **Multiple pinned locations**: `generate_markers_map(markers=[{\"label\": ...}, ...])` — "
|
|
56
|
-
"pins several places on one map. Each marker needs a `label
|
|
57
|
-
"
|
|
55
|
+
"pins several places on one map. Each marker needs a `label`, and may optionally include "
|
|
56
|
+
"`link` (its official website URL, if known) to make that pin a clickable link in the "
|
|
57
|
+
"result's 'Open in editor' link. Use this whenever the user asks to show multiple places "
|
|
58
|
+
"on a single map, or wants a map they (or someone else) can click through to visit the "
|
|
59
|
+
"pinned places' websites.\n"
|
|
58
60
|
"- **Walking/driving route**: `generate_route_map(from=..., to=..., mode=...)` — computes a "
|
|
59
|
-
"route between two places and draws it on the map
|
|
60
|
-
"
|
|
61
|
-
"-
|
|
62
|
-
"— like generate_markers_map, but produces a map where markers are clickable links to their "
|
|
63
|
-
"official websites. Set `link` on any marker whose official website you already know (e.g. "
|
|
64
|
-
"from search results or prior knowledge); at least one marker must have `link` set, or the "
|
|
65
|
-
"call errors. Use this whenever the user wants a map they (or someone else) can click "
|
|
66
|
-
"through to visit the pinned places' websites.\n"
|
|
67
|
-
"- Every generate_* call produces a PNG at default size and theme — see 'Important: "
|
|
68
|
-
"re-download without regenerating' below to view it differently.\n\n"
|
|
61
|
+
"route between two places and draws it on the map.\n"
|
|
62
|
+
"- Every generate_* call produces a PNG at the default color theme — see 'Important: "
|
|
63
|
+
"re-download without regenerating' below to change the theme or format without regenerating.\n\n"
|
|
69
64
|
"## If generation is still in progress\n"
|
|
70
65
|
"For busy areas, any generate_* tool may return before the map is ready, with a `dataKey` "
|
|
71
|
-
"and a message asking you to check back. In that case,
|
|
72
|
-
"
|
|
73
|
-
"
|
|
74
|
-
"
|
|
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"
|
|
75
71
|
"## Important: re-download without regenerating\n"
|
|
76
72
|
"After generating a map, the tool returns a `dataKey`. "
|
|
77
73
|
"You can call `redownload_map` with that `dataKey` to get the same map in a different "
|
|
@@ -80,14 +76,16 @@ mcp = FastMCP(
|
|
|
80
76
|
"MapNetwork supports 11 color themes (white, darkBlue, darkGreen, popArt, lightBlue, "
|
|
81
77
|
"lightGreen, beige, magenta, gray, black, brawn).\n\n"
|
|
82
78
|
"## Sharing the generated map\n"
|
|
83
|
-
"Every successful result includes a Download link
|
|
84
|
-
"
|
|
85
|
-
"Mention whichever one you receive.\n\n"
|
|
79
|
+
"Every successful result includes a Download link and an 'Open in editor' link — "
|
|
80
|
+
"mention both to the user.\n\n"
|
|
86
81
|
"## Parameter discipline\n"
|
|
87
82
|
"- **place/label**: `place`, a marker's `label`, and route's `from`/`to` must each be a "
|
|
88
83
|
"place name specific enough for the server to geocode it to a single, unambiguous "
|
|
89
84
|
"location (e.g. a full venue or station name, not a vague or generic term like "
|
|
90
|
-
"\"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."
|
|
91
89
|
),
|
|
92
90
|
)
|
|
93
91
|
|
|
@@ -114,61 +112,50 @@ async def _download(client: httpx.AsyncClient, data_key: str, format: str,
|
|
|
114
112
|
return resp.content
|
|
115
113
|
|
|
116
114
|
|
|
117
|
-
async def _has_any_link(client: httpx.AsyncClient, data_key: str) -> bool:
|
|
118
|
-
"""dataKeyの生成結果(placeDict)にlinkを持つエントリが1つでもあるか判定する。
|
|
119
|
-
Web UIの共有リンク機能が使うAPIを流用する(MCP生成データも同じSTORE_DIR配下に
|
|
120
|
-
保存されるため、dataKeyを指定すればWeb UI側からも同じデータが取得できる)。
|
|
121
|
-
どのツールを呼んだかではなく、実際に生成されたデータで判定する。"""
|
|
122
|
-
try:
|
|
123
|
-
resp = await client.get(f"{BASE_URL}/api/upd/download", params={"dataKey": data_key}, timeout=10)
|
|
124
|
-
if resp.status_code != 200:
|
|
125
|
-
return False
|
|
126
|
-
place_dict = resp.json().get("placeDict", {})
|
|
127
|
-
return any(isinstance(p, dict) and p.get("link") for p in place_dict.values())
|
|
128
|
-
except Exception:
|
|
129
|
-
return False
|
|
130
|
-
|
|
131
|
-
|
|
132
115
|
async def _poll_with_budget(
|
|
133
116
|
client: httpx.AsyncClient, data_key: str, budget_sec: float, ctx: Context | None,
|
|
134
|
-
|
|
117
|
+
sleep_first: bool,
|
|
118
|
+
) -> dict:
|
|
135
119
|
"""dataKeyの状態をPOLL_INTERVAL_SEC間隔でbudget_sec以内までポーリングする。
|
|
136
|
-
"ready"/"failed"
|
|
137
|
-
|
|
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
|
+
完了している可能性があるため、無駄な初回待ちを避ける)。"""
|
|
138
127
|
if ctx is not None:
|
|
139
128
|
await ctx.report_progress(0, budget_sec, "Map generation queued...")
|
|
140
129
|
elapsed = 0.0
|
|
141
|
-
|
|
130
|
+
if sleep_first:
|
|
142
131
|
await asyncio.sleep(POLL_INTERVAL_SEC)
|
|
143
132
|
elapsed += POLL_INTERVAL_SEC
|
|
133
|
+
while True:
|
|
144
134
|
status_resp = await client.get(
|
|
145
135
|
f"{BASE_URL}/status", params={"dataKey": data_key}, timeout=10
|
|
146
136
|
)
|
|
147
|
-
|
|
148
|
-
if status in ("ready", "failed"):
|
|
149
|
-
return
|
|
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"}
|
|
150
142
|
if ctx is not None:
|
|
151
143
|
await ctx.report_progress(
|
|
152
144
|
elapsed, budget_sec, f"Map generation in progress... ({elapsed:.0f}s elapsed)"
|
|
153
145
|
)
|
|
154
|
-
|
|
146
|
+
await asyncio.sleep(POLL_INTERVAL_SEC)
|
|
147
|
+
elapsed += POLL_INTERVAL_SEC
|
|
155
148
|
|
|
156
149
|
|
|
157
|
-
def _build_success_result(image_bytes: bytes, out_path: Path, data_key: str,
|
|
150
|
+
def _build_success_result(image_bytes: bytes, out_path: Path, data_key: str, download_url: str, editor_url: str) -> list:
|
|
158
151
|
out_path.write_bytes(image_bytes)
|
|
159
|
-
# linkを持つマーカーが1つでもあれば閲覧専用(lock)リンクを、無ければ編集用リンクを返す。
|
|
160
|
-
# どのツールを呼んだかではなく実際に生成されたplaceDictの中身で判定している(_has_any_link)。
|
|
161
|
-
link_line = (
|
|
162
|
-
f"hyperlink Map: https://mapnetwork.app/generate?dataKey={data_key}&lock=true"
|
|
163
|
-
if has_link else
|
|
164
|
-
f"Open in editor: https://mapnetwork.app/generate?dataKey={data_key}"
|
|
165
|
-
)
|
|
166
152
|
return [
|
|
167
153
|
Image(data=image_bytes, format="png"),
|
|
168
154
|
(
|
|
169
155
|
f"Map saved: {out_path}\n"
|
|
170
156
|
f"dataKey: {data_key}\n\n"
|
|
171
|
-
f"{
|
|
157
|
+
f"Download: {download_url}\n"
|
|
158
|
+
f"Open in editor: {editor_url}\n\n"
|
|
172
159
|
f"Tip: call redownload_map(data_key='{data_key}', ...) to get this map "
|
|
173
160
|
f"in a different color theme or format (svg/png) without regenerating."
|
|
174
161
|
),
|
|
@@ -178,17 +165,21 @@ def _build_success_result(image_bytes: bytes, out_path: Path, data_key: str, has
|
|
|
178
165
|
def _still_in_progress_result(data_key: str) -> list:
|
|
179
166
|
return [(
|
|
180
167
|
f"Map generation is still in progress (dataKey={data_key}). This can take a few "
|
|
181
|
-
"minutes for busy areas.
|
|
182
|
-
|
|
168
|
+
f"minutes for busy areas. Call download_map(data_key='{data_key}') again to check and "
|
|
169
|
+
"download once ready. "
|
|
183
170
|
"Do NOT call the generate_* tool again for the same request — that starts a redundant "
|
|
184
171
|
"duplicate job and wastes time."
|
|
185
172
|
)]
|
|
186
173
|
|
|
187
174
|
|
|
188
|
-
async def _generate_map_common(body: dict, ctx: Context | None) -> list:
|
|
189
|
-
"""
|
|
190
|
-
|
|
191
|
-
|
|
175
|
+
async def _generate_map_common(body: dict, ctx: Context | None, label: str | None = None) -> list:
|
|
176
|
+
"""3つのgenerate_*ツール共通のenqueue→poll→download→結果構築フロー。
|
|
177
|
+
downloadUrl/editorUrlは/statusレスポンスに含まれるものをそのまま使う(自前で組み立てない)。
|
|
178
|
+
labelはダウンロードファイル名の元にのみ使う(bodyには含めない)。呼び出し元がname引数を
|
|
179
|
+
明示していればbody["name"]としてバックエンドへ渡り、そのままconfigDict.nameになる。
|
|
180
|
+
省略時はバックエンド側がplace/markers/routeから同じ表示名を自動で導出する。
|
|
181
|
+
常にformat="png"・デフォルトcolor_setでダウンロードする(別の見た目が欲しければ
|
|
182
|
+
redownload_mapで取り直す)。"""
|
|
192
183
|
async with httpx.AsyncClient() as client:
|
|
193
184
|
# 1. Enqueue
|
|
194
185
|
resp = await client.post(f"{BASE_URL}/request", json=body, timeout=30)
|
|
@@ -200,12 +191,14 @@ async def _generate_map_common(body: dict, ctx: Context | None) -> list:
|
|
|
200
191
|
raise RuntimeError(f"Request rejected ({resp.status_code}): {detail}")
|
|
201
192
|
data_key = resp.json()["dataKey"]
|
|
202
193
|
|
|
203
|
-
# 2. Poll, but only up to
|
|
194
|
+
# 2. Poll, but only up to POLL_BUDGET_SEC (安全のためMCPクライアントの典型的な
|
|
204
195
|
# 60秒タイムアウトより十分短くしてある)。多くの地図生成はこの範囲で終わるため、
|
|
205
196
|
# その場合はこの1回の呼び出しだけで完結する。間に合わなければ、ここで打ち切って
|
|
206
|
-
# dataKeyを返し、
|
|
207
|
-
# 継続しているので、ここで諦めても失敗にはならない)。
|
|
208
|
-
|
|
197
|
+
# dataKeyを返し、download_mapでの確認をモデルに促す(生成自体はバックエンドで
|
|
198
|
+
# 継続しているので、ここで諦めても失敗にはならない)。enqueueした直後なので
|
|
199
|
+
# 最初のチェック前にも1回分待つ(sleep_first=True)。
|
|
200
|
+
status_json = await _poll_with_budget(client, data_key, POLL_BUDGET_SEC, ctx, sleep_first=True)
|
|
201
|
+
status = status_json.get("status")
|
|
209
202
|
|
|
210
203
|
if status == "failed":
|
|
211
204
|
raise RuntimeError(
|
|
@@ -215,12 +208,13 @@ async def _generate_map_common(body: dict, ctx: Context | None) -> list:
|
|
|
215
208
|
if status == "pending":
|
|
216
209
|
return _still_in_progress_result(data_key)
|
|
217
210
|
|
|
218
|
-
# 3. Download
|
|
211
|
+
# 3. Download(downloadUrl/editorUrlは/statusレスポンスに既に含まれている)
|
|
219
212
|
image_bytes = await _download(client, data_key, "png", None)
|
|
220
|
-
has_link = await _has_any_link(client, data_key)
|
|
221
213
|
|
|
222
|
-
|
|
223
|
-
|
|
214
|
+
return _build_success_result(
|
|
215
|
+
image_bytes, _make_filename(label or data_key, "png"), data_key,
|
|
216
|
+
status_json["downloadUrl"], status_json["editorUrl"],
|
|
217
|
+
)
|
|
224
218
|
|
|
225
219
|
|
|
226
220
|
# ---------------------------------------------------------------------------
|
|
@@ -230,14 +224,20 @@ async def _generate_map_common(body: dict, ctx: Context | None) -> list:
|
|
|
230
224
|
@mcp.tool()
|
|
231
225
|
async def generate_map(
|
|
232
226
|
place: Annotated[str, Field(description="Place name to center the map on (geocoded server-side).")],
|
|
227
|
+
name: Annotated[
|
|
228
|
+
str | None,
|
|
229
|
+
Field(description="Optional: display name for the map. If omitted, the server derives one automatically from place."),
|
|
230
|
+
] = None,
|
|
233
231
|
ctx: Context = None,
|
|
234
232
|
) -> list:
|
|
235
233
|
"""Generate a styled map centered on a single place.
|
|
236
234
|
|
|
237
235
|
Example: generate_map(place="Tokyo Station")
|
|
238
236
|
"""
|
|
239
|
-
body: dict = {"place": place
|
|
240
|
-
|
|
237
|
+
body: dict = {"place": place}
|
|
238
|
+
if name:
|
|
239
|
+
body["name"] = name
|
|
240
|
+
return await _generate_map_common(body, ctx, label=place)
|
|
241
241
|
|
|
242
242
|
|
|
243
243
|
# ---------------------------------------------------------------------------
|
|
@@ -253,19 +253,25 @@ async def generate_markers_map(
|
|
|
253
253
|
str | None,
|
|
254
254
|
Field(description="Optional: place to center the map on. If omitted, the center is computed automatically from the markers."),
|
|
255
255
|
] = None,
|
|
256
|
+
name: Annotated[
|
|
257
|
+
str | None,
|
|
258
|
+
Field(description="Optional: display name for the map. If omitted, the server derives one automatically from place/markers."),
|
|
259
|
+
] = None,
|
|
256
260
|
ctx: Context = None,
|
|
257
261
|
) -> list:
|
|
258
262
|
"""Generate a map with multiple pinned locations.
|
|
259
263
|
|
|
260
|
-
Example: generate_markers_map(markers=[{"label": "Tokyo Tower"}, {"label": "Zojoji Temple"}])
|
|
264
|
+
Example: generate_markers_map(markers=[{"label": "Tokyo Tower", "link": "https://www.tokyotower.co.jp/"}, {"label": "Zojoji Temple"}])
|
|
261
265
|
"""
|
|
262
266
|
if not markers:
|
|
263
267
|
raise ValueError("'markers' must contain at least one marker.")
|
|
264
268
|
label = place or "_".join(m.label for m in markers)[:40]
|
|
265
|
-
body: dict = {"markers": [m.model_dump(exclude_none=True) for m in markers]
|
|
269
|
+
body: dict = {"markers": [m.model_dump(exclude_none=True) for m in markers]}
|
|
266
270
|
if place:
|
|
267
271
|
body["place"] = place
|
|
268
|
-
|
|
272
|
+
if name:
|
|
273
|
+
body["name"] = name
|
|
274
|
+
return await _generate_map_common(body, ctx, label=label)
|
|
269
275
|
|
|
270
276
|
|
|
271
277
|
# ---------------------------------------------------------------------------
|
|
@@ -284,6 +290,10 @@ async def generate_route_map(
|
|
|
284
290
|
str | None,
|
|
285
291
|
Field(description="Optional: place to center the map on. If omitted, the center is computed automatically from the route."),
|
|
286
292
|
] = None,
|
|
293
|
+
name: Annotated[
|
|
294
|
+
str | None,
|
|
295
|
+
Field(description="Optional: display name for the map. If omitted, the server derives one automatically from place/route."),
|
|
296
|
+
] = None,
|
|
287
297
|
ctx: Context = None,
|
|
288
298
|
) -> list:
|
|
289
299
|
"""Compute a walking/driving route between two places and generate a map with it overlaid.
|
|
@@ -296,83 +306,50 @@ async def generate_route_map(
|
|
|
296
306
|
# いたが、それだと地図生成用の道路データ取得と合わせて同じ範囲の道路網を2回取得する
|
|
297
307
|
# ことになっていたため、サーバー側で1回にまとめた)。
|
|
298
308
|
label = place or "route"
|
|
299
|
-
body: dict = {"route": {"from": {"label": from_}, "to": {"label": to}, "mode": mode}
|
|
300
|
-
if place:
|
|
301
|
-
body["place"] = place
|
|
302
|
-
return await _generate_map_common(body, ctx)
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
# ---------------------------------------------------------------------------
|
|
306
|
-
# Tool: generate_hyperlink_map
|
|
307
|
-
# ---------------------------------------------------------------------------
|
|
308
|
-
|
|
309
|
-
@mcp.tool()
|
|
310
|
-
async def generate_hyperlink_map(
|
|
311
|
-
markers: Annotated[
|
|
312
|
-
list[Marker],
|
|
313
|
-
Field(description="Locations to pin. At least one required, and at least one marker must "
|
|
314
|
-
"have 'link' set (its official website URL) — otherwise use generate_markers_map instead."),
|
|
315
|
-
],
|
|
316
|
-
place: Annotated[
|
|
317
|
-
str | None,
|
|
318
|
-
Field(description="Optional: place to center the map on. If omitted, the center is computed automatically from the markers."),
|
|
319
|
-
] = None,
|
|
320
|
-
ctx: Context = None,
|
|
321
|
-
) -> list:
|
|
322
|
-
"""Generate a map with pinned locations whose website links are clickable in the resulting map link.
|
|
323
|
-
Requires at least one marker to have 'link' set — use generate_markers_map if none do.
|
|
324
|
-
|
|
325
|
-
Example: generate_hyperlink_map(markers=[{"label": "Tokyo Tower", "link": "https://www.tokyotower.co.jp/"}])
|
|
326
|
-
"""
|
|
327
|
-
if not markers:
|
|
328
|
-
raise ValueError("'markers' must contain at least one marker.")
|
|
329
|
-
if not any(m.link for m in markers):
|
|
330
|
-
raise ValueError(
|
|
331
|
-
"generate_hyperlink_map requires at least one marker with 'link' set. "
|
|
332
|
-
"Use generate_markers_map instead if no marker has a link."
|
|
333
|
-
)
|
|
334
|
-
label = place or "_".join(m.label for m in markers)[:40]
|
|
335
|
-
body: dict = {"markers": [m.model_dump(exclude_none=True) for m in markers], "name": label}
|
|
309
|
+
body: dict = {"route": {"from": {"label": from_}, "to": {"label": to}, "mode": mode}}
|
|
336
310
|
if place:
|
|
337
311
|
body["place"] = place
|
|
338
|
-
|
|
312
|
+
if name:
|
|
313
|
+
body["name"] = name
|
|
314
|
+
return await _generate_map_common(body, ctx, label=label)
|
|
339
315
|
|
|
340
316
|
|
|
341
317
|
# ---------------------------------------------------------------------------
|
|
342
|
-
# Tool:
|
|
318
|
+
# Tool: download_map
|
|
343
319
|
# ---------------------------------------------------------------------------
|
|
344
320
|
|
|
345
321
|
@mcp.tool()
|
|
346
|
-
async def
|
|
322
|
+
async def download_map(
|
|
347
323
|
data_key: Annotated[
|
|
348
324
|
str,
|
|
349
325
|
Field(description="The dataKey returned by a generate_* call that reported it was still in progress."),
|
|
350
326
|
],
|
|
351
327
|
ctx: Context = None,
|
|
352
328
|
) -> list:
|
|
353
|
-
"""
|
|
329
|
+
"""Check a pending generate_* job and download it once ready. If it's already done, returns
|
|
330
|
+
the image immediately; otherwise waits internally (checking periodically) before returning —
|
|
331
|
+
no need to wait between calls yourself. If still not ready when it returns, call it again
|
|
332
|
+
with the same dataKey.
|
|
354
333
|
|
|
355
|
-
Example:
|
|
334
|
+
Example: download_map(data_key="20260618aBcDeFgHiJ")
|
|
356
335
|
"""
|
|
357
336
|
async with httpx.AsyncClient() as client:
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
status_resp = await client.get(f"{BASE_URL}/status", params={"dataKey": data_key}, timeout=10)
|
|
361
|
-
status = status_resp.json().get("status")
|
|
337
|
+
status_json = await _poll_with_budget(client, data_key, POLL_BUDGET_SEC, ctx, sleep_first=False)
|
|
338
|
+
status = status_json.get("status")
|
|
362
339
|
if status == "failed":
|
|
363
340
|
raise RuntimeError(
|
|
364
341
|
f"Map generation failed (dataKey={data_key}). "
|
|
365
342
|
"Try a different location."
|
|
366
343
|
)
|
|
367
344
|
if status != "ready":
|
|
368
|
-
if ctx is not None:
|
|
369
|
-
await ctx.report_progress(0, 1, "Map generation still in progress...")
|
|
370
345
|
return _still_in_progress_result(data_key)
|
|
371
346
|
|
|
372
347
|
image_bytes = await _download(client, data_key, "png", None)
|
|
373
|
-
has_link = await _has_any_link(client, data_key)
|
|
374
348
|
|
|
375
|
-
return _build_success_result(
|
|
349
|
+
return _build_success_result(
|
|
350
|
+
image_bytes, _make_filename(data_key, "png"), data_key,
|
|
351
|
+
status_json["downloadUrl"], status_json["editorUrl"],
|
|
352
|
+
)
|
|
376
353
|
|
|
377
354
|
|
|
378
355
|
# ---------------------------------------------------------------------------
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
3
|
"title": "MapNetwork MCP - 入力JSON仕様",
|
|
4
|
-
"description": "mapnetwork_mcp/server.py で定義されている
|
|
4
|
+
"description": "mapnetwork_mcp/server.py で定義されている5つのMCPツールの入力パラメータ仕様。各属性の型・デフォルト値・設定可能値(enum)・制約を示す。",
|
|
5
5
|
"definitions": {
|
|
6
6
|
"Marker": {
|
|
7
7
|
"type": "object",
|
|
8
|
-
"description": "generate_markers_map
|
|
8
|
+
"description": "generate_markers_mapが使う、地図上にピン留めする地点。labelは必須、linkは任意で公式サイトURLを付けられる(バックエンド側がPlaces APIで自動補完する場合も多い)。link無しのマーカーが混在してもよい(むしろ通常はこちら)。以前はgenerate_hyperlink_mapという別ツールが同じMarker型を使い、markers全体のうち少なくとも1件がlinkを持つことを追加要求していたが、Places APIによるlink自動補完でgenerate_markers_mapとの差が実質無くなったため廃止された",
|
|
9
9
|
"properties": {
|
|
10
10
|
"label": { "type": "string", "description": "地名(ジオコーディング・表示用)" },
|
|
11
11
|
"link": { "type": ["string", "null"], "default": null, "description": "その地点の公式サイトURL(既知の場合のみ設定)" }
|
|
@@ -29,14 +29,15 @@
|
|
|
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
|
|
36
|
+
"constraints": ["nameを指定すればそのままconfigDict.nameに使われる。未指定ならバックエンド側がplaceの値をそのまま設定する"],
|
|
36
37
|
"example": { "place": "Tokyo Station" }
|
|
37
38
|
},
|
|
38
39
|
"generate_markers_map": {
|
|
39
|
-
"description": "複数の地点をピン留めした地図画像を生成する。各地点は任意でlink
|
|
40
|
+
"description": "複数の地点をピン留めした地図画像を生成する。各地点は任意でlinkを持てる(一部/全部/どれもlinkを持たなくてもよい)。常にデフォルトのカラーテーマ・PNG形式でダウンロードする",
|
|
40
41
|
"type": "object",
|
|
41
42
|
"properties": {
|
|
42
43
|
"markers": {
|
|
@@ -45,15 +46,16 @@
|
|
|
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
|
-
"markersのいずれかがlink
|
|
54
|
-
"configDict.name
|
|
55
|
+
"markersのいずれかがlink(明示指定またはバックエンド側のPlaces API自動補完)を持つ場合、成功レスポンスの'Open in editor'リンクに&lock=trueが付き、閲覧専用モードでそのmarkerがクリック可能になる(判定はどのツールを呼んだかではなく実データによる)",
|
|
56
|
+
"nameを指定すればそのままconfigDict.nameに使われる。未指定ならバックエンド側がplace(未指定ならmarkersのlabelを連結した文字列)を自動設定する"
|
|
55
57
|
],
|
|
56
|
-
"example": { "markers": [{ "label": "Tokyo Tower" }, { "label": "Zojoji Temple" }] }
|
|
58
|
+
"example": { "markers": [{ "label": "Tokyo Tower", "link": "https://www.tokyotower.co.jp/" }, { "label": "Zojoji Temple" }] }
|
|
57
59
|
},
|
|
58
60
|
"generate_route_map": {
|
|
59
61
|
"description": "2地点間の徒歩/車ルートを計算し、それを重ねた地図画像を1回の呼び出しで生成する。ルート探索と地図生成が別ツールに分かれていた旧設計(compute_route→generate_route_mapの2段階)は、MCPホスト側にとって難易度が高すぎたため統合された。ルートの両端点は地図上に自動でピン留めされる。常にデフォルトのカラーテーマ・PNG形式でダウンロードする",
|
|
@@ -66,39 +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
|
|
79
|
+
"nameを指定すればそのままconfigDict.nameに使われる。未指定ならバックエンド側がplace(未指定なら'route'固定文字列)を自動設定する"
|
|
77
80
|
],
|
|
78
81
|
"example": { "from": "Tokyo Station", "to": "Tokyo Tower", "mode": "walking" }
|
|
79
82
|
},
|
|
80
|
-
"
|
|
81
|
-
"description": "
|
|
82
|
-
"type": "object",
|
|
83
|
-
"properties": {
|
|
84
|
-
"markers": {
|
|
85
|
-
"type": "array",
|
|
86
|
-
"description": "地図上にピン留めする地点リスト(1件以上必須、かつ少なくとも1件はlinkを持つ必要がある)",
|
|
87
|
-
"items": { "$ref": "#/definitions/Marker" },
|
|
88
|
-
"minItems": 1
|
|
89
|
-
},
|
|
90
|
-
"place": { "type": ["string", "null"], "default": null, "description": "地図の中心とする地名。未指定ならmarkersの座標群から自動計算される" }
|
|
91
|
-
},
|
|
92
|
-
"required": ["markers"],
|
|
93
|
-
"constraints": [
|
|
94
|
-
"markersは1件以上必須",
|
|
95
|
-
"markersのうち少なくとも1件はlinkを持つ必要がある(ツール側でバリデーション、Marker定義自体はlinkを任意としている)。持たない場合はエラーになり、generate_markers_mapの使用を促すメッセージが返る",
|
|
96
|
-
"configDict.nameにはサーバー側がplace(未指定ならmarkersのlabelを連結した文字列)を自動設定する"
|
|
97
|
-
],
|
|
98
|
-
"example": { "markers": [{ "label": "Zojoji Temple" }, { "label": "Tokyo Tower", "link": "https://www.tokyotower.co.jp/" }] }
|
|
99
|
-
},
|
|
100
|
-
"check_map_status": {
|
|
101
|
-
"description": "generate_*ツールが未完了(pending)を返した場合のジョブをポーリングし、完了していればデフォルトのカラーテーマ・PNG形式でダウンロードする",
|
|
83
|
+
"download_map": {
|
|
84
|
+
"description": "generate_*ツールが未完了(pending)を返した場合のジョブを確認し、完了していればデフォルトのカラーテーマ・PNG形式でダウンロードする。まだ完了していなければ内部で待機してから再確認するため、呼び出し側で待つ必要はない",
|
|
102
85
|
"type": "object",
|
|
103
86
|
"properties": {
|
|
104
87
|
"data_key": { "type": "string", "description": "generate_*ツールが返したdataKey", "required": true }
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
3
|
"title": "MapNetwork MCP - 出力JSON仕様",
|
|
4
|
-
"description": "mapnetwork_mcp/server.py で定義されている
|
|
4
|
+
"description": "mapnetwork_mcp/server.py で定義されている5つのMCPツールの戻り値(MCPのCallToolResult)の仕様。各ツールの実装(FastMCPの変換ルールを含む)から実機検証して起こしたもの。",
|
|
5
5
|
"notes": [
|
|
6
|
-
"全ツールとも戻り値の型注釈が具体的な型パラメータを持たない 'list' であるため、FastMCPは構造化出力(structuredContent/tools/listのoutputSchema)を生成しない。実機確認済み:
|
|
7
|
-
"全
|
|
6
|
+
"全ツールとも戻り値の型注釈が具体的な型パラメータを持たない 'list' であるため、FastMCPは構造化出力(structuredContent/tools/listのoutputSchema)を生成しない。実機確認済み:5ツールすべてtools/listのoutputSchemaはnull、tools/callのstructuredContentも常にnull。呼び出し側はcontent配列(テキスト/画像)のみをパースすればよい。",
|
|
7
|
+
"全5ツールとも'list'を返す関数で、リストの各要素がFastMCPによってcontentの1項目に変換される:Imageインスタンス→ImageContent、文字列→TextContent。",
|
|
8
8
|
"ツール内で例外(ValueError/RuntimeError、または引数バリデーション失敗によるpydantic.ValidationError、httpxの接続エラー等)が送出された場合、FastMCPがそれを捕捉し、isError=trueと単一のTextContentに包んで返す。テキストの形式は常に 'Error executing tool <tool_name>: <str(exception)>'。ツール関数の中身でtry/exceptしてエラーメッセージを整形している箇所(Request rejected/Map generation failed等)もこの共通ラッパーの中を通る。",
|
|
9
9
|
"pydantic.ValidationErrorのstr()は複数行になる(フィールドパス、エラー種別、入力値、pydantic.devのドキュメントURLを含む)。例:\"1 validation error for generate_markers_mapArguments\\nmarkers.0.place\\n Extra inputs are not permitted [type=extra_forbidden, input_value='Tokyo', input_type=str]\\n For further information visit https://errors.pydantic.dev/2.13/v/extra_forbidden\"",
|
|
10
10
|
"redownload_mapのImageContentのmimeTypeは、指定したformat引数に連動する:format='png'なら'image/png'、format='svg'なら'image/svg+xml'(SVGの正式なMIMEタイプ。Image(format=...)ヘルパーはformat文字列をそのまま'image/{format}'に埋め込むだけなので、サーバー側で'svg'→'svg+xml'に変換してから渡している。過去バージョンではformat='svg'でもmimeTypeが常に'image/png'になる不具合があったが修正済み)。"
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
},
|
|
55
55
|
"PendingResult": {
|
|
56
56
|
"type": "object",
|
|
57
|
-
"description": "generate_
|
|
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>). ...
|
|
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_*系
|
|
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\\
|
|
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
|
}
|
|
@@ -110,12 +110,13 @@
|
|
|
110
110
|
"error": { "$ref": "#/definitions/ErrorResult" }
|
|
111
111
|
},
|
|
112
112
|
"notes": [
|
|
113
|
-
"successのcontent[1].textにある
|
|
114
|
-
" linkあり: '
|
|
113
|
+
"successのcontent[1].textにあるOpen in editorリンクは、生成された地図のplaceDictにlinkを持つマーカーが1つでもあるかどうかで&lock=trueの有無が動的に切り替わる(_has_any_link):",
|
|
114
|
+
" linkあり: 'Open in editor: https://mapnetwork.app/generate?dataKey=<dataKey>&lock=true'",
|
|
115
115
|
" linkなし: 'Open in editor: https://mapnetwork.app/generate?dataKey=<dataKey>'",
|
|
116
|
-
"generate_mapはmarkersを持たないので、通常はlink
|
|
116
|
+
"generate_mapはmarkersを持たないので、通常はlinkなし(&lock=trueなし)になる",
|
|
117
|
+
"Downloadリンク(https://mapnetwork.app/download?dataKey=<dataKey>)も常に含まれる"
|
|
117
118
|
],
|
|
118
|
-
"example_success_text": "Map saved: C:\\Users\\you\\Downloads\\map_Tokyo_Station_20260618_120000.png\ndataKey: 20260618aBcDeFgHiJ\n\nOpen in editor: https://mapnetwork.app/generate?dataKey=20260618aBcDeFgHiJ\n\nTip: call redownload_map(data_key='20260618aBcDeFgHiJ', ...) to get this map in a different color theme or format (svg/png) without regenerating.",
|
|
119
|
+
"example_success_text": "Map saved: C:\\Users\\you\\Downloads\\map_Tokyo_Station_20260618_120000.png\ndataKey: 20260618aBcDeFgHiJ\n\nDownload: https://mapnetwork.app/download?dataKey=20260618aBcDeFgHiJ\nOpen in editor: https://mapnetwork.app/generate?dataKey=20260618aBcDeFgHiJ\n\nTip: call redownload_map(data_key='20260618aBcDeFgHiJ', ...) to get this map in a different color theme or format (svg/png) without regenerating.",
|
|
119
120
|
"example_error_texts": [
|
|
120
121
|
"Error executing tool generate_map: All connection attempts failed",
|
|
121
122
|
"Error executing tool generate_map: Request rejected (400): <backend error detail>",
|
|
@@ -129,8 +130,8 @@
|
|
|
129
130
|
"error": { "$ref": "#/definitions/ErrorResult" }
|
|
130
131
|
},
|
|
131
132
|
"notes": [
|
|
132
|
-
"
|
|
133
|
-
"markersの中にlinkを持つものが1件でもあれば、successのcontent[1].textの
|
|
133
|
+
"markersのMarker型(label必須+link任意)はlink有無を問わず1件以上あれば成功する(全markerがlink無しなのが通常のケースだが、必須ではない)。",
|
|
134
|
+
"markersの中にlinkを持つものが1件でもあれば、successのcontent[1].textのOpen in editorリンクに'&lock=true'が付く(_has_any_link)。全markerがlink未設定なら付かない。"
|
|
134
135
|
],
|
|
135
136
|
"example_error_texts": [
|
|
136
137
|
"Error executing tool generate_markers_map: 'markers' must contain at least one marker.",
|
|
@@ -145,8 +146,8 @@
|
|
|
145
146
|
},
|
|
146
147
|
"notes": [
|
|
147
148
|
"compute_routeという別ツールは存在せず(廃止済み)、専用のルート探索エンドポイントも存在しない(こちらも廃止済み)。generate_route_mapは{\"from\":{\"label\":...}, \"to\":{\"label\":...}, \"mode\":...}をそのままバックエンドの/requestのrouteフィールドに詰めて1回だけ送るだけで、ジオコード・ルート探索・地図生成は全てバックエンドのワーカー内(build_map_data)で行われる。ルート探索は地図生成用に取得した道路データをそのまま再利用するため、道路網の二重取得が発生しない。",
|
|
148
|
-
"from/toはmarkerとして自動でピン留めされるが、linkを持たせる手段は無い。そのため生成データにlink
|
|
149
|
-
"ルート探索がバックエンド内(ワーカー)で行われるため、「ルートが見つからない」等の失敗はgenerate_route_map呼び出し時点では判明せず、他のgenerate_*ツールと同じ一般的な地図生成失敗('Map generation failed (dataKey=...). Try a different location.')として現れる。
|
|
149
|
+
"from/toはmarkerとして自動でピン留めされるが、linkを持たせる手段は無い。そのため生成データにlinkを持つエントリは発生せず、成功時のOpen in editorリンクに'&lock=true'は付かない。",
|
|
150
|
+
"ルート探索がバックエンド内(ワーカー)で行われるため、「ルートが見つからない」等の失敗はgenerate_route_map呼び出し時点では判明せず、他のgenerate_*ツールと同じ一般的な地図生成失敗('Map generation failed (dataKey=...). Try a different location.')として現れる。POLL_BUDGET_SEC(40秒)以内に失敗が判明すればそのままエラーとして返るが、それより時間がかかる場合は一旦pendingが返り、download_map経由で最終的に失敗が判明する。"
|
|
150
151
|
],
|
|
151
152
|
"example_error_texts": [
|
|
152
153
|
"Error executing tool generate_route_map: All connection attempts failed",
|
|
@@ -155,23 +156,7 @@
|
|
|
155
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"
|
|
156
157
|
]
|
|
157
158
|
},
|
|
158
|
-
"
|
|
159
|
-
"returns": {
|
|
160
|
-
"success": { "$ref": "#/definitions/MapSuccessResult" },
|
|
161
|
-
"pending": { "$ref": "#/definitions/PendingResult" },
|
|
162
|
-
"error": { "$ref": "#/definitions/ErrorResult" }
|
|
163
|
-
},
|
|
164
|
-
"notes": [
|
|
165
|
-
"generate_markers_mapと同一のMarker型(label必須+link任意)を使うが、ツール本体が追加のバリデーションとして「markersのうち少なくとも1件はlinkを持つこと」を要求する(Pydanticモデルのextra=\"forbid\"とは別に、関数内でanyチェックしている)。1件も持たない場合は下記example_error_textsの3件目のエラーになる。",
|
|
166
|
-
"markersの中にlinkを持つものが1件でもあれば、successのcontent[1].textの2行目が'hyperlink Map: .../generate?dataKey=...&lock=true'になる(バリデーションを通過した時点で必ず1件以上linkを持つため、generate_hyperlink_mapの成功結果は常にhyperlink Mapリンクになり、'Open in editor'にはならない)。"
|
|
167
|
-
],
|
|
168
|
-
"example_error_texts": [
|
|
169
|
-
"Error executing tool generate_hyperlink_map: 'markers' must contain at least one marker.",
|
|
170
|
-
"Error executing tool generate_hyperlink_map: 1 validation error for generate_hyperlink_mapArguments\nmarkers.0.place\n Extra inputs are not permitted [type=extra_forbidden, input_value='Tokyo', input_type=str]\n For further information visit https://errors.pydantic.dev/2.13/v/extra_forbidden",
|
|
171
|
-
"Error executing tool generate_hyperlink_map: generate_hyperlink_map requires at least one marker with 'link' set. Use generate_markers_map instead if no marker has a link."
|
|
172
|
-
]
|
|
173
|
-
},
|
|
174
|
-
"check_map_status": {
|
|
159
|
+
"download_map": {
|
|
175
160
|
"returns": {
|
|
176
161
|
"success": { "$ref": "#/definitions/MapSuccessResult" },
|
|
177
162
|
"pending": { "$ref": "#/definitions/PendingResult" },
|
|
@@ -179,8 +164,8 @@
|
|
|
179
164
|
},
|
|
180
165
|
"notes": [
|
|
181
166
|
"successの場合、_make_filename(data_key, \"png\")でファイル名を作るため、保存パスのslugにはdataKeyがそのまま使われる(generate_*の成功時はplace/markerラベル由来のslugになるのと異なる)。",
|
|
182
|
-
"
|
|
183
|
-
"
|
|
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秒経過までブロックするため、連打しても機械的に無駄が生じない。"
|
|
184
169
|
]
|
|
185
170
|
},
|
|
186
171
|
"redownload_map": {
|
|
@@ -211,7 +196,7 @@
|
|
|
211
196
|
"text": {
|
|
212
197
|
"type": "string",
|
|
213
198
|
"pattern": "^Map saved: .+ \\(dataKey=.+, colorSet=.*, format=(png|svg)\\)$",
|
|
214
|
-
"description": "'Map saved: <path> (dataKey=<dataKey>, colorSet=<color_set|None>, format=<png|svg>)'。generate_*系と異なり
|
|
199
|
+
"description": "'Map saved: <path> (dataKey=<dataKey>, colorSet=<color_set|None>, format=<png|svg>)'。generate_*系と異なりDownload/Open in editorのリンク案内は含まれない"
|
|
215
200
|
}
|
|
216
201
|
}
|
|
217
202
|
}
|
|
@@ -224,7 +209,7 @@
|
|
|
224
209
|
},
|
|
225
210
|
"notes": [
|
|
226
211
|
"redownload_mapにはpendingパターンはない(既存dataKeyのデータを即座にダウンロードするだけで、生成ジョブのポーリングを行わない)。",
|
|
227
|
-
"successのテキストには
|
|
212
|
+
"successのテキストにはDownload/Open in editorのリンク案内自体が含まれない。元のgenerate_*呼び出し結果に含まれていたリンクをそのまま使い回す想定。",
|
|
228
213
|
"color_setを指定しない場合、text内は'colorSet=None'という文字列になる(Pythonのf-stringでNoneがそのまま埋め込まれるため)。"
|
|
229
214
|
],
|
|
230
215
|
"example_success_text": "Map saved: C:\\Users\\you\\Downloads\\map_20260618aBcDeFgHiJ_20260618_120500.svg (dataKey=20260618aBcDeFgHiJ, colorSet=black, format=svg)",
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|