feat(gateway): add unified MCP gateway with per-domain enable/disable#39
Merged
Merged
Conversation
Introduces @cesium-mcp/gateway, a new server that aggregates tools from all existing domain servers (camera, entity, animation, imagery, tiles, terrain) behind a single MCP endpoint. Inspired by the 'unified gateway' pattern requested in issue CesiumGS#35 to keep the active tool surface small when many servers would otherwise be connected at once. Design: - Monkey-patches mcpServer.registerTool during each domain's registration (wrapped in try/finally) to capture the returned RegisteredTool and store it in a per-domain registry. - Exposes three meta-tools: gateway_list_domains, gateway_enable_domain, gateway_disable_domain. These call RegisteredTool.enable()/disable() so the set of advertised tools changes at runtime without server restart. - GATEWAY_DOMAINS environment variable controls which domains are enabled at boot (comma-separated, case-insensitive, whitespace-tolerant; unknown names log a warning). Each domain server now also exports its tool-registration function via a './tools' subpath so the gateway can import it without reaching into build/. Tests: 33 new unit tests across domain-registry, domains, and discovery-tools. Full monorepo suite: 1462/1462 passing. Refs CesiumGS#35
- README: fix tool name (cesium_*) and env var name (CESIUM_DOMAINS) - vitest: alias workspace tools packages to TS source for unbuilt test runs - domain-registry: extract setDomainEnabled helper to dedupe enable/disable
Contributor
Author
|
Thanks @MKartaviciute for the detailed review! All 4 points addressed in
All 33 tests still pass locally ( |
MKartaviciute
approved these changes
May 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Unified MCP Gateway (
@cesium-mcp/gateway)This PR introduces
@cesium-mcp/gateway, a new server that aggregates the tools from all existing domain servers (camera, entity, animation, imagery, tiles, terrain) behind a single MCP endpoint, and exposes meta-tools for runtime domain discovery and enable/disable.Motivated by #35 — when many domain servers are connected at once, the active tool surface balloons and starts competing with the assistant's context budget. The gateway lets users start only the tools they need for the current task and flip others on as the conversation evolves, without restarting.
Design
DomainRegistrymonkey-patchesmcpServer.registerToolduring each domain'sregisterTools()call (wrapped intry/finallyso a throwing domain registration cannot permanently pollute the MCP server). The wrapper captures the returnedRegisteredTooland stores it in a per-domain map.gateway_list_domains— lists every domain with[ON]/[OFF]status and tool countsgateway_enable_domain— callsRegisteredTool.enable()on every tool in a domaingateway_disable_domain— callsRegisteredTool.disable()on every tool in a domainenable/disableemitslistChangedautomatically, so the assistant's visible tool surface updates live.GATEWAY_DOMAINSenvironment variable controls which domains are enabled at boot (comma-separated, case-insensitive, whitespace-tolerant; unknown names log a warning; empty/unset means enable all).Sub-path exports
To let the gateway import each domain's tool-registration function without reaching into
build/, every existing domain server now also declares a"./tools"subpath export that points at itstools/index.tsbarrel. These barrels were already the de facto organisation — this PR only makes them part of the package API.Port
3010(next free slot after3007for terrain; leaves room for future domain servers).Tests
test/domain-registry.test.ts(12) — monkey-patch capture,try/finallyrestore, cross-domain isolation, enable/disable idempotency, unknown-domain handling, snapshotstest/domains.test.ts(14) —getEnabledDomainsacross undefined / empty / whitespace / case / trimming / unknown-warning / order-preservationtest/tools/discovery.test.ts(7) — discovery tools registration, list formatting, enable/disable happy path,isErroron unknown domainFull monorepo suite: 1462 / 1462 passing including the 33 new tests.
Checklist
pnpm run buildcleanpnpm test(all packages) — 1462 / 1462GATEWAY_DOMAINSnote, structure tree, build/dev scripts, MCP client config block.env.exampleshippedRefs #35