cesium-mcp-bridge 1.139.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 +21 -0
- package/README.md +147 -0
- package/dist/index.cjs +1219 -0
- package/dist/index.d.cts +265 -0
- package/dist/index.d.ts +265 -0
- package/dist/index.js +1196 -0
- package/package.json +49 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 GeoAgent Contributors
|
|
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,147 @@
|
|
|
1
|
+
# cesium-mcp-bridge
|
|
2
|
+
|
|
3
|
+
> Unified execution layer for AI Agents to control Cesium 3D maps in the browser.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/cesium-mcp-bridge)
|
|
6
|
+
[](LICENSE)
|
|
7
|
+
|
|
8
|
+
## What is this?
|
|
9
|
+
|
|
10
|
+
`cesium-mcp-bridge` is a lightweight SDK that lets AI Agents (LangChain, LangGraph, Claude, etc.) control a browser-side [CesiumJS](https://cesium.com) globe through a unified command interface. It supports both type-safe method calls and JSON command dispatch.
|
|
11
|
+
|
|
12
|
+
```
|
|
13
|
+
AI Agent --> SSE / MCP / WebSocket --> cesium-mcp-bridge --> Cesium Viewer
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Install
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install cesium-mcp-bridge cesium
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
> `cesium` is a peer dependency (compatible with `~1.139.0`).
|
|
23
|
+
|
|
24
|
+
## Quick Start
|
|
25
|
+
|
|
26
|
+
```typescript
|
|
27
|
+
import * as Cesium from 'cesium'
|
|
28
|
+
import { CesiumBridge } from 'cesium-mcp-bridge'
|
|
29
|
+
|
|
30
|
+
const viewer = new Cesium.Viewer('cesiumContainer')
|
|
31
|
+
const bridge = new CesiumBridge(viewer)
|
|
32
|
+
|
|
33
|
+
// Type-safe method call
|
|
34
|
+
await bridge.flyTo({ longitude: 116.39, latitude: 39.91, height: 5000 })
|
|
35
|
+
|
|
36
|
+
// JSON command dispatch (for AI Agent messages)
|
|
37
|
+
await bridge.execute({
|
|
38
|
+
action: 'addGeoJsonLayer',
|
|
39
|
+
params: { id: 'cities', name: 'Cities', data: geojson },
|
|
40
|
+
})
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Commands (19)
|
|
44
|
+
|
|
45
|
+
### View Control
|
|
46
|
+
|
|
47
|
+
| Command | Description |
|
|
48
|
+
|---------|-------------|
|
|
49
|
+
| `flyTo` | Fly to a geographic position with optional heading/pitch/roll |
|
|
50
|
+
| `setView` | Set camera position and orientation instantly |
|
|
51
|
+
| `getView` | Get current camera state (position, heading, pitch, roll) |
|
|
52
|
+
| `zoomToExtent` | Zoom to a bounding rectangle |
|
|
53
|
+
|
|
54
|
+
### Layer Management
|
|
55
|
+
|
|
56
|
+
| Command | Description |
|
|
57
|
+
|---------|-------------|
|
|
58
|
+
| `addGeoJsonLayer` | Add GeoJSON layer with style options (choropleth, category, etc.) |
|
|
59
|
+
| `addHeatmap` | Add a Canvas-based heatmap layer |
|
|
60
|
+
| `removeLayer` | Remove a layer by ID |
|
|
61
|
+
| `setLayerVisibility` | Show/hide a layer |
|
|
62
|
+
| `listLayers` | List all loaded layers with metadata |
|
|
63
|
+
| `updateLayerStyle` | Update a layer's style dynamically |
|
|
64
|
+
| `setBasemap` | Switch basemap (dark / satellite / standard / custom) |
|
|
65
|
+
|
|
66
|
+
### 3D Scene
|
|
67
|
+
|
|
68
|
+
| Command | Description |
|
|
69
|
+
|---------|-------------|
|
|
70
|
+
| `load3dTiles` | Load a 3D Tiles dataset from URL or Cesium Ion |
|
|
71
|
+
| `loadTerrain` | Switch terrain provider (flat / arcgis / cesiumion / url) |
|
|
72
|
+
| `loadImageryService` | Add WMS / WMTS / XYZ / ArcGIS imagery layer |
|
|
73
|
+
|
|
74
|
+
### Entities & Annotations
|
|
75
|
+
|
|
76
|
+
| Command | Description |
|
|
77
|
+
|---------|-------------|
|
|
78
|
+
| `addMarker` | Add a point marker (registered in layer system) |
|
|
79
|
+
| `addLabel` | Add text labels at multiple positions |
|
|
80
|
+
|
|
81
|
+
### Trajectory
|
|
82
|
+
|
|
83
|
+
| Command | Description |
|
|
84
|
+
|---------|-------------|
|
|
85
|
+
| `playTrajectory` | Animate an entity along a path with SampledPositionProperty |
|
|
86
|
+
|
|
87
|
+
### Interaction
|
|
88
|
+
|
|
89
|
+
| Command | Description |
|
|
90
|
+
|---------|-------------|
|
|
91
|
+
| `screenshot` | Capture current map view as base64 PNG |
|
|
92
|
+
| `highlight` | Highlight features in a layer by index or all |
|
|
93
|
+
|
|
94
|
+
## Two Calling Styles
|
|
95
|
+
|
|
96
|
+
```typescript
|
|
97
|
+
// Style 1: Type-safe methods
|
|
98
|
+
const layers = bridge.listLayers()
|
|
99
|
+
await bridge.flyTo({ longitude: 121.47, latitude: 31.23, height: 3000 })
|
|
100
|
+
|
|
101
|
+
// Style 2: JSON command dispatch (MCP / SSE compatible)
|
|
102
|
+
const result = await bridge.execute({
|
|
103
|
+
action: 'flyTo',
|
|
104
|
+
params: { longitude: 121.47, latitude: 31.23 },
|
|
105
|
+
})
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Events
|
|
109
|
+
|
|
110
|
+
```typescript
|
|
111
|
+
bridge.on('layerAdded', (e) => console.log('Layer added:', e.data))
|
|
112
|
+
bridge.on('layerRemoved', (e) => console.log('Layer removed:', e.data))
|
|
113
|
+
bridge.on('error', (e) => console.error('Error:', e.data))
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## Integration with cesium-mcp-runtime
|
|
117
|
+
|
|
118
|
+
This package is the browser-side execution engine for [cesium-mcp-runtime](https://www.npmjs.com/package/cesium-mcp-runtime). The runtime connects to the bridge via WebSocket:
|
|
119
|
+
|
|
120
|
+
```typescript
|
|
121
|
+
const ws = new WebSocket('ws://localhost:9100?session=default')
|
|
122
|
+
ws.onmessage = async (event) => {
|
|
123
|
+
const { id, method, params } = JSON.parse(event.data)
|
|
124
|
+
const result = await bridge.execute({ action: method, params })
|
|
125
|
+
ws.send(JSON.stringify({ id, result }))
|
|
126
|
+
}
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
## Type Exports
|
|
130
|
+
|
|
131
|
+
```typescript
|
|
132
|
+
import type {
|
|
133
|
+
BridgeCommand, BridgeResult, FlyToParams, SetViewParams,
|
|
134
|
+
AddGeoJsonLayerParams, AddHeatmapParams, Load3dTilesParams,
|
|
135
|
+
PlayTrajectoryParams, LayerInfo, HighlightParams,
|
|
136
|
+
} from 'cesium-mcp-bridge'
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
## Compatibility
|
|
140
|
+
|
|
141
|
+
| cesium-mcp-bridge | Cesium |
|
|
142
|
+
|-------------------|--------|
|
|
143
|
+
| 1.139.x | ~1.139.0 |
|
|
144
|
+
|
|
145
|
+
## License
|
|
146
|
+
|
|
147
|
+
MIT
|