Commit 68df4f5
authored
feat(mcp): Add MCP servers for Babylon.js graph editors (BabylonJS#18344)
## Summary
Adds a full Model Context Protocol (MCP) authoring layer for Babylon.js
graph-based tools, plus a shared live-session architecture that lets MCP
clients create or modify graphs and hand them directly to the matching
web editor.
The branch now covers the MCP servers themselves, shared server
utilities, live editor session infrastructure, editor-side session
panels/connectors, packaging for public consumption, coverage/registry
maintenance, and focused validation.
## MCP servers
This PR adds private tool workspaces for the Babylon.js authoring
surfaces that can be driven through MCP-compatible clients such as VS
Code Copilot, Claude Desktop, or other MCP hosts.
| Workspace | Purpose |
| --- | --- |
| `@tools/mcp-server-core` | Shared MCP utilities: validation, JSON/text
responses, scene attachment schemas, tool schemas, and the shared editor
session server/controller |
| `@tools/nme-mcp-server` | Node Material Editor material graph
authoring |
| `@tools/nge-mcp-server` | Node Geometry Editor geometry graph
authoring |
| `@tools/npe-mcp-server` | Node Particle Editor particle graph
authoring |
| `@tools/nrge-mcp-server` | Node Render Graph Editor render graph
authoring |
| `@tools/flow-graph-mcp-server` | Flow Graph visual scripting authoring
|
| `@tools/gui-mcp-server` | Babylon.js GUI layout authoring |
| `@tools/smart-filters-mcp-server` | Smart Filters graph authoring |
Each server includes a block/control registry or catalog, graph manager,
MCP tools, README coverage, examples, and unit tests. The servers build
through a shared Rollup MCP config and emit executable ESM bundles with
shebangs.
## Shared live editor sessions
Adds a reusable live-session server in `@tools/mcp-server-core` so every
graph MCP server uses the same MCP-to-editor workflow instead of
maintaining per-server session code.
The shared session architecture provides:
- A local HTTP/SSE editor session server with health, diagnostics,
session listing, document retrieval, and event streaming endpoints.
- A generic `McpEditorSessionController` used by all graph/editor MCP
servers.
- Conflict and session metadata for editor/agent handoff decisions.
- Server identity metadata and discovery helpers so editors can locate
the active MCP session server.
- CORS restrictions for local editor use.
- Keepalive and graceful idle shutdown support; by default the session
server exits after 15 minutes without MCP/editor activity.
- Unit coverage for session creation, reuse decisions, diagnostics,
discovery, CORS, activity refresh, and idle timeout behavior.
## Editor integrations
Adds MCP session UI integration to the graph editors so a user can
connect an editor to a session started by an MCP server and load the
agent-generated graph.
Integrated editor surfaces:
- Node Material Editor
- Node Geometry Editor
- Node Particle Editor
- Node Render Graph Editor
- Flow Graph Editor
- GUI Editor
- Smart Filters Editor Control
The editor side shares a browser connector in
`packages/dev/sharedUiComponents/src/mcp/mcpEditorSessionConnection.ts`
and each tool adds an MCP session component wired into its property
tab/global state flow.
The earlier Playground MCP session UI and local `.vscode/mcp.json` test
config were removed from the PR so the final branch stays focused on the
graph tools and MCP packages.
## Public package
Adds a public package under `packages/public/@babylonjs/mcp-servers`
that bundles all supported MCP servers into one installable npm package.
The package provides:
- Direct binaries for each server, such as `babylonjs-nme-mcp-server`,
`babylonjs-nge-mcp-server`, `babylonjs-nrge-mcp-server`,
`babylonjs-npe-mcp-server`, `babylonjs-flow-graph-mcp-server`,
`babylonjs-gui-mcp-server`, and `babylonjs-smart-filters-mcp-server`.
- A dispatcher binary, `babylonjs-mcp-servers`, with aliases such as
`nme`, `nge`, `npe`, `nrge`, `flow-graph`, `gui`, and `smart-filters`.
- A build pipeline that builds the private server workspaces, copies the
bundled outputs, preserves source maps, and makes the copied binaries
executable.
- README instructions for `npx` usage and MCP client configuration.
`build:es6:tools` now includes `@babylonjs/mcp-servers` so the public
package participates in the ES6/public-package build flow.
## Registry/catalog coverage
The branch updates MCP registries and catalogs so the servers expose the
current set of relevant authoring blocks and controls.
Recent coverage work includes:
- Flow Graph keyboard blocks: `FlowGraphKeyDownEventBlock`,
`FlowGraphKeyUpEventBlock`, and `FlowGraphIsKeyPressedBlock`.
- Node Geometry `BevelBlock`.
- GUI serialized controls such as `Scrollbar` and `MultiLine`.
- NRGE, NPE, NME, NGE, Smart Filters, and GUI audit notes for
intentional omissions such as abstract/base classes, helper classes,
gradients, and non-creatable types.
- A new instruction file requiring future graph block or GUI control
additions/removals/renames to update the matching MCP registry/catalog
in the same change.
## Cleanup and maintenance
Also included:
- Removed the glTF MCP server package because it is no longer needed.
- Removed redundant per-server session wrappers in favor of the shared
session controller.
- Reduced MCP server build warnings.
- Fixed block registry gaps and class-name casing issues found during
CI/self-review.
- Kept unrelated lint/barrel-import churn out of the branch through
revert commits.
- Added documentation and examples for the new MCP server packages.
## Validation
Focused validation performed on the latest branch state:
- MCP server unit tests: `249 passed` across the graph/server test
files.
- Shared editor session server unit tests, including idle timeout and
reuse behavior, were added and run during the session-server work.
- `npm run build -w @babylonjs/mcp-servers` passes and rebuilds/copies
all bundled MCP servers.
- Affected private MCP server builds pass through Rollup/TypeScript.
- Prettier checks pass for the changed MCP registry/catalog/instruction
files.
- `git diff --check` passes.
- VS Code diagnostics reported no errors on the changed MCP
registry/catalog/instruction files.1 parent abaafbd commit 68df4f5
170 files changed
Lines changed: 71735 additions & 514 deletions
File tree
- .github/instructions
- packages
- public/@babylonjs/mcp-servers
- scripts
- tools
- flow-graph-mcp-server
- examples
- src
- test/unit
- flowGraphEditor/src
- components
- mcpSession
- propertyTab
- gui-mcp-server
- examples
- src
- test/unit
- guiEditor/src
- components
- mcpSession
- propertyTab
- mcp-server-core
- src
- test/unit
- nge-mcp-server
- examples
- src
- test/unit
- nme-mcp-server
- examples
- src
- test/unit
- fixtures
- nodeEditor/src
- components
- mcpSession
- propertyTab
- graphSystem/display
- nodeGeometryEditor/src
- components
- mcpSession
- propertyTab
- nodeParticleEditor/src
- components
- mcpSession
- propertyTab
- nodeRenderGraphEditor/src
- components
- mcpSession
- propertyTab
- npe-mcp-server
- examples
- src
- test/unit
- nrge-mcp-server
- examples
- src
- test/unit
- smart-filters-mcp-server
- examples
- src
- test/unit
- smartFiltersEditorControl/src
- components
- mcpSession
- propertyTab
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
64 | | - | |
| 64 | + | |
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
| |||
Lines changed: 99 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
Lines changed: 66 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
0 commit comments