@cablate/mcp-google-map 0.0.37 → 0.0.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -7
- package/dist/chunk-5KQOCTQX.js +1 -0
- package/dist/cli.js +4 -4
- package/dist/index.d.ts +11 -0
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/skills/google-maps/SKILL.md +5 -1
- package/skills/google-maps/references/tools-api.md +72 -12
- package/skills/google-maps/references/travel-planning.md +136 -0
- package/skills/project-docs/SKILL.md +66 -0
- package/skills/project-docs/references/architecture.md +135 -0
- package/skills/project-docs/references/decisions.md +149 -0
- package/skills/project-docs/references/geo-domain-knowledge.md +286 -0
- package/skills/project-docs/references/google-maps-api-guide.md +139 -0
- package/dist/chunk-TP4VNBCV.js +0 -1
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: mcp-google-map-project
|
|
3
|
+
description: Project knowledge for developing and maintaining @cablate/mcp-google-map. Architecture, Google Maps API guide, GIS domain knowledge, and design decisions. Read this skill to onboard onto the project or make informed development decisions.
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
compatibility:
|
|
6
|
+
- claude-code
|
|
7
|
+
- cursor
|
|
8
|
+
- vscode-copilot
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# mcp-google-map — Project Knowledge
|
|
12
|
+
|
|
13
|
+
## Overview
|
|
14
|
+
|
|
15
|
+
This skill contains everything needed to develop, maintain, and extend the `@cablate/mcp-google-map` MCP server. Reading these files gives you full context on architecture, API specifics, domain knowledge, and the reasoning behind design decisions.
|
|
16
|
+
|
|
17
|
+
For the **agent skill** (how to USE the tools), see `skills/google-maps/SKILL.md`.
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## Quick Orientation
|
|
22
|
+
|
|
23
|
+
| Aspect | Summary |
|
|
24
|
+
|--------|---------|
|
|
25
|
+
| **What** | MCP server providing Google Maps tools for AI agents |
|
|
26
|
+
| **Stack** | TypeScript, Node.js, Express, MCP SDK, Zod |
|
|
27
|
+
| **Tools** | 17 tools (14 atomic + 3 composite) |
|
|
28
|
+
| **Transports** | stdio, Streamable HTTP, standalone exec CLI |
|
|
29
|
+
| **APIs** | Places API (New), Directions, Geocoding, Elevation, Timezone, Weather, Air Quality, Static Maps, Search Along Route |
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## Reference Files
|
|
34
|
+
|
|
35
|
+
| File | Content | When to read |
|
|
36
|
+
|------|---------|--------------|
|
|
37
|
+
| `references/architecture.md` | System architecture, 3-layer design, transport modes, tool registration flow, 9-file checklist, code map | **Start here** when onboarding. Also read when adding new tools. |
|
|
38
|
+
| `references/google-maps-api-guide.md` | All Google Maps API endpoints used, pricing, coverage limits, rate limits, common gotchas, Places New vs Legacy | When debugging API errors, evaluating new APIs, or checking costs |
|
|
39
|
+
| `references/geo-domain-knowledge.md` | GIS fundamentals — coordinates, distance, geocoding, place types, spatial search, map projection, Japan-specific knowledge | When making tool design decisions that involve geographic concepts |
|
|
40
|
+
| `references/decisions.md` | 10 Architecture Decision Records (ADR) with context and rationale | When asking "why was X built this way?" or considering changes to existing design |
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## How to Add a New Tool
|
|
45
|
+
|
|
46
|
+
See `references/architecture.md` § "9-File Tool Change Checklist" for the complete procedure. Summary:
|
|
47
|
+
|
|
48
|
+
1. Create `src/tools/maps/<toolName>.ts` (NAME, DESCRIPTION, SCHEMA, ACTION)
|
|
49
|
+
2. Register in `src/config.ts`
|
|
50
|
+
3. Add exec case in `src/cli.ts`
|
|
51
|
+
4. Add to `tests/smoke.test.ts` (expectedTools + API call test)
|
|
52
|
+
5. Update `README.md` (count + table + exec list + project structure)
|
|
53
|
+
6. Update `skills/google-maps/SKILL.md` (Tool Map)
|
|
54
|
+
7. Update `skills/google-maps/references/tools-api.md` (params + chaining)
|
|
55
|
+
8. Check `server.json` and `package.json` descriptions
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## When to Update This Skill
|
|
60
|
+
|
|
61
|
+
| Trigger | What to update |
|
|
62
|
+
|---------|----------------|
|
|
63
|
+
| Architecture change | `references/architecture.md` |
|
|
64
|
+
| New Google Maps API integrated | `references/google-maps-api-guide.md` |
|
|
65
|
+
| New design decision made | `references/decisions.md` (add ADR) |
|
|
66
|
+
| New GIS concept relevant to tools | `references/geo-domain-knowledge.md` |
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
# Architecture Reference
|
|
2
|
+
|
|
3
|
+
## System Architecture Overview
|
|
4
|
+
|
|
5
|
+
Three-layer architecture with a shared entry point:
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
CLI / HTTP / stdio
|
|
9
|
+
|
|
|
10
|
+
BaseMcpServer <- MCP protocol layer (tool registration, transport)
|
|
11
|
+
|
|
|
12
|
+
Tool ACTION() <- thin dispatch, calls PlacesSearcher
|
|
13
|
+
|
|
|
14
|
+
PlacesSearcher <- service facade (composition, filtering, response shaping)
|
|
15
|
+
/ \
|
|
16
|
+
GoogleMapsTools NewPlacesService
|
|
17
|
+
(Legacy REST SDK) (Places API New gRPC/REST client)
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
| Layer | Files | Responsibility |
|
|
21
|
+
|---|---|---|
|
|
22
|
+
| Entry | `src/cli.ts` | Parse CLI args, select transport mode, instantiate server |
|
|
23
|
+
| Protocol | `src/core/BaseMcpServer.ts` | Register tools, handle MCP sessions, route HTTP/stdio |
|
|
24
|
+
| Tool | `src/tools/maps/*.ts` | Declare NAME, DESCRIPTION, SCHEMA, ACTION |
|
|
25
|
+
| Config | `src/config.ts` | Assemble ToolConfig[], attach MAPS_TOOL_ANNOTATIONS |
|
|
26
|
+
| Facade | `src/services/PlacesSearcher.ts` | Orchestrate multi-step / composite tools |
|
|
27
|
+
| API client (legacy) | `src/services/toolclass.ts` | Wrap `@googlemaps/google-maps-services-js` SDK |
|
|
28
|
+
| API client (new) | `src/services/NewPlacesService.ts` | Wrap `@googlemaps/places` gRPC client |
|
|
29
|
+
| Auth | `src/utils/apiKeyManager.ts` | API key priority resolution |
|
|
30
|
+
| Context | `src/utils/requestContext.ts` | Per-request AsyncLocalStorage propagation |
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## Transport Modes
|
|
35
|
+
|
|
36
|
+
| Mode | Entry | How to activate | Notes |
|
|
37
|
+
|---|---|---|---|
|
|
38
|
+
| **HTTP (Streamable)** | `cli.ts` → `BaseMcpServer.startHttpServer()` | default, or `--port` | Listens on `/mcp` (POST/GET/DELETE); sessions tracked by UUID header `mcp-session-id` |
|
|
39
|
+
| **stdio** | `cli.ts` → `BaseMcpServer.startStdio()` | `--stdio` flag | Used by Claude Desktop, Cursor; stdout reserved for JSON-RPC, all logs go to stderr |
|
|
40
|
+
| **exec CLI** | `cli.ts` → `execTool()` | `mcp-google-map exec <tool> '<json>'` | No MCP protocol; directly calls `PlacesSearcher` method and prints JSON to stdout; used for scripting/piping |
|
|
41
|
+
|
|
42
|
+
### HTTP Session Lifecycle
|
|
43
|
+
|
|
44
|
+
```
|
|
45
|
+
POST /mcp (no session-id, isInitializeRequest)
|
|
46
|
+
-> create StreamableHTTPServerTransport
|
|
47
|
+
-> create new McpServer, connect transport
|
|
48
|
+
-> store in sessions[uuid]
|
|
49
|
+
|
|
50
|
+
POST /mcp (mcp-session-id header)
|
|
51
|
+
-> reuse existing session context
|
|
52
|
+
-> update apiKey if header present
|
|
53
|
+
|
|
54
|
+
DELETE /mcp (mcp-session-id header)
|
|
55
|
+
-> terminate session, clean up transport
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## Tool Registration Flow
|
|
61
|
+
|
|
62
|
+
```
|
|
63
|
+
src/tools/maps/weather.ts exports Weather.{NAME, DESCRIPTION, SCHEMA, ACTION}
|
|
64
|
+
|
|
|
65
|
+
src/config.ts builds ToolConfig[] array, attaches MAPS_TOOL_ANNOTATIONS
|
|
66
|
+
|
|
|
67
|
+
src/cli.ts passes config.tools[] to new BaseMcpServer(name, tools)
|
|
68
|
+
|
|
|
69
|
+
BaseMcpServer.createMcpServer() calls server.registerTool(name, {description, inputSchema, annotations}, action)
|
|
70
|
+
|
|
|
71
|
+
@modelcontextprotocol/sdk exposes tool to MCP client
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
`MAPS_TOOL_ANNOTATIONS` applied to all tools:
|
|
75
|
+
|
|
76
|
+
```ts
|
|
77
|
+
{ readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true }
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
## API Key Management
|
|
83
|
+
|
|
84
|
+
Priority order (highest to lowest):
|
|
85
|
+
|
|
86
|
+
| Priority | Source | Header / Variable |
|
|
87
|
+
|---|---|---|
|
|
88
|
+
| 1 | HTTP request header | `X-Google-Maps-API-Key` |
|
|
89
|
+
| 2 | HTTP Authorization header | `Authorization: Bearer <key>` |
|
|
90
|
+
| 3 | Session-specific key | stored per `mcp-session-id` |
|
|
91
|
+
| 4 | CLI argument | `--apikey` / `-k` |
|
|
92
|
+
| 5 | Environment variable | `GOOGLE_MAPS_API_KEY` |
|
|
93
|
+
| 6 | `.env` file | loaded by `dotenv` at startup from `cwd` or package dir |
|
|
94
|
+
|
|
95
|
+
**Flow in HTTP mode**: `ApiKeyManager.getApiKey(req)` resolves key → stored in `SessionContext.apiKey` → propagated via `runWithContext()` (AsyncLocalStorage) → tool action reads from context or `process.env`.
|
|
96
|
+
|
|
97
|
+
**Flow in exec mode**: `--apikey` arg → directly passed to `new PlacesSearcher(apiKey)` constructor.
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
## Adding a New Tool — 9-File Checklist
|
|
102
|
+
|
|
103
|
+
From `CLAUDE.md`:
|
|
104
|
+
|
|
105
|
+
| # | File | What to update |
|
|
106
|
+
|---|---|---|
|
|
107
|
+
| 1 | `src/tools/maps/<toolName>.ts` | Define NAME, DESCRIPTION, SCHEMA, ACTION |
|
|
108
|
+
| 2 | `src/config.ts` | Add to `tools[]` array with annotations |
|
|
109
|
+
| 3 | `src/cli.ts` | Add to `EXEC_TOOLS` const + `switch` case in `execTool()` |
|
|
110
|
+
| 4 | `tests/smoke.test.ts` | Add to `expectedTools` array + update tool count assertions |
|
|
111
|
+
| 5 | `README.md` | Update tool count (header, comparison table, Server Info, exec mode) + Available Tools table + Project Structure |
|
|
112
|
+
| 6 | `skills/google-maps/SKILL.md` | Add row to Tool Map table |
|
|
113
|
+
| 7 | `skills/google-maps/references/tools-api.md` | Add parameter docs + chaining patterns |
|
|
114
|
+
| 8 | `server.json` | Update description if it mentions tool count |
|
|
115
|
+
| 9 | `package.json` | Update description if it mentions tool count |
|
|
116
|
+
|
|
117
|
+
Missing any file causes doc/behavior mismatch. Verify all before opening a PR.
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
## Code Map
|
|
122
|
+
|
|
123
|
+
| File | Purpose |
|
|
124
|
+
|---|---|
|
|
125
|
+
| `src/cli.ts` | CLI entry point — parses args, selects transport, dispatches exec mode |
|
|
126
|
+
| `src/config.ts` | Assembles ToolConfig[] array from all tool modules |
|
|
127
|
+
| `src/core/BaseMcpServer.ts` | MCP server core — tool registration, HTTP session management, stdio transport |
|
|
128
|
+
| `src/index.ts` | Package entry — exports Logger and re-exports public API |
|
|
129
|
+
| `src/services/PlacesSearcher.ts` | Service facade — orchestrates multi-step composite tools (planRoute, exploreArea, comparePlaces, searchAlongRoute) |
|
|
130
|
+
| `src/services/toolclass.ts` | Legacy Google Maps SDK wrapper — geocode, directions, distanceMatrix, elevation, timezone, weather, airQuality, staticMap |
|
|
131
|
+
| `src/services/NewPlacesService.ts` | Places API (New) client — searchNearby, searchText, getPlaceDetails via gRPC |
|
|
132
|
+
| `src/tools/maps/*.ts` | Individual tool definitions (17 files) — each exports NAME, DESCRIPTION, SCHEMA, ACTION |
|
|
133
|
+
| `src/utils/apiKeyManager.ts` | Singleton — resolves API key priority from headers / session / env |
|
|
134
|
+
| `src/utils/requestContext.ts` | AsyncLocalStorage — propagates API key within a single request lifecycle |
|
|
135
|
+
| `tests/smoke.test.ts` | Integration smoke tests — validates tool list, basic API calls |
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
# Architecture Decision Records — mcp-google-map
|
|
2
|
+
|
|
3
|
+
> Format: Decision / Context / Rationale
|
|
4
|
+
> Sources: dev-roadmap-spec.md, CLAUDE.md, project history
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## ADR-001: Unified `maps_` Prefix for All Tool Names
|
|
9
|
+
|
|
10
|
+
**Decision**: All tools are named with the `maps_` prefix (e.g., `maps_geocode`, `maps_search_nearby`). This was applied as a breaking change when the namespace was standardized.
|
|
11
|
+
|
|
12
|
+
**Context**: Early tool names were inconsistent — some had prefixes, some did not. As the tool count grew and the server was listed on MCP registries, namespace collisions with other MCP servers became a concern. Claude's tool selection also benefits from a clear namespace signal.
|
|
13
|
+
|
|
14
|
+
**Rationale**:
|
|
15
|
+
- Consistent namespace prevents collision when multiple MCP servers are active simultaneously.
|
|
16
|
+
- The `maps_` prefix gives Claude a strong disambiguation signal — it knows these tools are geospatial without reading descriptions.
|
|
17
|
+
- Breaking change was accepted early (pre-stable) to avoid accumulating technical debt. All 9 files in the Tool Change Checklist must be updated together on any rename.
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## ADR-002: `compare_places` Retained as a Composite Tool
|
|
22
|
+
|
|
23
|
+
**Decision**: `maps_compare_places` is a single tool that internally fetches details for multiple places and returns a structured comparison. It is not decomposed into atomic `place_details` calls that the AI chains together.
|
|
24
|
+
|
|
25
|
+
**Context**: An alternative design would have the AI call `maps_place_details` N times and synthesize the comparison itself. During testing, this produced inconsistent output quality and required users to explicitly orchestrate the chain.
|
|
26
|
+
|
|
27
|
+
**Rationale**:
|
|
28
|
+
- Users ask "compare these restaurants" and expect a comparison table, not raw data to synthesize.
|
|
29
|
+
- Composite tools reduce chaining overhead and produce deterministic, structured output.
|
|
30
|
+
- The Geo-Reasoning Benchmark (GRB) validates this: Composite Efficiency Score (CES) rewards using 1 call instead of N calls. `compare_places` is the reference case for this metric.
|
|
31
|
+
- User preference confirmed: users do not want to manually chain atomic calls for comparison tasks.
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## ADR-003: `maps_weather` and `maps_air_quality` as Separate Tools
|
|
36
|
+
|
|
37
|
+
**Decision**: Weather and air quality are exposed as two independent tools, not combined into a single `maps_environment` tool.
|
|
38
|
+
|
|
39
|
+
**Context**: A natural grouping might combine weather and air quality into one "environmental conditions" call. Both return ambient data about a location.
|
|
40
|
+
|
|
41
|
+
**Rationale**:
|
|
42
|
+
- **Different APIs**: Weather uses one endpoint; Air Quality uses `POST https://airquality.googleapis.com/v1/currentConditions:lookup` — a completely separate Google service requiring separate API enablement.
|
|
43
|
+
- **Different geographic coverage**: Weather API does not support Japan. Air Quality API fully supports Japan (including AEROS local index). Combining them would require complex conditional logic and mislead users about availability.
|
|
44
|
+
- **Different data structures and use cases**: Weather is for planning (will it rain?). Air quality is for health decisions (should I wear a mask? can elderly parents go outside?). The 7-demographic health recommendation field in air quality has no analogue in weather.
|
|
45
|
+
- **Independent billing**: Separate pricing makes cost attribution cleaner.
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## ADR-004: `maps_isochrone` Not Built
|
|
50
|
+
|
|
51
|
+
**Decision**: Isochrone generation (travel-time polygons) is excluded from the roadmap, marked as "Skip for now."
|
|
52
|
+
|
|
53
|
+
**Context**: Isochrones are a commonly requested GIS feature — "show me everywhere I can reach in 30 minutes." They are valuable for real estate analysis, event planning, and accessibility research.
|
|
54
|
+
|
|
55
|
+
**Rationale**:
|
|
56
|
+
- **Google has no native isochrone API.** All alternative implementations have disqualifying problems:
|
|
57
|
+
- Mapbox Isochrone API: mature, but introduces a second vendor (Mapbox key) alongside Google — breaks the single-provider positioning.
|
|
58
|
+
- OpenRouteService: free but rate-limited and stability uncertain for production use.
|
|
59
|
+
- Distance Matrix grid approximation: 24+ API calls per isochrone at ~$0.12/request; prohibitively expensive and low-accuracy.
|
|
60
|
+
- **Core value is visual**: An isochrone polygon is only meaningful when rendered on a map. Without `maps_static_map` to display it, returning raw GeoJSON coordinates is not useful to AI or users. The feature was deprioritized until static map rendering was in place.
|
|
61
|
+
- **Revisit path**: If built later, the best approach is Distance Matrix 8-direction probing + `maps_static_map` to render an approximated polygon. Estimated effort: 8 hours.
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## ADR-005: `maps_validate_address` Not Built
|
|
66
|
+
|
|
67
|
+
**Decision**: Address validation (checking if a postal address is deliverable) is excluded from the tool set.
|
|
68
|
+
|
|
69
|
+
**Context**: Google's Address Validation API provides USPS CASS-certified validation, deliverability flags, and address correction. It could theoretically be useful for any tool that takes address inputs.
|
|
70
|
+
|
|
71
|
+
**Rationale**:
|
|
72
|
+
- **Cost**: $17 per 1,000 requests — 3.4× the cost of standard geocoding. This is prohibitive for conversational AI use where users make casual address queries.
|
|
73
|
+
- **Wrong use case**: Address validation is designed for backend pipelines (e-commerce checkout, CRM deduplication, bulk mailing). It requires structured postal input and returns structured postal corrections — not a natural fit for natural-language AI conversations.
|
|
74
|
+
- **Coverage gap**: Only 38 countries supported; excludes most of Asia and Africa. A tool that silently fails for Tokyo or Mumbai addresses would create confusing UX.
|
|
75
|
+
- **Existing alternative**: `maps_geocode` already handles 60% of "is this address valid?" scenarios by returning whether a geocode succeeded and providing the `formatted_address` canonical form.
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
## ADR-006: Spatial Context / Session Memory Not Built
|
|
80
|
+
|
|
81
|
+
**Decision**: There is no persistent spatial context or session memory layer in the MCP server. The server does not remember previously queried locations or build a "current location" state across calls.
|
|
82
|
+
|
|
83
|
+
**Context**: A proposed feature was to maintain implicit state — if a user asks "find coffee shops" after previously mentioning "I'm in Shinjuku," the server would remember Shinjuku and use it as the implicit location for the next search.
|
|
84
|
+
|
|
85
|
+
**Rationale**:
|
|
86
|
+
- **Claude's conversation history already solves this.** Claude reads its own prior messages and can extract previously mentioned locations. A server-side memory layer would duplicate capability that already exists in the LLM.
|
|
87
|
+
- **Composite tools reduce chaining need.** Tools like `maps_explore_area` and `maps_plan_route` accept multi-intent inputs that would otherwise require chaining with location state.
|
|
88
|
+
- **Implementation risks outweigh benefits**:
|
|
89
|
+
- Implicit state leakage: state from one user's session could bleed into another in concurrent scenarios.
|
|
90
|
+
- Debugging opacity: errors become harder to trace when the server has hidden state.
|
|
91
|
+
- stdio transport has no session concept — each stdio connection is stateless by design.
|
|
92
|
+
- **User value assessed at 3/10.** In testing, users could not perceive a meaningful difference. The friction of unexpected state (wrong implicit location) outweighed the convenience.
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
## ADR-007: stdio as Primary Transport
|
|
97
|
+
|
|
98
|
+
**Decision**: The MCP server uses stdio (standard input/output) as its primary transport mechanism. HTTP/SSE is secondary.
|
|
99
|
+
|
|
100
|
+
**Context**: MCP servers can expose transport via stdio (subprocess model) or HTTP+SSE (network server model). Both are valid per the MCP specification.
|
|
101
|
+
|
|
102
|
+
**Rationale**:
|
|
103
|
+
- **MCP Registry requirement**: The official MCP registry and most client integrations (Claude Desktop, Claude Code, Cursor) prefer or require stdio-based servers for local installation.
|
|
104
|
+
- **Security model**: stdio servers run as a subprocess of the client, inheriting the client's trust context. No network port exposure, no authentication complexity.
|
|
105
|
+
- **Deployment simplicity**: `npx mcp-google-map` works out of the box without configuring ports, firewalls, or SSL.
|
|
106
|
+
- **Statelessness aligns with stdio**: Each stdio connection represents one session. This reinforces ADR-006 (no spatial context) — the transport model naturally discourages stateful designs.
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
## ADR-008: Search Along Route Uses Direct REST Calls
|
|
111
|
+
|
|
112
|
+
**Decision**: The "search along route" capability calls the Google Maps REST API directly rather than using the official `@googlemaps/google-maps-services-js` client library.
|
|
113
|
+
|
|
114
|
+
**Context**: Most tools in this project use the official client library for consistency and type safety. The route-based search requires fetching a polyline and then querying points along it — a pattern not natively supported by the client library.
|
|
115
|
+
|
|
116
|
+
**Rationale**:
|
|
117
|
+
- **Client library may not expose the required parameters or patterns** for buffered route searches. The REST API is always the source of truth; the client library is a convenience wrapper.
|
|
118
|
+
- **Direct REST calls are straightforward**: for GET requests with query parameters, `axios` or `fetch` is sufficient and keeps the implementation explicit.
|
|
119
|
+
- **Type safety can be maintained** by defining TypeScript interfaces for the REST response shapes — same outcome as using the library, without library constraints.
|
|
120
|
+
- This is an exception to the general project preference for the client library, justified by the specific technical requirement.
|
|
121
|
+
|
|
122
|
+
---
|
|
123
|
+
|
|
124
|
+
## ADR-009: MCP Prompt Templates Removed
|
|
125
|
+
|
|
126
|
+
**Decision**: MCP Prompt Templates (slash commands like `/travel-planner`) were evaluated and ultimately not shipped as a feature.
|
|
127
|
+
|
|
128
|
+
**Context**: The roadmap spec (P1-1) proposed implementing MCP's `prompts` primitive to expose slash commands in clients like Claude Desktop. The intended value was giving non-technical users a one-click entry into geo agent mode.
|
|
129
|
+
|
|
130
|
+
**Rationale**:
|
|
131
|
+
- **Client support is low and inconsistent.** As of evaluation, most MCP clients either do not render prompt templates as slash commands or render them inconsistently. The feature would benefit a small fraction of users.
|
|
132
|
+
- **SKILL.md already covers the use case** for Claude Code users — the skill system provides rich scenario guidance, chaining patterns, and example recipes that go beyond what prompt templates support.
|
|
133
|
+
- **Maintenance cost**: Prompt template content would need to stay in sync with tool capabilities, adding to the already-significant 9-file update checklist (CLAUDE.md ADR).
|
|
134
|
+
- **Revisit condition**: If MCP client support for prompts reaches broad adoption (Claude Desktop, VS Code extension, Cursor all render them consistently), this should be reconsidered. The 6-hour implementation estimate is low.
|
|
135
|
+
|
|
136
|
+
---
|
|
137
|
+
|
|
138
|
+
## ADR-010: Travel Planning Uses "Tool-Driven Diffusion," Not AI Prior Knowledge
|
|
139
|
+
|
|
140
|
+
**Decision**: Travel planning workflows are designed so the AI discovers ground truth by calling tools, not by relying on training-data knowledge of specific places, hours, or transit schedules.
|
|
141
|
+
|
|
142
|
+
**Context**: An AI could answer "what time does Kinkaku-ji open?" from training data. It could suggest a Tokyo itinerary without any tool calls based on memorized "best of Tokyo" patterns. This is faster but fragile.
|
|
143
|
+
|
|
144
|
+
**Rationale**:
|
|
145
|
+
- **Training data goes stale.** Business hours change, places close, new venues open. A tool call to `maps_place_details` returns current data; training knowledge reflects a past snapshot.
|
|
146
|
+
- **Specificity requires data.** A user asking for restaurants near their hotel requires the actual hotel coordinates, not generic neighborhood knowledge. The tool call chain (geocode hotel → search nearby → get details) produces a personalized result that training data cannot replicate.
|
|
147
|
+
- **Verifiability and trust.** When the AI cites data from a tool response (e.g., "Fushimi Inari opens at 6 AM according to Google Maps"), users can verify the source. When it speaks from training data, there is no audit trail.
|
|
148
|
+
- **The SKILL.md geo-domain knowledge** (temple hours, transit rules, energy curves) is intentionally at the *pattern* level — it tells the AI *how* to plan, not *what* specific facts are. The facts come from tools. This separation is the core design principle.
|
|
149
|
+
- Practical implementation: always geocode place names (don't assume coordinates), always fetch operating hours from `maps_place_details` (don't assume 9–5), always calculate transit time with `maps_directions` (don't estimate from distance).
|
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
# Geo Domain Knowledge for AI Map Tool Operators
|
|
2
|
+
|
|
3
|
+
> Purpose: Give an AI agent without GIS background the domain knowledge needed to use map tools correctly and confidently.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 1. Coordinate Systems
|
|
8
|
+
|
|
9
|
+
**WGS84** is the universal standard. Every latitude/longitude pair you encounter in Google Maps APIs uses WGS84. No conversion needed.
|
|
10
|
+
|
|
11
|
+
**Order convention — lat comes first:**
|
|
12
|
+
- Correct: `(35.6762, 139.6503)` — Tokyo
|
|
13
|
+
- Wrong: `(139.6503, 35.6762)` — inverted, puts you in the ocean
|
|
14
|
+
- Google Maps API parameters are always `latitude`, `longitude` in that order.
|
|
15
|
+
|
|
16
|
+
**Precision and real-world accuracy:**
|
|
17
|
+
|
|
18
|
+
| Decimal places | Precision | Notes |
|
|
19
|
+
|----------------|-----------|-------|
|
|
20
|
+
| 0 (e.g., 35°) | ~111 km | Country-level |
|
|
21
|
+
| 1 (35.6°) | ~11 km | City-level |
|
|
22
|
+
| 2 (35.67°) | ~1.1 km | District-level |
|
|
23
|
+
| 3 (35.676°) | ~111 m | Street-level |
|
|
24
|
+
| 4 (35.6762°) | ~11 m | Building-level |
|
|
25
|
+
| 5 (35.67620°) | ~1.1 m | Door-level |
|
|
26
|
+
| 6+ | <1 m | Survey-grade, rarely needed |
|
|
27
|
+
|
|
28
|
+
For navigation and place lookup, 4–5 decimal places is sufficient. Do not truncate coordinates returned by the API — pass them as-is to downstream tools.
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## 2. Distance Concepts
|
|
33
|
+
|
|
34
|
+
**Latitude degree is nearly constant worldwide:**
|
|
35
|
+
- 1° latitude ≈ 111 km everywhere
|
|
36
|
+
|
|
37
|
+
**Longitude degree varies with latitude:**
|
|
38
|
+
- At equator (0°): 1° longitude ≈ 111 km
|
|
39
|
+
- At 35°N (Tokyo/Seoul/Beijing): 1° longitude ≈ 91 km
|
|
40
|
+
- At 45°N (Paris/Milan): 1° longitude ≈ 78 km
|
|
41
|
+
- At 60°N (Oslo/Helsinki): 1° longitude ≈ 55 km
|
|
42
|
+
|
|
43
|
+
**Quick mental math:** At Tokyo's latitude, a 0.01° difference is roughly 1 km.
|
|
44
|
+
|
|
45
|
+
**Speed references for time estimation:**
|
|
46
|
+
|
|
47
|
+
| Mode | Typical speed | Notes |
|
|
48
|
+
|------|--------------|-------|
|
|
49
|
+
| Walking | ~5 km/h | 1 km = ~12 min |
|
|
50
|
+
| Cycling | ~15 km/h | varies by terrain |
|
|
51
|
+
| Urban driving | ~30–40 km/h | traffic included |
|
|
52
|
+
| Highway driving | ~80–100 km/h | intercity |
|
|
53
|
+
| Transit (urban) | ~20–30 km/h door-to-door | includes wait time |
|
|
54
|
+
| Shinkansen | ~250–300 km/h | between major cities |
|
|
55
|
+
|
|
56
|
+
These are rule-of-thumb values. Always use `maps_directions` or `maps_distance_matrix` for real travel time — actual conditions (traffic, transit schedules) differ significantly.
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## 3. Geocoding Concepts
|
|
61
|
+
|
|
62
|
+
**Forward geocoding**: address/name → lat/lng
|
|
63
|
+
- Input: "Shibuya Station, Tokyo"
|
|
64
|
+
- Output: `{ lat: 35.6580, lng: 139.7016, place_id: "ChIJ...", formatted_address: "..." }`
|
|
65
|
+
|
|
66
|
+
**Reverse geocoding**: lat/lng → address
|
|
67
|
+
- Input: `(35.6580, 139.7016)`
|
|
68
|
+
- Output: formatted address + place types for that location
|
|
69
|
+
- Use case: "What is at these coordinates?"
|
|
70
|
+
|
|
71
|
+
**place_id** — the stable identifier for a place in Google's database:
|
|
72
|
+
- Format: `ChIJN1t_tDeuEmsRUsoyG83frY4` (opaque string)
|
|
73
|
+
- Stable across time (unlike coordinates, which can shift if a business moves)
|
|
74
|
+
- Preferred input for `maps_place_details` — faster and more precise than re-searching by name
|
|
75
|
+
- Always cache `place_id` when you receive it; reuse in subsequent calls
|
|
76
|
+
|
|
77
|
+
**formatted_address vs raw input:**
|
|
78
|
+
- `formatted_address` is Google's canonical form: `"2 Chome-21-1 Asakusa, Taito City, Tokyo 111-0032, Japan"`
|
|
79
|
+
- Use it for display and for chaining into other tools that accept address strings
|
|
80
|
+
- Do not invent or modify addresses — only pass what Google returned
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
## 4. Place Types
|
|
85
|
+
|
|
86
|
+
Google's place type system is hierarchical. A place can have multiple types (e.g., a convenience store is both `convenience_store` and `store`).
|
|
87
|
+
|
|
88
|
+
**Common type categories:**
|
|
89
|
+
|
|
90
|
+
| Category | Examples |
|
|
91
|
+
|----------|---------|
|
|
92
|
+
| Food & drink | `restaurant`, `cafe`, `bar`, `bakery`, `meal_takeaway`, `food` |
|
|
93
|
+
| Lodging | `lodging`, `hotel`, `hostel`, `guest_house` |
|
|
94
|
+
| Transport | `train_station`, `subway_station`, `bus_station`, `airport`, `transit_station` |
|
|
95
|
+
| Culture | `museum`, `art_gallery`, `library`, `church`, `temple`, `shrine` |
|
|
96
|
+
| Nature | `park`, `natural_feature`, `campground`, `amusement_park` |
|
|
97
|
+
| Health | `hospital`, `pharmacy`, `doctor`, `dentist` |
|
|
98
|
+
| Shopping | `shopping_mall`, `supermarket`, `convenience_store`, `clothing_store` |
|
|
99
|
+
| Finance | `bank`, `atm` |
|
|
100
|
+
| Education | `school`, `university` |
|
|
101
|
+
| Government | `local_government_office`, `post_office`, `police` |
|
|
102
|
+
|
|
103
|
+
**How to pick the right type for search:**
|
|
104
|
+
- Be specific for precision: `ramen_restaurant` > `restaurant` when you know what you want
|
|
105
|
+
- Use broader types for exploration: `food` catches everything edible
|
|
106
|
+
- Some types are not searchable (too broad) — prefer specific leaf-level types
|
|
107
|
+
- Compound queries work: pass `keyword="ramen"` with `type="restaurant"` for best results
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
## 5. Routing and Navigation
|
|
112
|
+
|
|
113
|
+
**Travel modes:**
|
|
114
|
+
|
|
115
|
+
| Mode | Parameter | Notes |
|
|
116
|
+
|------|-----------|-------|
|
|
117
|
+
| Driving | `DRIVE` | Default, uses current traffic |
|
|
118
|
+
| Walking | `WALK` | No highways, includes pedestrian paths |
|
|
119
|
+
| Cycling | `BICYCLE` | Not available in all regions |
|
|
120
|
+
| Transit | `TRANSIT` | Requires `departure_time` for accurate results |
|
|
121
|
+
|
|
122
|
+
**Key rule for transit**: Always provide `departure_time` (Unix timestamp). Without it, Google may use default schedules that don't reflect actual service patterns. For planning tools, use a future timestamp on a weekday.
|
|
123
|
+
|
|
124
|
+
**Overview polyline:**
|
|
125
|
+
- A compressed string encoding the entire route path (e.g., `_p~iF~ps|U_ulLnnqC_mqNvxq`@`)
|
|
126
|
+
- Encoded in Google's Polyline Algorithm (each character represents coordinate delta)
|
|
127
|
+
- Use it when you need to pass the route to `maps_static_map` for visualization
|
|
128
|
+
- Do not try to decode it manually — pass it as-is to display tools
|
|
129
|
+
|
|
130
|
+
**Waypoints and stops:**
|
|
131
|
+
- Routes can include intermediate waypoints
|
|
132
|
+
- Optimize waypoint order with `optimize=true` for multi-stop itineraries
|
|
133
|
+
- For Tokyo sightseeing: always think about natural geographic flow (e.g., north→south or circular) to minimize backtracking
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
## 6. Map Projections
|
|
138
|
+
|
|
139
|
+
**Mercator projection** is what Google Maps (and virtually all web maps) uses.
|
|
140
|
+
|
|
141
|
+
Key distortion property: **area is not preserved, shape is**. The further from the equator, the larger things appear relative to their true size.
|
|
142
|
+
|
|
143
|
+
| Location | Apparent size on map vs reality |
|
|
144
|
+
|----------|--------------------------------|
|
|
145
|
+
| Africa vs Greenland | Africa is 14x larger in reality, but they look similar on Mercator |
|
|
146
|
+
| Japan (~35°N) | Moderate distortion, cities appear roughly accurate |
|
|
147
|
+
| Scandinavia (~60°N) | Significantly overstated on map |
|
|
148
|
+
|
|
149
|
+
**Why this matters for `maps_static_map`:**
|
|
150
|
+
- At the same zoom level, a 600x400 tile covers more actual ground at higher latitudes
|
|
151
|
+
- Zoom 12 in Tokyo covers ~10 km across; zoom 12 in Tokyo's northern suburbs covers slightly more
|
|
152
|
+
- Zoom guidelines for `maps_static_map`:
|
|
153
|
+
|
|
154
|
+
| Zoom | Coverage |
|
|
155
|
+
|------|---------|
|
|
156
|
+
| 1 | World |
|
|
157
|
+
| 5 | Continent/large country |
|
|
158
|
+
| 10 | City |
|
|
159
|
+
| 12 | District |
|
|
160
|
+
| 14 | Neighborhood |
|
|
161
|
+
| 16 | Streets |
|
|
162
|
+
| 18 | Building-level |
|
|
163
|
+
| 20 | Room-level (where available) |
|
|
164
|
+
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
## 7. Spatial Search Types
|
|
168
|
+
|
|
169
|
+
**Circular search (radius-based):**
|
|
170
|
+
- Definition: find places within N meters of a center point
|
|
171
|
+
- API: `maps_search_nearby` with `radius` parameter
|
|
172
|
+
- Best for: "coffee shops near me," "ATM within 500m"
|
|
173
|
+
- Limitation: covers uniform area regardless of walkability — a 500m radius includes both sides of a river
|
|
174
|
+
|
|
175
|
+
**Search along route:**
|
|
176
|
+
- Definition: find places near any point on a route path
|
|
177
|
+
- Requires: route polyline from `maps_directions`
|
|
178
|
+
- Best for: "rest stops between Tokyo and Osaka," "gas stations on the way"
|
|
179
|
+
- Implementation: buffer the polyline, search at interval waypoints
|
|
180
|
+
|
|
181
|
+
**Bounding box search:**
|
|
182
|
+
- Definition: find everything within a lat/lng rectangle
|
|
183
|
+
- Best for: "all museums in Kyoto" (known geographic area)
|
|
184
|
+
- Less precise than radius — corners are farther from center than edge midpoints
|
|
185
|
+
|
|
186
|
+
**Choosing the right approach:**
|
|
187
|
+
|
|
188
|
+
| Scenario | Use |
|
|
189
|
+
|----------|-----|
|
|
190
|
+
| Near a specific point | Circular (radius) |
|
|
191
|
+
| Along a travel path | Route-based |
|
|
192
|
+
| Within a city/district | Bounding box or large radius from city center |
|
|
193
|
+
| "Best of" in an area | Keyword search + type filter |
|
|
194
|
+
|
|
195
|
+
---
|
|
196
|
+
|
|
197
|
+
## 8. Travel Planning Domain Knowledge
|
|
198
|
+
|
|
199
|
+
**Time-of-day sensitivity:**
|
|
200
|
+
- Early morning (6–9 AM): temples/shrines are quieter, markets open
|
|
201
|
+
- Midday (11 AM–2 PM): lunch crowds at restaurants; museums uncrowded
|
|
202
|
+
- Late afternoon (3–5 PM): good for viewpoints and gardens (golden hour light)
|
|
203
|
+
- Evening (5–8 PM): best for dining, night markets, illuminated landmarks
|
|
204
|
+
- Night (8 PM+): limited temple access, izakayas peak, Tokyo Skytree views
|
|
205
|
+
|
|
206
|
+
**Arc routing principle:**
|
|
207
|
+
- Design routes that move in one general direction, then return — avoid ping-pong backtracking
|
|
208
|
+
- Example: Asakusa → Ueno → Akihabara (east→center→east) is efficient; Shinjuku → Asakusa → Shinjuku is not
|
|
209
|
+
|
|
210
|
+
**Energy curve (fatigue model):**
|
|
211
|
+
- Morning: high energy → schedule physically demanding activities (hills, many stairs)
|
|
212
|
+
- Midday: lunch + rest → schedule museum interiors, air-conditioned venues
|
|
213
|
+
- Afternoon: moderate energy → walking tours, shopping
|
|
214
|
+
- Evening: low energy → seated dining, short walks only
|
|
215
|
+
|
|
216
|
+
**Meal timing:**
|
|
217
|
+
- Breakfast: 7–9 AM
|
|
218
|
+
- Lunch: 11:30 AM–1:30 PM (plan to arrive before 12 to avoid queues)
|
|
219
|
+
- Dinner: 6–8 PM (popular spots fill by 6:30)
|
|
220
|
+
- Always build 15–20 min buffer for transit between meals and activities
|
|
221
|
+
|
|
222
|
+
**Group size adjustments:**
|
|
223
|
+
- Solo/couple: access anywhere, no reservation usually needed
|
|
224
|
+
- Group (4–8): book restaurants ahead, check venue capacity
|
|
225
|
+
- Large group (8+): many historic sites have capacity limits (e.g., Fushimi Inari paths are narrow)
|
|
226
|
+
|
|
227
|
+
---
|
|
228
|
+
|
|
229
|
+
## 9. Japan-Specific Knowledge
|
|
230
|
+
|
|
231
|
+
### Kyoto Area Structure
|
|
232
|
+
|
|
233
|
+
Kyoto's main sightseeing zones:
|
|
234
|
+
|
|
235
|
+
| Zone | Key sites | Character |
|
|
236
|
+
|------|----------|-----------|
|
|
237
|
+
| Arashiyama (west) | Bamboo Grove, Tenryu-ji | Nature, bamboo, riverside |
|
|
238
|
+
| Higashiyama (east) | Kiyomizu-dera, Gion, Ninen-zaka | Traditional streets, temples |
|
|
239
|
+
| Fushimi (south) | Fushimi Inari | Torii gates, accessible by JR |
|
|
240
|
+
| Downtown (center) | Nijo Castle, Nishiki Market | Mix of modern and historical |
|
|
241
|
+
| Nishijin (north-center) | Kinkaku-ji, Ryoan-ji | Famous temples, crowded |
|
|
242
|
+
|
|
243
|
+
**Rule**: Arashiyama and Higashiyama are on opposite sides of the city (~1 hr by bus). Do not combine them in a half-day plan.
|
|
244
|
+
|
|
245
|
+
### Train Network
|
|
246
|
+
|
|
247
|
+
| Network | Type | Use case |
|
|
248
|
+
|---------|------|---------|
|
|
249
|
+
| Shinkansen (bullet train) | Inter-city | Tokyo↔Kyoto (2h15m), Tokyo↔Osaka (2h30m) |
|
|
250
|
+
| JR lines | Regional/urban | JR Pass compatible, connects major stations |
|
|
251
|
+
| Hankyu/Keihan/Kintetsu | Private railways | Osaka↔Kyoto alternatives, often cheaper |
|
|
252
|
+
| Tokyo Metro / Toei | Urban subway | Dense Tokyo inner-city coverage |
|
|
253
|
+
| Kyoto Bus | Urban bus | Essential for Kyoto (no subway to Arashiyama/Fushimi) |
|
|
254
|
+
|
|
255
|
+
**Practical notes:**
|
|
256
|
+
- IC cards (Suica, Pasmo, ICOCA) work on almost all trains and buses in Japan — recommend for all visitors
|
|
257
|
+
- JR Pass only covers JR-operated lines, not private railways or subways
|
|
258
|
+
- In Kyoto, bus day pass (¥700) is cost-effective for 3+ bus rides
|
|
259
|
+
|
|
260
|
+
### Temple and Shrine Access Times
|
|
261
|
+
|
|
262
|
+
| Category | Typical hours | Notes |
|
|
263
|
+
|----------|--------------|-------|
|
|
264
|
+
| Major temples (paid) | 8:30 AM – 5:00 PM | Last entry 30 min before close |
|
|
265
|
+
| Fushimi Inari | 24 hours | Lower section always open |
|
|
266
|
+
| Buddhist temple grounds | 6:00 AM – dusk | Gates/halls may have separate hours |
|
|
267
|
+
| Shrine precincts | Usually always open | Inner buildings have set hours |
|
|
268
|
+
|
|
269
|
+
**Key rule**: Always plan temple visits for morning to avoid afternoon crowds and ensure all halls are open. Schedule Fushimi Inari early morning (6–8 AM) to avoid tour groups.
|
|
270
|
+
|
|
271
|
+
### Japanese Address System
|
|
272
|
+
|
|
273
|
+
Addresses in Japan follow a reverse order from Western convention:
|
|
274
|
+
- Prefecture → City → Ward → Chome (district) → Block → Building
|
|
275
|
+
- Example: `東京都渋谷区道玄坂1丁目2-3` = Tokyo-to, Shibuya-ku, Dogenzaka 1-chome, block 2, building 3
|
|
276
|
+
- Always geocode Japanese addresses using `maps_geocode` — do not attempt to calculate coordinates from address text.
|
|
277
|
+
|
|
278
|
+
### Useful Distance References (Japan)
|
|
279
|
+
|
|
280
|
+
| Route | Distance | Transport | Time |
|
|
281
|
+
|-------|----------|-----------|------|
|
|
282
|
+
| Tokyo → Kyoto | 450 km | Nozomi Shinkansen | 2h15m |
|
|
283
|
+
| Tokyo → Osaka | 520 km | Nozomi Shinkansen | 2h30m |
|
|
284
|
+
| Kyoto → Nara | 35 km | JR Nara Line | 45m |
|
|
285
|
+
| Kyoto → Osaka | 75 km | JR/Hankyu | 15–28m |
|
|
286
|
+
| Shinjuku → Asakusa (Tokyo) | 10 km | Metro | 30m |
|