@cablate/mcp-google-map 0.0.63 → 0.0.65

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,59 @@
1
+ # Setup and diagnostics
2
+
3
+ Use this procedure before the first Google Maps CLI call in a session and when a call fails. Do not start an MCP server: these Skills use the standalone CLI.
4
+
5
+ ## Local preflight
6
+
7
+ Run the local doctor first. It makes no Google API requests and does not print the key:
8
+
9
+ ```bash
10
+ npx -y @cablate/mcp-google-map doctor
11
+ ```
12
+
13
+ Interpret its JSON checks:
14
+
15
+ - `node`: Node.js 18 or newer is required.
16
+ - `package`: the npm package and CLI entrypoint were resolved.
17
+ - `api-key`: `GOOGLE_MAPS_API_KEY` is visible to the agent process; the value stays hidden.
18
+ - `live-api: skip`: expected during local-only diagnosis and not a failure.
19
+
20
+ If the key is missing, ask the user to set `GOOGLE_MAPS_API_KEY` in the environment used to launch the agent and start a new session. Prefer the environment variable to `--apikey`; command-line keys may appear in shell history or process listings.
21
+
22
+ ## Google Cloud prerequisites
23
+
24
+ The key must belong to a Google Cloud project with billing enabled and restrictions compatible with the environment. Enable only the APIs needed by the requested tools:
25
+
26
+ | Capability | Google Maps Platform API |
27
+ |---|---|
28
+ | Address geocoding and reverse geocoding | Geocoding API |
29
+ | Text search, nearby search, place details, along-route place search, comparisons, local rank tracking | Places API (New) |
30
+ | Directions, distance matrix, waypoint optimization, along-route routing | Routes API |
31
+ | Elevation | Elevation API |
32
+ | Timezone | Time Zone API |
33
+ | Weather | Weather API |
34
+ | Air quality | Air Quality API |
35
+ | Static maps | Maps Static API |
36
+
37
+ ## Optional live diagnosis
38
+
39
+ Only run this after telling the user that it makes billable test requests:
40
+
41
+ ```bash
42
+ npx -y @cablate/mcp-google-map doctor --live
43
+ ```
44
+
45
+ It independently tests Geocoding API, Places API (New), and Routes API so one disabled capability does not hide the others. It does not validate every optional API in the table. Test an optional capability with the smallest relevant tool call only when the user's task needs it.
46
+
47
+ ## Failure classification
48
+
49
+ | Symptom | Likely cause | Next action |
50
+ |---|---|---|
51
+ | Package or command cannot be found | Node.js/npm unavailable, registry blocked, or package resolution failed | Repair Node/npm or registry access, then rerun local doctor |
52
+ | API key missing | Environment variable was not passed to the agent process | Set the variable and start a new session |
53
+ | `REQUEST_DENIED`, permission, or API-disabled error | API disabled, billing unavailable, or key restriction mismatch | Use the failed check name to review that API and the key restrictions in Google Cloud Console |
54
+ | `OVER_QUERY_LIMIT`, quota, or rate-limit error | Project quota or billing limit | Stop retries and ask the user to review quota/billing |
55
+ | Invalid request | Wrong parameters or unsupported mode | Read the selected tool's parameter reference and correct the request |
56
+ | Network or timeout error | Connectivity, proxy, DNS, or transient service issue | Report the observed failure; retry only when reasonable and requested |
57
+ | One live check fails while others pass | Capability-specific API configuration | Fix only the named API; do not claim the entire key is invalid |
58
+
59
+ Never include the API key in diagnostic output, copied commands, bug reports, or final answers.
@@ -1,84 +1,43 @@
1
1
  ---
2
2
  name: google-maps
3
- description: Use Google Maps-backed geocoding, place search, routing, and geographic analysis through the standalone @cablate/mcp-google-map CLI when a user asks about real-world locations. No MCP connection is required.
3
+ description: Search places, resolve addresses, compare routes, inspect neighborhoods, and retrieve geographic or environmental facts through the standalone @cablate/mcp-google-map CLI. Use for concrete location questions; use the travel-planning or local-seo Skill for those specialized outcomes.
4
4
  license: MIT
