Skip to content

feat(mcp): Add MCP servers for Babylon.js graph editors#18344

Open
RaananW wants to merge 37 commits into
BabylonJS:masterfrom
RaananW:mcp/graph-servers
Open

feat(mcp): Add MCP servers for Babylon.js graph editors#18344
RaananW wants to merge 37 commits into
BabylonJS:masterfrom
RaananW:mcp/graph-servers

Conversation

@RaananW
Copy link
Copy Markdown
Member

@RaananW RaananW commented Apr 20, 2026

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.

Add Model Context Protocol (MCP) servers that expose Babylon.js authoring
workflows to MCP-compatible clients (VS Code Copilot, Claude, etc.).

Servers included:
- mcp-server-core: shared helpers for validation, response shaping, schemas
- nme-mcp-server: Node Material Editor graph authoring with live session bridge
- nge-mcp-server: Node Geometry Editor graph authoring
- npe-mcp-server: Node Particle Editor graph authoring
- nrge-mcp-server: Node Render Graph Editor graph authoring
- flow-graph-mcp-server: Flow Graph visual scripting
- gui-mcp-server: Babylon.js GUI layout authoring
- gltf-mcp-server: glTF/glb asset authoring and validation
- smart-filters-mcp-server: Smart Filters post-processing chains

Each server includes README, unit tests, and example outputs.
Also adds MCP session UI components to the Node Editor and Playground.
@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 20, 2026

Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s).
To prevent this PR from going to the changelog marked it with the "skip changelog" label.

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 20, 2026

Reviewer - this PR has made changes to one or more package.json files.

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 20, 2026

Building or testing the playground has failed.

If the tests failed, results can be found here:
https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/PLAYGROUND/refs/pull/18344/merge/testResults/

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 20, 2026

Snapshot stored with reference name:
refs/pull/18344/merge

Test environment:
https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/refs/pull/18344/merge/index.html

To test a playground add it to the URL, for example:

https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/refs/pull/18344/merge/index.html#WGZLGJ#4600

Links to test your changes to core in the published versions of the Babylon tools (does not contain changes you made to the tools themselves):

https://playground.babylonjs.com/?snapshot=refs/pull/18344/merge
https://sandbox.babylonjs.com/?snapshot=refs/pull/18344/merge
https://gui.babylonjs.com/?snapshot=refs/pull/18344/merge
https://nme.babylonjs.com/?snapshot=refs/pull/18344/merge

To test the snapshot in the playground with a playground ID add it after the snapshot query string:

https://playground.babylonjs.com/?snapshot=refs/pull/18344/merge#BCU1XR#0

If you made changes to the sandbox or playground in this PR, additional comments will be generated soon containing links to the dev versions of those tools.

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 20, 2026

Smart Filters Editor is available to test at:
https://sfe.babylonjs.com/?snapshot=refs/pull/18344/merge

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 20, 2026

You have changed file(s) that made possible changes to the sandbox.
You can test the sandbox snapshot here:

https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/SANDBOX/refs/pull/18344/merge/

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 20, 2026

RaananW added 4 commits April 20, 2026 15:26
- Change mcp-server-core imports from dist/index.js to src/index.js so
  vitest can resolve TypeScript source directly without a build step
- Add babylonjs-gltf2interface stub alias to vitest.config.mts (matching
  master) so glTF loader tests can resolve the types-only package
- Replace 20 barrel (directory) imports with direct file imports
- Rename type params to StrictPascalCase (TSchema→Schema, etc.)
- Rename IJsonObject→JsonObject, _parseJsonObject→ParseJsonObject
- Add Async suffix: resolveExternalBuffers→resolveExternalBuffersAsync
- Rename _getNumComponents→_GetNumComponents (static private)
- Add missing JSDoc @param/@returns annotations
- Replace Promise.then with async IIFE in signal handlers
- Merge duplicate core/Misc/gradients imports
@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 20, 2026

