Skip to content

feat: add terrain-server MCP server#30

Merged
MKartaviciute merged 2 commits into
CesiumGS:mainfrom
gaopengbin:feat/terrain-server
Apr 1, 2026
Merged

feat: add terrain-server MCP server#30
MKartaviciute merged 2 commits into
CesiumGS:mainfrom
gaopengbin:feat/terrain-server

Conversation

@gaopengbin
Copy link
Copy Markdown
Contributor

@gaopengbin gaopengbin commented Mar 29, 2026

Summary

Add a new MCP server for managing terrain providers on the CesiumJS globe.

terrain_mcp_server.mp4

Closes #29

New Tools

Tool Description
terrain_set Set terrain provider from Cesium Ion assets, direct URLs, or flat WGS84 ellipsoid
terrain_get Query current terrain provider info and capabilities
terrain_remove Reset terrain to flat WGS84 ellipsoid (no elevation data)

Source Types

  • ion — Cesium Ion terrain assets (e.g., Cesium World Terrain with asset ID 1)
  • url — Direct terrain server URLs (quantized-mesh endpoints)
  • ellipsoid — Flat WGS84 ellipsoid with no terrain elevation

Terrain Options

  • requestVertexNormals — Request vertex normals for lighting (default: true for ion/url)
  • requestWaterMask — Request water mask data for water effects (default: false)
  • requestMetadata — Request terrain metadata (default: true)

Changes

Server (servers/terrain-server/)

  • Zod v4 schemas: core data types, tool inputs, response structures
  • Three tool handlers with parameter validation and error handling
  • Utility helpers for source type validation and error formatting
  • Port 3007, following existing server conventions

Client (test-applications/packages/client-core/)

  • CesiumTerrainManager implementing ManagerInterface
    • setTerrain: Creates CesiumTerrainProvider (Ion/URL) or EllipsoidTerrainProvider
    • getTerrain: Reads current provider metadata and capabilities
    • removeTerrain: Resets to EllipsoidTerrainProvider
  • Type definitions extending MCPCommandResult

Integration

  • Registered in monorepo build/dev/test scripts
  • Added to web app configuration (esbuild defines, app.ts server list)
  • Updated parent README with terrain server documentation

Testing

  • 31 unit tests across 4 test files (schemas, set, get, remove)
  • Client-side unit tests with full Cesium module mocking
  • 1268 total tests passing across the entire monorepo (64 test files)

Architecture Note

Unlike imagery layers (collection-based, indexed), terrain is a singleton — the viewer has one terrainProvider at a time. This simplifies the API to set/get/remove without needing ID tracking or ordering.

Add a new MCP server for managing terrain providers on the CesiumJS globe.

Server (servers/terrain-server/):
- terrain_set: Set terrain from Cesium Ion assets, direct URLs, or flat ellipsoid
- terrain_get: Query current terrain provider info and capabilities
- terrain_remove: Reset terrain to flat WGS84 ellipsoid
- Zod v4 schemas for input validation and response structure
- 31 unit tests covering schemas, tools, and client manager

Client (test-applications/packages/client-core/):
- CesiumTerrainManager with setTerrain, getTerrain, removeTerrain handlers
- Terrain type definitions extending MCPCommandResult
- Unit tests with full Cesium module mocking

Integration:
- Port 3007, following existing server conventions
- Registered in monorepo build/dev/test scripts
- Added to web app configuration and esbuild defines
- Updated parent README with terrain server documentation

Closes CesiumGS#29
@gaopengbin gaopengbin force-pushed the feat/terrain-server branch from 5cf242d to 3bb689c Compare March 29, 2026 06:53
@MKartaviciute
Copy link
Copy Markdown
Contributor

@gaopengbin Looks good! Thanks for contribution. I will add a small demo showing terrain mcp capabilities into README and will merge the PR.

@MKartaviciute MKartaviciute merged commit 65d8ab5 into CesiumGS:main Apr 1, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Terrain Management mcp server

2 participants