5
5
  ---
6
6
 
7
- # Google Maps - Geospatial Query Capabilities
7
+ # Google Maps
8
8
 
9
- ## Overview
9
+ Answer real-world location questions with the package's standalone `exec` CLI. Do not start or configure an MCP server for this workflow.
10
10
 
11
- Use the package's `exec` CLI to answer location questions without starting an MCP server. The Skill supplies tool-selection and chaining guidance; the npm package makes the API calls. The user must provide their own Google Maps Platform API key.
11
+ ## Before calling the CLI
12
12
 
13
- ---
14
-
15
- ## Core Principles
16
-
17
- | Principle | Explanation |
18
- |-----------|-------------|
19
- | Chain over single-shot | Most geo questions require 2-5 tool calls chained together. See Scenario Recipes in references/tools-api.md for the full patterns. |
20
- | Match recipe to intent | Map the user's question to a recipe (Trip Planning, Local Discovery, Route Comparison, Neighborhood Analysis, Multi-Stop, Place Comparison, Along the Route) before calling any tool. |
21
- | Precise input saves trouble | Use coordinates over address strings when available. Use place_id over name search. More precise input = more reliable output. |
22
- | Output is structured | Every tool returns JSON. Use it directly for downstream computation or comparison — no extra parsing needed. |
23
- | Present results clearly | Summarize comparisons in a table when it helps; do not pass raw JSON through as the final answer. |
24
- | Preserve source context | Google Maps content has display, attribution, and retention conditions. Read `references/content-attribution.md` before presenting place reviews, photos, or AI summaries. |
25
-
26
- ---
13
+ - On the first call in a session, or after an execution failure, read `../_shared/setup-and-diagnostics.md` and run the non-billable local preflight.
14
+ - The user must supply `GOOGLE_MAPS_API_KEY`. Never print it or place it in a command unless the user explicitly accepts shell-history and process-list exposure.
15
+ - Before presenting Places reviews, photos, or AI summaries, read `../_shared/content-attribution.md`.
27
16
 
28
- ## Tool Map
17
+ ## Workflow
29
18
 
30
- 18 tools in five categories — pick by scenario:
19
+ 1. Identify the concrete location outcome and missing inputs. Do not request details that can be resolved by geocoding or place search.
20
+ 2. Read `references/tools-api.md` when exact parameters, response fields, or a multi-tool recipe are needed.
21
+ 3. Prefer coordinates over ambiguous addresses and `place_id` over repeated name searches.
22
+ 4. Chain only the calls needed for the outcome. Reuse returned identifiers and coordinates.
23
+ 5. Treat nonzero exit status or `{ "success": false }` as a failure, not as geographic data.
24
+ 6. Summarize the useful result rather than returning raw JSON. Preserve source and attribution metadata where required.
31
25
 
32
- ### Place Discovery
33
- | Tool | When to use | Example |
34
- |------|-------------|---------|
35
- | `maps_geocode` | Have an address/landmark, need coordinates | "What are the coordinates of Tokyo Tower?" |
36
- | `maps_reverse_geocode` | Have coordinates, need an address | "What's at 35.65, 139.74?" |
37
- | `maps_search_nearby` | Know a location, find nearby places by type | "Coffee shops near my hotel" |
38
- | `maps_search_places` | Natural language place search | "Best ramen in Tokyo" |
39
- | `maps_place_details` | Have a place_id, need full info (+ optional photo URLs via `maxPhotos`) | "Opening hours and reviews for this restaurant?" |
40
- | `maps_batch_geocode` | Geocode multiple addresses at once (max 50) | "Get coordinates for all these offices" |
26
+ ## Tool selection
41
27
 