Reviewer - this PR has made changes to one or more package.json files.

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 20, 2026

Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s).
To prevent this PR from going to the changelog marked it with the "skip changelog" label.

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 20, 2026

Reviewer - this PR has made changes to one or more package.json files.

- Fix className casing to match engine RegisterClass names:
  Csm→Cascaded, Fxaa→FXAA, Ssao2→SSAO2, Ssr→SSR, Taa→TAA
- Add missing blocks: ComputeShaderBlock, IblShadowsRendererBlock,
  PassCubePostProcessBlock
- Update documentation strings with corrected block names
@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 20, 2026

Building or testing the playground has failed.

If the tests failed, results can be found here:
https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/PLAYGROUND/refs/pull/18344/merge/testResults/

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 20, 2026

Snapshot stored with reference name:
refs/pull/18344/merge

Test environment:
https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/refs/pull/18344/merge/index.html

To test a playground add it to the URL, for example:

https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/refs/pull/18344/merge/index.html#WGZLGJ#4600

Links to test your changes to core in the published versions of the Babylon tools (does not contain changes you made to the tools themselves):

https://playground.babylonjs.com/?snapshot=refs/pull/18344/merge
https://sandbox.babylonjs.com/?snapshot=refs/pull/18344/merge
https://gui.babylonjs.com/?snapshot=refs/pull/18344/merge
https://nme.babylonjs.com/?snapshot=refs/pull/18344/merge

To test the snapshot in the playground with a playground ID add it after the snapshot query string:

https://playground.babylonjs.com/?snapshot=refs/pull/18344/merge#BCU1XR#0

If you made changes to the sandbox or playground in this PR, additional comments will be generated soon containing links to the dev versions of those tools.

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 20, 2026

Smart Filters Editor is available to test at:
https://sfe.babylonjs.com/?snapshot=refs/pull/18344/merge

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 20, 2026

You have changed file(s) that made possible changes to the sandbox.
You can test the sandbox snapshot here:

https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/SANDBOX/refs/pull/18344/merge/

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 20, 2026

Flow Graph: add pointer events (Down/Up/Move), physics collision event,
audio sound ended event, physics execution blocks (ApplyForce,
ApplyImpulse, SetLinearVelocity, SetAngularVelocity, SetMotionType),
physics data blocks (GetLinearVelocity, GetAngularVelocity,
GetMassProperties), audio execution blocks (PlaySound, StopSound,
PauseSound, SetVolume), audio data blocks (GetVolume, IsSoundPlaying),
matrix combine/extract blocks (Matrix2D, Matrix3D), and DebugBlock.
Remove stale 'NOT yet implemented' comments for blocks now in core.

NGE: add ExtrudeGeometryBlock to registry.
@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 20, 2026

Reviewer - this PR has made changes to one or more package.json files.

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 20, 2026

Building or testing the playground has failed.

If the tests failed, results can be found here:
https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/PLAYGROUND/refs/pull/18344/merge/testResults/

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 20, 2026

Smart Filters Editor is available to test at:
https://sfe.babylonjs.com/?snapshot=refs/pull/18344/merge

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 20, 2026

You have changed file(s) that made possible changes to the sandbox.
You can test the sandbox snapshot here:

https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/SANDBOX/refs/pull/18344/merge/

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented May 20, 2026

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented May 20, 2026

⚡ Performance Test Results

🟢 All performance tests passed — no regressions detected.

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented May 20, 2026

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented May 20, 2026

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented May 20, 2026

🟢 Memory Leak Test Results

13 passed, 0 leaked out of 13 scenarios

🟢 All memory leak tests passed — no leaks detected.

