Skip to content

cesium-mcp-bridge

Browser SDK — embeds in your CesiumJS app, receives commands via WebSocket.

npm

Installation

bash
npm install cesium-mcp-bridge

Peer dependency: cesium@~1.139.0

Initialization

js
import { CesiumBridge } from 'cesium-mcp-bridge'

const viewer = new Cesium.Viewer('cesiumContainer')
const bridge = new CesiumBridge(viewer)

Commands (58)

View Control

CommandDescriptionKey Parameters
flyToAnimate camera to a positionlongitude, latitude, height, heading, pitch, roll, duration
setViewInstantly set camera positionlongitude, latitude, height, heading, pitch, roll
getViewGet current camera state
zoomToExtentZoom to geographic boundswest, south, east, north
saveViewpointSave current view as named bookmarkname
loadViewpointRestore a saved viewpoint bookmarkname, duration
listViewpointsList all saved viewpoint bookmarks
exportSceneExport scene as structured JSON snapshot

Entity

CommandDescriptionKey Parameters
addMarkerAdd point markerlongitude, latitude, label, color, size
addLabelAdd text labelsdata, field, style
addPolylineAdd polyline (path/route)coordinates, color, width, clampToGround
addPolygonAdd polygon areacoordinates, color, outlineColor, opacity, extrudedHeight
addModelPlace 3D model (glTF/GLB)longitude, latitude, url, scale, heading, pitch, roll
updateEntityUpdate entity propertiesentityId, position, color, label, scale, show
removeEntityRemove a single entityentityId
batchAddEntitiesAdd multiple entities at onceentities (array of typed defs)
queryEntitiesSearch/filter entities in scenename, type, bbox
getEntityPropertiesGet all properties of an entityentityId

Layer Management

CommandDescriptionKey Parameters
addGeoJsonLayerLoad GeoJSON dataurl or data, name, style
listLayersList all loaded layers
removeLayerRemove a layer by IDlayerId
clearAllRemove all layers, entities, and data sources
setLayerVisibilityShow/hide a layerlayerId, visible
updateLayerStyleChange layer stylinglayerId, style, tileStyle
getLayerSchemaGet layer property field structurelayerId
setBasemapSwitch imagery base layerprovider, url

Camera (advanced)

CommandDescriptionKey Parameters
lookAtTransformOrbit-style camera aimlongitude, latitude, height, heading, pitch, range
startOrbitStart camera orbitspeed, direction
stopOrbitStop orbit animation
setCameraOptionsConfigure camera controllerenableRotate, enableZoom, enableTilt

Extended Entity Types

CommandDescriptionKey Parameters
addBillboardAdd image iconlongitude, latitude, image, scale
addBoxAdd 3D boxposition, dimensions, material
addCorridorAdd corridorpositions, width, material
addCylinderAdd cylinder/coneposition, length, topRadius, bottomRadius
addEllipseAdd ellipseposition, semiMajorAxis, semiMinorAxis
addRectangleAdd rectanglewest, south, east, north, material
addWallAdd wallpositions, maximumHeights, minimumHeights

Animation

CommandDescriptionKey Parameters
createAnimationCreate waypoint animationentityId, waypoints, model
controlAnimationPlay/pause animationentityId, action
removeAnimationRemove animation entityentityId
listAnimationsList active animations
updateAnimationPathUpdate path visualsentityId, show, width, color
trackEntityCamera follows entityentityId
controlClockConfigure clockstartTime, stopTime, multiplier
setGlobeLightingGlobe lighting controlenableLighting, enableFog

3D Scene

CommandDescriptionKey Parameters
load3dTilesLoad 3D Tileseturl or ionAssetId, name, maximumScreenSpaceError
loadTerrainSet terrain providerurl, provider
loadImageryServiceAdd imagery layerurl/serviceType or ionAssetId, name
loadCzmlLoad CZML time-dynamic datadata or url, name
loadKmlLoad KML/KMZ datadata or url, name

Interaction

CommandDescriptionKey Parameters
screenshotCapture current viewwidth, height, format
highlightHighlight featureslayerId, featureId, color
measureMeasure distance or areatype, coordinates

Other

CommandDescriptionKey Parameters
playTrajectoryAnimate along a pathpositions, duration, loop
addHeatmapCreate heatmap visualizationpoints, name, radius, gradient

Scene

CommandDescriptionKey Parameters
setSceneOptionsConfigure scene environmentfogEnabled, shadowsEnabled, sunShow, backgroundColor
setPostProcessConfigure post-processing effectsbloom, ambientOcclusion, fxaa

Two Calling Styles

Style 1: Type-safe Methods

typescript
const result = await bridge.flyTo({
  longitude: 116.4,
  latitude: 39.9,
  height: 5000,
  duration: 2,
})

Style 2: JSON Command Dispatch

typescript
const result = await bridge.execute({
  action: 'flyTo',
  params: {
    longitude: 116.4,
    latitude: 39.9,
    height: 5000,
    duration: 2,
  },
})

Events

typescript
bridge.on('layerAdded', (layer) => console.log('Layer added:', layer))
bridge.on('layerRemoved', (layerId) => console.log('Removed:', layerId))
bridge.on('error', (err) => console.error('Bridge error:', err))

TypeScript Types

typescript
import type {
  BridgeCommand,
  BridgeResult,
  FlyToParams,
  SetViewParams,
  AddGeoJsonLayerParams,
  AddHeatmapParams,
  AddPolylineParams,
  AddPolygonParams,
  AddModelParams,
  UpdateEntityParams,
  RemoveEntityParams,
  Load3dTilesParams,
  PlayTrajectoryParams,
  LayerInfo,
  HighlightParams,
  ColorInput,
  // Camera
  LookAtTransformParams,
  StartOrbitParams,
  SetCameraOptionsParams,
  // Entity Types
  AddBillboardParams,
  AddBoxParams,
  AddCorridorParams,
  AddCylinderParams,
  AddEllipseParams,
  AddRectangleParams,
  AddWallParams,
  MaterialSpec,
  MaterialInput,
  OrientationInput,
  PositionDegrees,
  // Animation
  CreateAnimationParams,
  ControlAnimationParams,
  RemoveAnimationParams,
  UpdateAnimationPathParams,
  TrackEntityParams,
  ControlClockParams,
  SetGlobeLightingParams,
  AnimationWaypoint,
  AnimationInfo,
  // Layer Schema & Style
  GetLayerSchemaParams,
  LayerSchemaResult,
  LayerSchemaField,
  UpdateLayerStyleParams,
  // Scene
  SetSceneOptionsParams,
  SetPostProcessParams,
  // Data Formats
  LoadCzmlParams,
  LoadKmlParams,
  // Interaction
  MeasureParams,
} from 'cesium-mcp-bridge'

Released under the MIT License.