42
- ### Routing & Distance
43
- | Tool | When to use | Example |
44
- |------|-------------|---------|
45
- | `maps_directions` | How to get from A to B, including drive-only avoid-tolls/highways controls | "Route from Taipei Main Station to airport avoiding tolls" |
46
- | `maps_distance_matrix` | Compare distances across multiple points, including drive-only avoid-tolls/highways controls | "Which of these 3 hotels is closest to airport without highways?" |
47
- | `maps_search_along_route` | Find places along a route (meals, stops) ranked by detour time | "Restaurants between Fushimi Inari and Kiyomizu-dera" |
48
-
49
- ### Environment
50
- | Tool | When to use | Example |
51
- |------|-------------|---------|
52
- | `maps_elevation` | Query altitude | "Elevation profile along this hiking trail" |
53
- | `maps_timezone` | Need local time at a destination | "What time is it in Tokyo?" |
54
- | `maps_weather` | Weather at a location (current or forecast) | "What's the weather in Paris?" |
55
- | `maps_air_quality` | AQI, pollutants, health recommendations | "Is the air safe for jogging?" |
56
-
57
- ### Visualization
58
- | Tool | When to use | Example |
59
- |------|-------------|---------|
60
- | `maps_static_map` | Show locations/routes on a map image | "Show me these places on a map" |
61
-
62
- ### Composite (one-call shortcuts)
63
- | Tool | When to use | Example |
64
- |------|-------------|---------|
65
- | `maps_explore_area` | Overview of a neighborhood | "What's around Tokyo Tower?" |
66
- | `maps_plan_route` | Multi-stop optimized itinerary (Routes API waypoint optimization, up to 25 stops) with drive-only avoid-tolls/highways controls | "Visit these 5 places efficiently without tolls" |
67
- | `maps_compare_places` | Side-by-side comparison | "Which ramen shop near Shibuya?" |
68
- | `maps_local_rank_tracker` | Local SEO grid rank tracking | "How does this dentist rank across the area?" |
69
-
70
- ---
71
-
72
- ## Known API Limitations
73
-
74
- | Tool | Limitation | Workaround |
75
- |------|-----------|------------|
76
- | `maps_weather` | Unsupported regions: Japan, China, South Korea, Cuba, Iran, North Korea, Syria | Use web search for weather in these regions |
77
- | `maps_distance_matrix` | Transit mode may return null in some regions | Fall back to `driving` or `walking` mode, or use `maps_directions` for transit |
78
- | `maps_plan_route` | Transit mode does not support waypoint optimization | Set `optimize: false` for transit mode |
79
- | `maps_air_quality` | Works globally including Japan (unlike weather) | — |
80
-
81
- ---
28
+ | Outcome | Preferred tools |
29
+ |---|---|
30
+ | Address or landmark to coordinates | `maps_geocode` |
31
+ | Coordinates to address | `maps_reverse_geocode` |
32
+ | Nearby discovery | `maps_search_nearby`, then `maps_place_details` |
33
+ | Natural-language place search | `maps_search_places`, then `maps_place_details` |
34
+ | Compare candidate places | `maps_compare_places` or search → details → distance matrix |
35
+ | Route or travel-mode comparison | `maps_directions`, `maps_distance_matrix` |
36
+ | Multi-stop route without a broader itinerary | `maps_plan_route` |
37
+ | Things along a route | `maps_search_along_route` |
38
+ | Neighborhood facts | `maps_explore_area` plus targeted nearby searches |
39
+ | Elevation, timezone, weather, or air quality | corresponding environment tool; geocode first when needed |
40
+ | Visual map | `maps_static_map` after locations or a route are known |
82
41
 
83
42
  ## Invocation
84
43
 
@@ -86,30 +45,18 @@ Use the package's `exec` CLI to answer location questions without starting an MC
86
45
  npx -y @cablate/mcp-google-map exec <tool> '<json_params>'