Passed Scenarios (13)
Scenario Package
Core Feature Stack @babylonjs/core
Core Rendering Materials Shadows Stack @babylonjs/core
Core Textures Render Targets PostProcess Stack @babylonjs/core
GUI Fullscreen UI Controls @babylonjs/gui
GUI Mesh ADT Controls @babylonjs/gui
Loaders Boombox Import @babylonjs/loaders
Loaders OBJ Direct Load @babylonjs/loaders
Loaders STL Direct Load @babylonjs/loaders
Materials Library Stack @babylonjs/materials
Serializers glTF Export @babylonjs/serializers
Serializers GLB Export @babylonjs/serializers
PostProcesses Digital Rain Stack @babylonjs/post-processes
Procedural Textures Stack @babylonjs/procedural-textures

@RaananW RaananW marked this pull request as ready for review May 21, 2026 14:15
Copilot AI review requested due to automatic review settings May 21, 2026 14:15
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review this pull request because it exceeds the maximum number of lines (20,000). Try reducing the number of changed lines and requesting a review from Copilot again.

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented May 21, 2026

Reviewer - this PR has made changes to one or more package.json files.

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented May 21, 2026

Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s).
To prevent this PR from going to the changelog marked it with the "skip changelog" label.

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented May 21, 2026

Reviewer - this PR has made changes to one or more package.json files.

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented May 21, 2026

Snapshot stored with reference name:
refs/pull/18344/merge

Test environment:
https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/refs/pull/18344/merge/index.html

To test a playground add it to the URL, for example:

https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/refs/pull/18344/merge/index.html#WGZLGJ#4600

Links to test your changes to core in the published versions of the Babylon tools (does not contain changes you made to the tools themselves):

https://playground.babylonjs.com/?snapshot=refs/pull/18344/merge
https://sandbox.babylonjs.com/?snapshot=refs/pull/18344/merge
https://gui.babylonjs.com/?snapshot=refs/pull/18344/merge
https://nme.babylonjs.com/?snapshot=refs/pull/18344/merge

To test the snapshot in the playground with a playground ID add it after the snapshot query string:

https://playground.babylonjs.com/?snapshot=refs/pull/18344/merge#BCU1XR#0

If you made changes to the sandbox or playground in this PR, additional comments will be generated soon containing links to the dev versions of those tools.

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented May 21, 2026

Smart Filters Editor is available to test at:
https://sfe.babylonjs.com/?snapshot=refs/pull/18344/merge

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented May 21, 2026

You have changed file(s) that made possible changes to the sandbox.
You can test the sandbox snapshot here:

https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/SANDBOX/refs/pull/18344/merge/

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented May 21, 2026

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented May 21, 2026

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented May 21, 2026

⚡ Performance Test Results

🟢 All performance tests passed — no regressions detected.

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented May 21, 2026

You have made possible changes to the playground.
You can test the snapshot here:

https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/PLAYGROUND/refs/pull/18344/merge/

The snapshot playground with the CDN snapshot (only when available):

https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/PLAYGROUND/refs/pull/18344/merge/?snapshot=refs/pull/18344/merge

Note that neither Babylon scenes nor textures are uploaded to the snapshot directory, so some playgrounds won't work correctly.

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented May 21, 2026

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented May 21, 2026

🟢 Memory Leak Test Results

13 passed, 0 leaked out of 13 scenarios

🟢 All memory leak tests passed — no leaks detected.

Passed Scenarios (13)
Scenario Package
Core Feature Stack @babylonjs/core
Core Rendering Materials Shadows Stack @babylonjs/core
Core Textures Render Targets PostProcess Stack @babylonjs/core
GUI Fullscreen UI Controls @babylonjs/gui
GUI Mesh ADT Controls @babylonjs/gui
Loaders Boombox Import @babylonjs/loaders
Loaders OBJ Direct Load @babylonjs/loaders
Loaders STL Direct Load @babylonjs/loaders
Materials Library Stack @babylonjs/materials
Serializers glTF Export @babylonjs/serializers
Serializers GLB Export @babylonjs/serializers
PostProcesses Digital Rain Stack @babylonjs/post-processes
Procedural Textures Stack @babylonjs/procedural-textures

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants