@cablate/mcp-google-map 0.0.4 → 0.0.5
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 +325 -113
- package/dist/chunk-U2CGP7BJ.js +1 -0
- package/dist/cli.d.ts +4 -0
- package/dist/cli.js +3 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +1 -197
- package/package.json +73 -47
- package/LICENSE +0 -21
- package/dist/index.cjs +0 -24181
- package/dist/maps-tools/mapsTools.js +0 -167
- package/dist/maps-tools/searchPlaces.js +0 -144
- package/dist/maps-tools/toolclass.js +0 -248
package/dist/index.js
CHANGED
|
@@ -1,197 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
3
|
-
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
4
|
-
import { CallToolRequestSchema, ListToolsRequestSchema } from "@modelcontextprotocol/sdk/types.js";
|
|
5
|
-
import { DIRECTIONS_TOOL, DISTANCE_MATRIX_TOOL, ELEVATION_TOOL, GEOCODE_TOOL, GET_PLACE_DETAILS_TOOL, REVERSE_GEOCODE_TOOL, SEARCH_NEARBY_TOOL } from "./maps-tools/mapsTools.js";
|
|
6
|
-
import { PlacesSearcher } from "./maps-tools/searchPlaces.js";
|
|
7
|
-
const tools = [SEARCH_NEARBY_TOOL, GET_PLACE_DETAILS_TOOL, GEOCODE_TOOL, REVERSE_GEOCODE_TOOL, DISTANCE_MATRIX_TOOL, DIRECTIONS_TOOL, ELEVATION_TOOL];
|
|
8
|
-
const placesSearcher = new PlacesSearcher();
|
|
9
|
-
const server = new Server({
|
|
10
|
-
name: "mcp-server/maps_executor",
|
|
11
|
-
version: "0.0.1",
|
|
12
|
-
}, {
|
|
13
|
-
capabilities: {
|
|
14
|
-
description: "An MCP server providing Google Maps integration!",
|
|
15
|
-
tools: {},
|
|
16
|
-
},
|
|
17
|
-
});
|
|
18
|
-
server.setRequestHandler(ListToolsRequestSchema, async () => ({
|
|
19
|
-
tools,
|
|
20
|
-
}));
|
|
21
|
-
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
22
|
-
try {
|
|
23
|
-
const { name, arguments: args } = request.params;
|
|
24
|
-
if (!args) {
|
|
25
|
-
throw new Error("No parameters provided");
|
|
26
|
-
}
|
|
27
|
-
if (name === "search_nearby") {
|
|
28
|
-
const { center, keyword, radius, openNow, minRating } = args;
|
|
29
|
-
const result = await placesSearcher.searchNearby({
|
|
30
|
-
center,
|
|
31
|
-
keyword,
|
|
32
|
-
radius,
|
|
33
|
-
openNow,
|
|
34
|
-
minRating,
|
|
35
|
-
});
|
|
36
|
-
if (!result.success) {
|
|
37
|
-
return {
|
|
38
|
-
content: [{ type: "text", text: result.error || "搜尋失敗" }],
|
|
39
|
-
isError: true,
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
return {
|
|
43
|
-
content: [
|
|
44
|
-
{
|
|
45
|
-
type: "text",
|
|
46
|
-
text: `location: ${JSON.stringify(result.location, null, 2)}\n` + JSON.stringify(result.data, null, 2),
|
|
47
|
-
},
|
|
48
|
-
],
|
|
49
|
-
isError: false,
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
if (name === "get_place_details") {
|
|
53
|
-
const { placeId } = args;
|
|
54
|
-
const result = await placesSearcher.getPlaceDetails(placeId);
|
|
55
|
-
if (!result.success) {
|
|
56
|
-
return {
|
|
57
|
-
content: [{ type: "text", text: result.error || "獲取詳細資訊失敗" }],
|
|
58
|
-
isError: true,
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
return {
|
|
62
|
-
content: [
|
|
63
|
-
{
|
|
64
|
-
type: "text",
|
|
65
|
-
text: JSON.stringify(result.data, null, 2),
|
|
66
|
-
},
|
|
67
|
-
],
|
|
68
|
-
isError: false,
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
if (name === "maps_geocode") {
|
|
72
|
-
const { address } = args;
|
|
73
|
-
const result = await placesSearcher.geocode(address);
|
|
74
|
-
if (!result.success) {
|
|
75
|
-
return {
|
|
76
|
-
content: [{ type: "text", text: result.error || "地址轉換座標失敗" }],
|
|
77
|
-
isError: true,
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
return {
|
|
81
|
-
content: [
|
|
82
|
-
{
|
|
83
|
-
type: "text",
|
|
84
|
-
text: JSON.stringify(result.data, null, 2),
|
|
85
|
-
},
|
|
86
|
-
],
|
|
87
|
-
isError: false,
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
if (name === "maps_reverse_geocode") {
|
|
91
|
-
const { latitude, longitude } = args;
|
|
92
|
-
const result = await placesSearcher.reverseGeocode(latitude, longitude);
|
|
93
|
-
if (!result.success) {
|
|
94
|
-
return {
|
|
95
|
-
content: [{ type: "text", text: result.error || "座標轉換地址失敗" }],
|
|
96
|
-
isError: true,
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
return {
|
|
100
|
-
content: [
|
|
101
|
-
{
|
|
102
|
-
type: "text",
|
|
103
|
-
text: JSON.stringify(result.data, null, 2),
|
|
104
|
-
},
|
|
105
|
-
],
|
|
106
|
-
isError: false,
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
if (name === "maps_distance_matrix") {
|
|
110
|
-
const { origins, destinations, mode } = args;
|
|
111
|
-
const result = await placesSearcher.calculateDistanceMatrix(origins, destinations, mode || "driving");
|
|
112
|
-
if (!result.success) {
|
|
113
|
-
return {
|
|
114
|
-
content: [{ type: "text", text: result.error || "計算距離矩陣失敗" }],
|
|
115
|
-
isError: true,
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
return {
|
|
119
|
-
content: [
|
|
120
|
-
{
|
|
121
|
-
type: "text",
|
|
122
|
-
text: JSON.stringify(result.data, null, 2),
|
|
123
|
-
},
|
|
124
|
-
],
|
|
125
|
-
isError: false,
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
if (name === "maps_directions") {
|
|
129
|
-
const { origin, destination, mode } = args;
|
|
130
|
-
const result = await placesSearcher.getDirections(origin, destination, mode || "driving");
|
|
131
|
-
if (!result.success) {
|
|
132
|
-
return {
|
|
133
|
-
content: [{ type: "text", text: result.error || "獲取路線指引失敗" }],
|
|
134
|
-
isError: true,
|
|
135
|
-
};
|
|
136
|
-
}
|
|
137
|
-
return {
|
|
138
|
-
content: [
|
|
139
|
-
{
|
|
140
|
-
type: "text",
|
|
141
|
-
text: JSON.stringify(result.data, null, 2),
|
|
142
|
-
},
|
|
143
|
-
],
|
|
144
|
-
isError: false,
|
|
145
|
-
};
|
|
146
|
-
}
|
|
147
|
-
if (name === "maps_elevation") {
|
|
148
|
-
const { locations } = args;
|
|
149
|
-
const result = await placesSearcher.getElevation(locations);
|
|
150
|
-
if (!result.success) {
|
|
151
|
-
return {
|
|
152
|
-
content: [{ type: "text", text: result.error || "獲取海拔數據失敗" }],
|
|
153
|
-
isError: true,
|
|
154
|
-
};
|
|
155
|
-
}
|
|
156
|
-
return {
|
|
157
|
-
content: [
|
|
158
|
-
{
|
|
159
|
-
type: "text",
|
|
160
|
-
text: JSON.stringify(result.data, null, 2),
|
|
161
|
-
},
|
|
162
|
-
],
|
|
163
|
-
isError: false,
|
|
164
|
-
};
|
|
165
|
-
}
|
|
166
|
-
return {
|
|
167
|
-
content: [{ type: "text", text: `錯誤:未知的工具 ${name}` }],
|
|
168
|
-
isError: true,
|
|
169
|
-
};
|
|
170
|
-
}
|
|
171
|
-
catch (error) {
|
|
172
|
-
return {
|
|
173
|
-
content: [
|
|
174
|
-
{
|
|
175
|
-
type: "text",
|
|
176
|
-
text: `錯誤:${error instanceof Error ? error.message : String(error)}`,
|
|
177
|
-
},
|
|
178
|
-
],
|
|
179
|
-
isError: true,
|
|
180
|
-
};
|
|
181
|
-
}
|
|
182
|
-
});
|
|
183
|
-
async function runServer() {
|
|
184
|
-
try {
|
|
185
|
-
const transport = new StdioServerTransport();
|
|
186
|
-
await server.connect(transport);
|
|
187
|
-
console.log("MCP Maps Server started");
|
|
188
|
-
}
|
|
189
|
-
catch (error) {
|
|
190
|
-
console.error("Server startup failed:", error);
|
|
191
|
-
process.exit(1);
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
runServer().catch((error) => {
|
|
195
|
-
console.error("Server encountered a critical error:", error);
|
|
196
|
-
process.exit(1);
|
|
197
|
-
});
|
|
1
|
+
import{a,b}from"./chunk-U2CGP7BJ.js";export{a as ImagePurpose,b as Logger};
|
package/package.json
CHANGED
|
@@ -1,47 +1,73 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@cablate/mcp-google-map",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
"
|
|
9
|
-
},
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
"
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
"homepage": "https://github.com/cablate/mcp-google-map#readme",
|
|
40
|
-
"repository": {
|
|
41
|
-
"type": "git",
|
|
42
|
-
"url": "git+https://github.com/cablate/mcp-google-map.git"
|
|
43
|
-
},
|
|
44
|
-
"bugs": {
|
|
45
|
-
"url": "https://github.com/cablate/mcp-google-map/issues"
|
|
46
|
-
}
|
|
47
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@cablate/mcp-google-map",
|
|
3
|
+
"version": "0.0.5",
|
|
4
|
+
"description": "Google Maps MCP server with streamable HTTP transport support for location services, geocoding, and navigation",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"bin": {
|
|
8
|
+
"mcp-google-map": "dist/cli.js"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"dist",
|
|
12
|
+
"dist/**/*.map",
|
|
13
|
+
"README.md"
|
|
14
|
+
],
|
|
15
|
+
"scripts": {
|
|
16
|
+
"build": "tsup --dts",
|
|
17
|
+
"start": "node dist/cli.js",
|
|
18
|
+
"dev": "cross-env NODE_ENV=development tsup --watch",
|
|
19
|
+
"prepublishOnly": "npm run build"
|
|
20
|
+
},
|
|
21
|
+
"engines": {
|
|
22
|
+
"node": ">=18.0.0"
|
|
23
|
+
},
|
|
24
|
+
"keywords": [
|
|
25
|
+
"google",
|
|
26
|
+
"map",
|
|
27
|
+
"api",
|
|
28
|
+
"llm",
|
|
29
|
+
"typescript",
|
|
30
|
+
"mcp",
|
|
31
|
+
"server",
|
|
32
|
+
"streamable",
|
|
33
|
+
"location",
|
|
34
|
+
"geocoding",
|
|
35
|
+
"navigation"
|
|
36
|
+
],
|
|
37
|
+
"author": "CabLate",
|
|
38
|
+
"license": "MIT",
|
|
39
|
+
"homepage": "https://github.com/cablate/mcp-google-map#readme",
|
|
40
|
+
"repository": {
|
|
41
|
+
"type": "git",
|
|
42
|
+
"url": "git+https://github.com/cablate/mcp-google-map.git"
|
|
43
|
+
},
|
|
44
|
+
"bugs": {
|
|
45
|
+
"url": "https://github.com/cablate/mcp-google-map/issues"
|
|
46
|
+
},
|
|
47
|
+
"dependencies": {
|
|
48
|
+
"@googlemaps/google-maps-services-js": "^3.4.0",
|
|
49
|
+
"@modelcontextprotocol/sdk": "^1.11.0",
|
|
50
|
+
"@types/yargs": "^17.0.33",
|
|
51
|
+
"cross-env": "^7.0.3",
|
|
52
|
+
"dotenv": "^16.4.7",
|
|
53
|
+
"express": "^4.21.2",
|
|
54
|
+
"yargs": "^17.7.2",
|
|
55
|
+
"zod": "^3.24.2"
|
|
56
|
+
},
|
|
57
|
+
"devDependencies": {
|
|
58
|
+
"@types/express": "^5.0.0",
|
|
59
|
+
"@types/jest": "^29.5.14",
|
|
60
|
+
"@types/js-yaml": "^4.0.9",
|
|
61
|
+
"@types/node": "^20.17.0",
|
|
62
|
+
"@typescript-eslint/eslint-plugin": "^8.24.0",
|
|
63
|
+
"@typescript-eslint/parser": "^8.24.0",
|
|
64
|
+
"eslint": "^9.20.1",
|
|
65
|
+
"eslint-config-prettier": "^10.0.1",
|
|
66
|
+
"jest": "^29.7.0",
|
|
67
|
+
"prettier": "^3.5.0",
|
|
68
|
+
"ts-jest": "^29.2.5",
|
|
69
|
+
"tsup": "^8.4.0",
|
|
70
|
+
"tsx": "^4.19.2",
|
|
71
|
+
"typescript": "^5.7.3"
|
|
72
|
+
}
|
|
73
|
+
}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2025 CabLate
|
|
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.
|