87
46
  ```
88
47
 
89
- - **API Key**: Set `GOOGLE_MAPS_API_KEY` in the environment. The `-k` flag also works, but may expose the key in shell history or process listings. If no key is available, ask the user to configure one; do not invent results.
90
- - **Output**: Successful calls return JSON on stdout. A failed call exits nonzero with error details on stderr; report the failure rather than treating it as map data.
91
- - **Stateless**: each call is independent
92
- - **Tool names**: CLI accepts both `maps_geocode` and `geocode` short forms
48
+ The CLI accepts both MCP-style names such as `maps_geocode` and short names such as `geocode`. Each call is stateless and returns JSON on stdout.
93
49
 
94
- ---
95
-
96
- ## When to Update This Skill
97
-
98
- | Trigger | What to update |
99
- |---------|----------------|
100
- | New tool added to the package | Tool Map table + references/tools-api.md |
101
- | Tool parameters changed | references/tools-api.md |
102
- | New chaining pattern discovered in practice | references/tools-api.md chaining section |
103
-
104
- ---
50
+ ## Boundaries
105
51
 
106
- ## Reference
52
+ - For a multi-day itinerary, trip schedule, or travel-day optimization, use `google-maps-travel-planning` instead.
53
+ - For Google Business Profile visibility, grid ranking, keyword coverage, or competitor audits, use `google-maps-local-seo` instead.
54
+ - `maps_weather` is unavailable in Japan, China, South Korea, Cuba, Iran, North Korea, and Syria; use a current web source there.
55
+ - Transit waypoint optimization is unsupported; use `optimize: false` for transit routes.
56
+ - Geographic proximity and elevation alone do not establish safety, accessibility, flood risk, or suitability. State those limitations when relevant.
107
57
 
108
- | File | Content | When to read |
109
- |------|---------|--------------|
110
- | `references/tools-api.md` | Full parameter specs, response formats, 7 scenario recipes, and decision guide | When you need exact parameters, response shapes, or multi-tool workflow patterns |
111
- | `references/travel-planning.md` | Travel planning methodology — 6-layer model, Search Along Route, anti-patterns | When planning multi-day trips — **read before Recipe 1** |
112
- | `references/local-seo.md` | Local SEO / Google Business Profile ranking analysis — competitor audit, keyword landscape, gap analysis | When analyzing business rankings, comparing competitors, or scouting locations |
113
- | `references/content-attribution.md` | Google Maps content attribution, source links, AI disclosure, and storage limits | Before presenting reviews, photos, or AI summaries from Places |
58
+ ## References
114
59
 
115
- > For **project development** knowledge (architecture, API guide, GIS domain, design decisions), see `skills/project-docs/SKILL.md`.
60
+ - `references/tools-api.md`: read for exact parameters, response shapes, and generic chaining recipes.
61
+ - `../_shared/setup-and-diagnostics.md`: read for first-run checks and error classification.
62
+ - `../_shared/content-attribution.md`: read before displaying regulated Google Maps content.
@@ -156,7 +156,7 @@ Response includes (when available from Google):
156
156
  | `reviews[].author_uri`, `author_photo_uri`, `google_maps_uri` | string | Author profile/avatar and individual review source |
157
157
  | `photos[].author_attributions`, `google_maps_uri` | object[], string | Photo credits and individual photo source, returned with `maxPhotos > 0` |
158
158
 
159
- Before showing reviews, photos, or AI summaries to end users, read [`content-attribution.md`](./content-attribution.md). The old legacy-review merge was removed because it could not supply a per-review Google Maps source link; reviews now come from Places API (New) only.
159
+ Before showing reviews, photos, or AI summaries to end users, read [`content-attribution.md`](../../_shared/content-attribution.md). The old legacy-review merge was removed because it could not supply a per-review Google Maps source link; reviews now come from Places API (New) only.
160
160
 
161
161
  ---
162
162
 
@@ -494,7 +494,7 @@ Use these recipes when the user's question maps to a multi-step workflow. Think
494
494
 
495
495
  This is the most common complex scenario. The goal is a time-ordered itinerary with routes between stops.
496
496
 
497
- > **Read `references/travel-planning.md` first** — it contains the full methodology, anti-patterns, and time budget guidelines.
497
+ > This workflow belongs to the `google-maps-travel-planning` Skill. Read its `references/travel-planning.md` before planning an itinerary.
498
498
 
499
499
  **Steps:**
500
500
  1. `maps_search_places` — Search "top attractions in {city}" → geographically diverse **anchor points**
@@ -0,0 +1,47 @@
1
+ ---
2
+ name: google-maps-local-seo
3
+ description: Analyze Google Business Profile visibility, geographic grid rankings, local search keywords, and nearby competitors through the standalone Google Maps CLI. Use for local SEO or location-strategy decisions, not ordinary place recommendations.
4
+ license: MIT
5
+ ---
6
+
7
+ # Google Maps Local SEO
8
+
9
+ Produce a reproducible local-search visibility analysis grounded in Google Maps results. Use the standalone CLI; no MCP connection is required.
10
+
11
+ ## Before calling the CLI
12
+
13
+ - On the first call in a session, or after an execution failure, read `../_shared/setup-and-diagnostics.md` and run the non-billable local preflight.
14
+ - The user must supply `GOOGLE_MAPS_API_KEY`. Never expose its value.
15
+ - Read `../_shared/content-attribution.md` before presenting reviews, photos, or Google-generated summaries.
16
+
17
+ ## Workflow
18
+
19
+ 1. Confirm the target business or `place_id`, service area, relevant keywords, grid size, and decision the user needs to make.
20
+ 2. Read `references/local-seo.md` before running an audit.
21
+ 3. Resolve the target with `maps_search_places` and `maps_place_details`; do not assume businesses with similar names are identical.
22
+ 4. Use `maps_local_rank_tracker` for geographic rankings. Keep the keyword, center, spacing, and grid size with every reported result.
23
+ 5. Use place search, comparison, and area exploration to identify competitors and evidence for gaps.
24
+ 6. Separate observed API results from recommendations. Explain ARP, ATRP, SoLV, unfound grid points, and sample limitations.
25
+ 7. Present prioritized actions tied to the observed evidence; do not promise ranking improvements.
26
+
27
+ ## CLI
28
+
29
+ ```bash
30
+ npx -y @cablate/mcp-google-map exec <tool> '<json_params>'
31
+ ```
32
+
33
+ For exact parameters, read the relevant sections of `../google-maps/references/tools-api.md`.
34
+
35
+ ## Boundaries
36
+
37
+ - Ordinary nearby-place discovery and place comparison belong to `google-maps`.
38
+ - Consumer travel itineraries belong to `google-maps-travel-planning`.
39
+ - Grid results are a sampled snapshot, not an exhaustive or stable representation of Google ranking.
40
+ - Do not recommend deceptive reviews, keyword stuffing, impersonation, or other policy-violating tactics.
41
+
42
+ ## References
43
+
44
+ - `references/local-seo.md`: required audit method, competitor analysis, metrics, and reporting structure.
45
+ - `../google-maps/references/tools-api.md`: selected tool parameters and response shapes.
46
+ - `../_shared/setup-and-diagnostics.md`: first-run and failure recovery.
47
+ - `../_shared/content-attribution.md`: Places presentation requirements.
@@ -0,0 +1,48 @@
1
+ ---
2
+ name: google-maps-travel-planning
3
+ description: Build evidence-backed day trips, multi-day itineraries, and efficient stop sequences with Google Maps data through the standalone CLI. Use when the desired output is a practical travel plan, not merely a route or list of places.
4
+ license: MIT
5
+ ---
6
+
7
+ # Google Maps Travel Planning
8
+
9
+ Build a time-ordered itinerary whose geography, travel times, opening constraints, and along-route stops have been checked. Use the standalone CLI; no MCP connection is required.
10
+
11
+ ## Before calling the CLI
12
+
13
+ - On the first call in a session, or after an execution failure, read `../_shared/setup-and-diagnostics.md` and run the non-billable local preflight.
14
+ - The user must supply `GOOGLE_MAPS_API_KEY`. Never expose its value.
15
+ - Read `../_shared/content-attribution.md` before presenting reviews, photos, or Google-generated summaries.
16
+
17
+ ## Workflow
18
+
19
+ 1. Establish destination, dates or duration, fixed anchors, mobility constraints, pace, and relevant preferences. Ask only for omissions that materially change the itinerary.
20
+ 2. Read `references/travel-planning.md` before designing the itinerary.
21
+ 3. Use `maps_search_places` to find candidate anchors, then group nearby anchors into one-direction daily arcs.
22
+ 4. Use `maps_search_along_route` for meals and breaks between anchors. Use `maps_place_details` for hours, ratings, and source metadata.
23
+ 5. Validate every day with `maps_plan_route` or `maps_directions`. Do not present estimated timing as validated timing.
24
+ 6. Check weather and air quality when they affect the plan. Respect regional weather limitations described in the reference.
25
+ 7. When useful, produce a numbered static map after the stop order is final.
26
+ 8. Present a day-by-day schedule with travel time, visit duration, reservations or opening-hour caveats, and clearly marked fallbacks.
27
+
28
+ ## CLI
29
+
30
+ ```bash
31
+ npx -y @cablate/mcp-google-map exec <tool> '<json_params>'
32
+ ```
33
+
34
+ For exact tool parameters, read `../google-maps/references/tools-api.md` only for the tools selected by the plan.
35
+
36
+ ## Boundaries
37
+
38
+ - A request for only A-to-B directions or a simple multi-stop ordering belongs to `google-maps`.
39
+ - A request to assess business visibility or local search rankings belongs to `google-maps-local-seo`.
40
+ - Do not infer that a venue is accessible, open, safe, or suitable when the API response does not establish it.
41
+ - Do not silently substitute web estimates for unavailable Google Maps results; identify the alternate source.
42
+
43
+ ## References
44
+
45
+ - `references/travel-planning.md`: required methodology, timing budgets, geographic arcs, and anti-patterns.
46
+ - `../google-maps/references/tools-api.md`: exact parameters and response shapes for selected tools.
47
+ - `../_shared/setup-and-diagnostics.md`: first-run and failure recovery.
48
+ - `../_shared/content-attribution.md`: Places presentation requirements.
Binary file
@@ -1,66 +0,0 @@
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** | 18 tools (14 atomic + 4 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` |
@@ -1,137 +0,0 @@
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 RoutesService NewPlacesService
17
- (geocode/tz/elev) (Routes API REST) (Places API New)
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 (routes) | `src/services/RoutesService.ts` | Routes API REST client (directions, distance matrix, waypoint optimization) |
28
- | API client (legacy) | `src/services/toolclass.ts` | Wrap `@googlemaps/google-maps-services-js` SDK (geocode, timezone, elevation) |
29
- | API client (places) | `src/services/NewPlacesService.ts` | Wrap `@googlemaps/places` gRPC client |
30
- | Auth | `src/utils/apiKeyManager.ts` | API key priority resolution |
31
- | Context | `src/utils/requestContext.ts` | Per-request AsyncLocalStorage propagation |
32
-
33
- ---
34
-
35
- ## Transport Modes
36
-
37
- | Mode | Entry | How to activate | Notes |
38
- |---|---|---|---|
39
- | **HTTP (Streamable)** | `cli.ts` → `BaseMcpServer.startHttpServer()` | default, or `--port` | Listens on `/mcp` (POST/GET/DELETE); sessions tracked by UUID header `mcp-session-id` |
40
- | **stdio** | `cli.ts` → `BaseMcpServer.startStdio()` | `--stdio` flag | Used by Claude Desktop, Cursor; stdout reserved for JSON-RPC, all logs go to stderr |
41
- | **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 |
42
-
43
- ### HTTP Session Lifecycle
44
-
45
- ```
46
- POST /mcp (no session-id, isInitializeRequest)
47
- -> create StreamableHTTPServerTransport
48
- -> create new McpServer, connect transport
49
- -> store in sessions[uuid]
50
-
51
- POST /mcp (mcp-session-id header)
52
- -> reuse existing session context
53
- -> update apiKey if header present
54
-
55
- DELETE /mcp (mcp-session-id header)
56
- -> terminate session, clean up transport
57
- ```
58
-
59
- ---
60
-
61
- ## Tool Registration Flow
62
-
63
- ```
64
- src/tools/maps/weather.ts exports Weather.{NAME, DESCRIPTION, SCHEMA, ACTION}
65
- |
66
- src/config.ts builds ToolConfig[] array, attaches MAPS_TOOL_ANNOTATIONS
67
- |
68
- src/cli.ts passes config.tools[] to new BaseMcpServer(name, tools)
69
- |
70
- BaseMcpServer.createMcpServer() calls server.registerTool(name, {description, inputSchema, annotations}, action)
71
- |
72
- @modelcontextprotocol/sdk exposes tool to MCP client
73
- ```
74
-
75
- `MAPS_TOOL_ANNOTATIONS` applied to all tools:
76
-
77
- ```ts
78
- { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true }
79
- ```
80
-
81
- ---
82
-
83
- ## API Key Management
84
-
85
- Priority order (highest to lowest):
86
-
87
- | Priority | Source | Header / Variable |
88
- |---|---|---|
89
- | 1 | HTTP request header | `X-Google-Maps-API-Key` |
90
- | 2 | HTTP Authorization header | `Authorization: Bearer <key>` |
91
- | 3 | Session-specific key | stored per `mcp-session-id` |
92
- | 4 | CLI argument | `--apikey` / `-k` |
93
- | 5 | Environment variable | `GOOGLE_MAPS_API_KEY` |
94
- | 6 | `.env` file | loaded by `dotenv` at startup from `cwd` or package dir |
95
-
96
- **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`.
97
-
98
- **Flow in exec mode**: `--apikey` arg → directly passed to `new PlacesSearcher(apiKey)` constructor.
99
-
100
- ---
101
-
102
- ## Adding a New Tool — 9-File Checklist
103
-
104
- From `CLAUDE.md`:
105
-
106
- | # | File | What to update |
107
- |---|---|---|
108
- | 1 | `src/tools/maps/<toolName>.ts` | Define NAME, DESCRIPTION, SCHEMA, ACTION |
109
- | 2 | `src/config.ts` | Add to `tools[]` array with annotations |
110
- | 3 | `src/cli.ts` | Add to `EXEC_TOOLS` const + `switch` case in `execTool()` |
111
- | 4 | `tests/smoke.test.ts` | Add to `expectedTools` array + update tool count assertions |
112
- | 5 | `README.md` | Update tool count (header, comparison table, Server Info, exec mode) + Available Tools table + Project Structure |
113
- | 6 | `skills/google-maps/SKILL.md` | Add row to Tool Map table |
114
- | 7 | `skills/google-maps/references/tools-api.md` | Add parameter docs + chaining patterns |
115
- | 8 | `server.json` | Update description if it mentions tool count |
116
- | 9 | `package.json` | Update description if it mentions tool count |
117
-
118
- Missing any file causes doc/behavior mismatch. Verify all before opening a PR.
119
-
120
- ---
121
-
122
- ## Code Map
123
-
124
- | File | Purpose |
125
- |---|---|
126
- | `src/cli.ts` | CLI entry point — parses args, selects transport, dispatches exec mode |
127
- | `src/config.ts` | Assembles ToolConfig[] array from all tool modules |
128
- | `src/core/BaseMcpServer.ts` | MCP server core — tool registration, HTTP session management, stdio transport |
129
- | `src/index.ts` | Package entry — exports Logger and re-exports public API |
130
- | `src/services/PlacesSearcher.ts` | Service facade — orchestrates multi-step composite tools (planRoute, exploreArea, comparePlaces, searchAlongRoute) |
131
- | `src/services/RoutesService.ts` | Routes API REST client — computeRoutes (directions), computeRouteMatrix (distance matrix), waypoint optimization |
132
- | `src/services/toolclass.ts` | Google Maps SDK wrapper — geocode, elevation, timezone, weather, airQuality, staticMap, searchAlongRoute |
133
- | `src/services/NewPlacesService.ts` | Places API (New) client — searchNearby, searchText, getPlaceDetails via gRPC |
134
- | `src/tools/maps/*.ts` | Individual tool definitions (17 files) — each exports NAME, DESCRIPTION, SCHEMA, ACTION |
135
- | `src/utils/apiKeyManager.ts` | Singleton — resolves API key priority from headers / session / env |
136
- | `src/utils/requestContext.ts` | AsyncLocalStorage — propagates API key within a single request lifecycle |
137
- | `tests/smoke.test.ts` | Integration smoke tests — validates tool list, basic API calls |