mapbox-create-map-mcp 1.1.0 → 1.2.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.
Files changed (3) hide show
  1. package/README.md +36 -1
  2. package/package.json +1 -1
  3. package/src/server.js +39 -22
package/README.md CHANGED
@@ -8,7 +8,42 @@
8
8
  npm install mapbox-create-map-mcp
9
9
  ```
10
10
 
11
- ## 使用方法
11
+ ## MCP 服务使用
12
+
13
+ ### 直接启动
14
+
15
+ ```bash
16
+ npx mapbox-create-map-mcp
17
+ ```
18
+
19
+ ### MCP 客户端配置
20
+
21
+ 在 MCP 客户端(如 Claude Desktop、Cursor 等)的配置文件中添加:
22
+
23
+ ```json
24
+ {
25
+ "mcpServers": {
26
+ "mapbox-createmap": {
27
+ "command": "npx",
28
+ "args": ["mapbox-create-map-mcp"]
29
+ }
30
+ }
31
+ }
32
+ ```
33
+
34
+ ### MCP 工具
35
+
36
+ **CreateMap** - 根据配置生成地图图层配置信息
37
+
38
+ 输入参数:
39
+ - `title` (string, 必需): 地图标题
40
+ - `description` (string, 必需): 地图描述
41
+ - `layers` (array, 必需): 图层配置数组
42
+ - `baseStyle` (string, 可选): 底图样式
43
+ - `center` (array, 可选): 中心点 [经度, 纬度]
44
+ - `zoom` (number, 可选): 缩放级别
45
+
46
+ ## JavaScript 库使用
12
47
 
13
48
  ### 基本使用
14
49
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mapbox-create-map-mcp",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "A Mapbox-based MCP tool for creating geographic data visualizations",
5
5
  "main": "dist/index.js",
6
6
  "module": "src/index.js",
package/src/server.js CHANGED
@@ -114,11 +114,44 @@ class McpServer {
114
114
  const metadata = this.createMap.metadata;
115
115
  const layerMetadata = this.createMap.layerMetadata;
116
116
 
117
+ // 合并所有图层类型的配置属性
118
+ const allConfigProperties = {};
119
+
120
+ // point 属性
121
+ for (const key in layerMetadata.point) {
122
+ const prop = layerMetadata.point[key];
123
+ allConfigProperties[key] = {
124
+ type: prop.type,
125
+ description: `[point图层] ${prop.description}`
126
+ };
127
+ if (prop.default !== undefined) allConfigProperties[key].default = prop.default;
128
+ }
129
+
130
+ // linestring 属性
131
+ for (const key in layerMetadata.linestring) {
132
+ const prop = layerMetadata.linestring[key];
133
+ allConfigProperties[key] = {
134
+ type: prop.type,
135
+ description: `[linestring图层] ${prop.description}`
136
+ };
137
+ if (prop.default !== undefined) allConfigProperties[key].default = prop.default;
138
+ }
139
+
140
+ // polygon 属性
141
+ for (const key in layerMetadata.polygon) {
142
+ const prop = layerMetadata.polygon[key];
143
+ allConfigProperties[key] = {
144
+ type: prop.type,
145
+ description: `[polygon图层] ${prop.description}`
146
+ };
147
+ if (prop.default !== undefined) allConfigProperties[key].default = prop.default;
148
+ }
149
+
117
150
  return {
118
151
  tools: [
119
152
  {
120
153
  name: 'CreateMap',
121
- description: '根据配置生成地图图层配置信息,返回FeatureCollection格式的结果用于渲染',
154
+ description: '根据配置生成地图图层配置信息,返回FeatureCollection格式的结果用于渲染。图层类型支持point(点)、linestring(线)、polygon(面)三种。',
122
155
  inputSchema: {
123
156
  type: 'object',
124
157
  properties: {
@@ -133,23 +166,20 @@ class McpServer {
133
166
  baseStyle: {
134
167
  type: 'string',
135
168
  enum: metadata.baseStyle.enum,
136
- default: metadata.baseStyle.default,
137
169
  description: metadata.baseStyle.description
138
170
  },
139
171
  center: {
140
172
  type: 'array',
141
173
  items: { type: 'number' },
142
- default: metadata.center.default,
143
174
  description: metadata.center.description
144
175
  },
145
176
  zoom: {
146
177
  type: 'number',
147
- default: metadata.zoom.default,
148
178
  description: metadata.zoom.description
149
179
  },
150
180
  layers: {
151
181
  type: 'array',
152
- description: metadata.layers.description,
182
+ description: '图层配置数组。每个图层需要id和type,type决定了config中可用的属性:point类型用circle-*属性,lingestring类型用line-*属性,polygon类型用fill-*属性',
153
183
  items: {
154
184
  type: 'object',
155
185
  properties: {
@@ -157,27 +187,14 @@ class McpServer {
157
187
  type: {
158
188
  type: 'string',
159
189
  enum: ['point', 'linestring', 'polygon'],
160
- description: '图层类型'
190
+ description: '图层类型: point(点,使用circle-*属性), linestring(线,使用line-*属性), polygon(面,使用fill-*属性)'
161
191
  },
162
192
  data: { type: 'object', description: 'GeoJSON格式的地理数据' },
163
- fileUrl: { type: 'string', description: '数据文件URL' },
193
+ fileUrl: { type: 'string', description: '数据URL地址' },
164
194
  config: {
165
195
  type: 'object',
166
- description: '图层样式配置,属性取决于type字段的值',
167
- propertiesByType: {
168
- point: {
169
- description: '当type="point"时,config使用以下属性(对应Mapbox circle图层)',
170
- properties: this.formatProperties(layerMetadata.point)
171
- },
172
- linestring: {
173
- description: '当type="linestring"时,config使用以下属性(对应Mapbox line图层)',
174
- properties: this.formatProperties(layerMetadata.linestring)
175
- },
176
- polygon: {
177
- description: '当type="polygon"时,config使用以下属性(对应Mapbox fill图层)',
178
- properties: this.formatProperties(layerMetadata.polygon)
179
- }
180
- }
196
+ description: '图层样式配置,根据type选择对应属性: point用circle-*、linestring用line-*、polygon用fill-*',
197
+ properties: allConfigProperties
181
198
  }
182
199
  },
183
200
  required: ['id', 'type']