@pipeworx/mcp-google_maps 0.1.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Pipeworx
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,41 @@
1
+ # mcp-google_maps
2
+
3
+ Google Maps MCP Pack — geocoding, places, directions, distance matrix, elevation.
4
+
5
+ Part of the [Pipeworx](https://pipeworx.io) open MCP gateway.
6
+
7
+ ## Tools
8
+
9
+ | Tool | Description |
10
+ |------|-------------|
11
+ | `maps_geocode` | Geocode an address to latitude/longitude coordinates. |
12
+ | `maps_reverse_geocode` | Reverse geocode coordinates to an address. |
13
+ | `maps_place_search` | Search for places nearby a location (restaurants, hotels, etc.). |
14
+ | `maps_place_details` | Get detailed info about a place (address, phone, hours, reviews, rating). |
15
+ | `maps_directions` | Get directions between two locations. |
16
+ | `maps_distance_matrix` | Get travel distance and time between multiple origins and destinations. |
17
+ | `maps_elevation` | Get elevation data for locations. |
18
+
19
+ ## Quick Start
20
+
21
+ Add to your MCP client config:
22
+
23
+ ```json
24
+ {
25
+ "mcpServers": {
26
+ "google_maps": {
27
+ "url": "https://gateway.pipeworx.io/google_maps/mcp"
28
+ }
29
+ }
30
+ }
31
+ ```
32
+
33
+ Or use the CLI:
34
+
35
+ ```bash
36
+ npx pipeworx use google_maps
37
+ ```
38
+
39
+ ## License
40
+
41
+ MIT
package/package.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "@pipeworx/mcp-google_maps",
3
+ "version": "0.1.0",
4
+ "description": "Google Maps MCP Pack — geocoding, places, directions, distance matrix, elevation.",
5
+ "type": "module",
6
+ "main": "src/index.ts",
7
+ "types": "src/index.ts",
8
+ "keywords": ["mcp", "mcp-server", "model-context-protocol", "pipeworx", "google_maps"],
9
+ "license": "MIT",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "https://github.com/pipeworx-io/mcp-google_maps"
13
+ },
14
+ "scripts": {
15
+ "typecheck": "tsc --noEmit"
16
+ },
17
+ "devDependencies": {
18
+ "typescript": "^5.7.0"
19
+ }
20
+ }
package/server.json ADDED
@@ -0,0 +1,18 @@
1
+ {
2
+ "$schema": "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json",
3
+ "name": "io.github.pipeworx-io/google_maps",
4
+ "title": "google_maps",
5
+ "description": "Google Maps MCP Pack — geocoding, places, directions, distance matrix, elevation.",
6
+ "version": "0.1.0",
7
+ "websiteUrl": "https://pipeworx.io/packs/google_maps",
8
+ "repository": {
9
+ "url": "https://github.com/pipeworx-io/mcp-google_maps",
10
+ "source": "github"
11
+ },
12
+ "remotes": [
13
+ {
14
+ "type": "streamable-http",
15
+ "url": "https://gateway.pipeworx.io/google_maps/mcp"
16
+ }
17
+ ]
18
+ }
package/src/index.ts ADDED
@@ -0,0 +1,191 @@
1
+ interface McpToolDefinition {
2
+ name: string;
3
+ description: string;
4
+ inputSchema: {
5
+ type: 'object';
6
+ properties: Record<string, unknown>;
7
+ required?: string[];
8
+ };
9
+ }
10
+
11
+ interface McpToolExport {
12
+ tools: McpToolDefinition[];
13
+ callTool: (name: string, args: Record<string, unknown>) => Promise<unknown>;
14
+ }
15
+
16
+ /**
17
+ * Google Maps MCP Pack — geocoding, places, directions, distance matrix, elevation.
18
+ * Uses Google Maps Platform APIs (API key based, not OAuth).
19
+ * Expects GOOGLE_MAPS_API_KEY injected via gateway env or BYO via _context.
20
+ */
21
+
22
+
23
+ const API = 'https://maps.googleapis.com/maps/api';
24
+
25
+ // API key is passed via _context.google_maps.apiKey (injected by gateway or BYO)
26
+ // For now, use a hardcoded approach — the gateway can inject it later
27
+ interface MapsContext {
28
+ google_maps?: { apiKey: string };
29
+ }
30
+
31
+ function getKey(args: Record<string, unknown>): string {
32
+ const ctx = (args._context ?? {}) as MapsContext;
33
+ delete args._context;
34
+ const key = ctx.google_maps?.apiKey ?? (args._apiKey as string);
35
+ delete args._apiKey;
36
+ if (!key) throw new Error('Google Maps API key required. Pass via _context or _apiKey parameter.');
37
+ return key;
38
+ }
39
+
40
+ async function mapsFetch(url: string) {
41
+ const res = await fetch(url);
42
+ if (!res.ok) {
43
+ const text = await res.text();
44
+ throw new Error(`Google Maps API error (${res.status}): ${text}`);
45
+ }
46
+ return res.json();
47
+ }
48
+
49
+ const tools: McpToolExport['tools'] = [
50
+ {
51
+ name: 'maps_geocode',
52
+ description: 'Geocode an address to latitude/longitude coordinates.',
53
+ inputSchema: {
54
+ type: 'object' as const,
55
+ properties: {
56
+ address: { type: 'string', description: 'Address to geocode (e.g., "1600 Amphitheatre Parkway, Mountain View, CA")' },
57
+ _apiKey: { type: 'string', description: 'Google Maps API key' },
58
+ },
59
+ required: ['address', '_apiKey'],
60
+ },
61
+ },
62
+ {
63
+ name: 'maps_reverse_geocode',
64
+ description: 'Reverse geocode coordinates to an address.',
65
+ inputSchema: {
66
+ type: 'object' as const,
67
+ properties: {
68
+ lat: { type: 'number', description: 'Latitude' },
69
+ lng: { type: 'number', description: 'Longitude' },
70
+ _apiKey: { type: 'string', description: 'Google Maps API key' },
71
+ },
72
+ required: ['lat', 'lng', '_apiKey'],
73
+ },
74
+ },
75
+ {
76
+ name: 'maps_place_search',
77
+ description: 'Search for places nearby a location (restaurants, hotels, etc.).',
78
+ inputSchema: {
79
+ type: 'object' as const,
80
+ properties: {
81
+ query: { type: 'string', description: 'Search query (e.g., "pizza near Times Square")' },
82
+ location: { type: 'string', description: 'Center point as "lat,lng" (optional)' },
83
+ radius: { type: 'number', description: 'Search radius in meters (max 50000, default 5000)' },
84
+ _apiKey: { type: 'string', description: 'Google Maps API key' },
85
+ },
86
+ required: ['query', '_apiKey'],
87
+ },
88
+ },
89
+ {
90
+ name: 'maps_place_details',
91
+ description: 'Get detailed info about a place (address, phone, hours, reviews, rating).',
92
+ inputSchema: {
93
+ type: 'object' as const,
94
+ properties: {
95
+ place_id: { type: 'string', description: 'Google Place ID' },
96
+ _apiKey: { type: 'string', description: 'Google Maps API key' },
97
+ },
98
+ required: ['place_id', '_apiKey'],
99
+ },
100
+ },
101
+ {
102
+ name: 'maps_directions',
103
+ description: 'Get directions between two locations.',
104
+ inputSchema: {
105
+ type: 'object' as const,
106
+ properties: {
107
+ origin: { type: 'string', description: 'Starting point (address or "lat,lng")' },
108
+ destination: { type: 'string', description: 'End point (address or "lat,lng")' },
109
+ mode: { type: 'string', description: 'Travel mode: driving, walking, bicycling, transit (default: driving)' },
110
+ _apiKey: { type: 'string', description: 'Google Maps API key' },
111
+ },
112
+ required: ['origin', 'destination', '_apiKey'],
113
+ },
114
+ },
115
+ {
116
+ name: 'maps_distance_matrix',
117
+ description: 'Get travel distance and time between multiple origins and destinations.',
118
+ inputSchema: {
119
+ type: 'object' as const,
120
+ properties: {
121
+ origins: { type: 'string', description: 'Pipe-separated origins (e.g., "New York|Boston")' },
122
+ destinations: { type: 'string', description: 'Pipe-separated destinations (e.g., "Philadelphia|Washington DC")' },
123
+ mode: { type: 'string', description: 'Travel mode: driving, walking, bicycling, transit' },
124
+ _apiKey: { type: 'string', description: 'Google Maps API key' },
125
+ },
126
+ required: ['origins', 'destinations', '_apiKey'],
127
+ },
128
+ },
129
+ {
130
+ name: 'maps_elevation',
131
+ description: 'Get elevation data for locations.',
132
+ inputSchema: {
133
+ type: 'object' as const,
134
+ properties: {
135
+ locations: { type: 'string', description: 'Pipe-separated "lat,lng" pairs (e.g., "39.7391,-104.9847|36.4555,-116.8666")' },
136
+ _apiKey: { type: 'string', description: 'Google Maps API key' },
137
+ },
138
+ required: ['locations', '_apiKey'],
139
+ },
140
+ },
141
+ ];
142
+
143
+ async function callTool(name: string, args: Record<string, unknown>): Promise<unknown> {
144
+ const key = getKey(args);
145
+
146
+ switch (name) {
147
+ case 'maps_geocode':
148
+ return mapsFetch(`${API}/geocode/json?address=${encodeURIComponent(args.address as string)}&key=${key}`);
149
+
150
+ case 'maps_reverse_geocode':
151
+ return mapsFetch(`${API}/geocode/json?latlng=${args.lat},${args.lng}&key=${key}`);
152
+
153
+ case 'maps_place_search': {
154
+ const params = new URLSearchParams({ query: args.query as string, key });
155
+ if (args.location) params.set('location', args.location as string);
156
+ if (args.radius) params.set('radius', String(args.radius));
157
+ return mapsFetch(`${API}/place/textsearch/json?${params}`);
158
+ }
159
+
160
+ case 'maps_place_details':
161
+ return mapsFetch(`${API}/place/details/json?place_id=${args.place_id}&key=${key}&fields=name,formatted_address,formatted_phone_number,opening_hours,rating,reviews,website,price_level,types,geometry`);
162
+
163
+ case 'maps_directions': {
164
+ const params = new URLSearchParams({
165
+ origin: args.origin as string,
166
+ destination: args.destination as string,
167
+ key,
168
+ });
169
+ if (args.mode) params.set('mode', args.mode as string);
170
+ return mapsFetch(`${API}/directions/json?${params}`);
171
+ }
172
+
173
+ case 'maps_distance_matrix': {
174
+ const params = new URLSearchParams({
175
+ origins: args.origins as string,
176
+ destinations: args.destinations as string,
177
+ key,
178
+ });
179
+ if (args.mode) params.set('mode', args.mode as string);
180
+ return mapsFetch(`${API}/distancematrix/json?${params}`);
181
+ }
182
+
183
+ case 'maps_elevation':
184
+ return mapsFetch(`${API}/elevation/json?locations=${encodeURIComponent(args.locations as string)}&key=${key}`);
185
+
186
+ default:
187
+ throw new Error(`Unknown tool: ${name}`);
188
+ }
189
+ }
190
+
191
+ export default { tools, callTool, meter: { credits: 5 } } satisfies McpToolExport;
package/tsconfig.json ADDED
@@ -0,0 +1,14 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "ESNext",
5
+ "moduleResolution": "bundler",
6
+ "strict": true,
7
+ "esModuleInterop": true,
8
+ "skipLibCheck": true,
9
+ "outDir": "dist",
10
+ "rootDir": "src",
11
+ "declaration": true
12
+ },
13
+ "include": ["src"]
14
+ }