davidvanstory/babylonjs-mcp
If you are the rightful owner of babylonjs-mcp and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
The Babylon.js MCP Server is a Model Context Protocol server that enables AI assistants to interact with 3D objects in a Babylon.js scene using text commands.
create_object
Create a 3D object with specified properties
delete_object
Remove an object by name
select_object
Highlight an object
list_objects
Get all objects in the scene
Babylon.js MCP Server
An MCP (Model Context Protocol) server that allows AI assistants like Claude to create and manipulate 3D objects in a Babylon.js scene through text commands.
Features
- Create 3D objects (box, sphere, cylinder, cone, torus) with customizable properties
- Delete objects by name
- Select objects for highlighting
- List all objects in the scene
- Real-time WebSocket communication between MCP server and browser
- React and vanilla JavaScript implementations
Architecture
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
β Claude Desktop ββββββΆβ MCP Server ββββββΆβ Browser App β
β β β (stdio + WS) β β (Babylon.js) β
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
Installation
- Clone the repository:
git clone <repository-url>
cd babylonjs-mcpV2
- Install dependencies:
npm install
- Build the project:
npm run build
Usage
1. Start the MCP Server
The MCP server needs to be running to bridge communication between Claude and the browser:
node dist/mcp-stdio-server.js
This will:
- Start the MCP server listening on stdio
- Start a WebSocket server on port 8080
2. Start the Browser Application
In a new terminal, start the development server:
npm run dev
Open http://localhost:3000 in your browser. You should see:
- A 3D canvas with a ground plane
- A command input interface
- A WebSocket connection status indicator
3. Configure Claude Desktop
Add the following to your Claude Desktop configuration:
On macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
On Windows: %APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"babylonjs": {
"command": "node",
"args": ["/absolute/path/to/babylonjs-mcpV2/dist/mcp-stdio-server.js"]
}
}
}
Replace /absolute/path/to/babylonjs-mcpV2
with the actual path to your project.
4. Test the Connection
- Restart Claude Desktop
- Make sure the browser app shows "Connected" status
- In Claude, you can now use commands like:
- "Create a red box named myBox"
- "Delete myBox"
- "List all objects"
- "Select myBox"
Available Commands
The MCP server exposes the following tools:
-
create_object: Create a 3D object
shape
: box, sphere, cylinder, cone, or torusname
: unique identifier for the objectposition
: (optional) {x, y, z} coordinatessize
: (optional) scale factorcolor
: (optional) {r, g, b} values (0-1)
-
delete_object: Remove an object by name
name
: identifier of the object to delete
-
select_object: Highlight an object
name
: identifier of the object to select
-
list_objects: Get all objects in the scene
Development
Project Structure
src/
βββ core/ # Core business logic
β βββ babylon-scene.ts # 3D scene management
β βββ command-parser.ts # Text command parsing
β βββ mcp-server.ts # MCP server implementation
β βββ websocket-client.ts # WebSocket client for browser
β βββ types.ts # TypeScript types
βββ react/ # React components
β βββ BabylonMCP.tsx # Main React component
βββ vanilla/ # Vanilla JS implementation
β βββ index.ts # Browser entry point
βββ mcp-stdio-server.ts # MCP server executable
βββ App.tsx # React demo app
Scripts
npm run dev
- Start development servernpm run build
- Build everythingnpm run build:server
- Build MCP server onlynpm run typecheck
- Run TypeScript type checkingnpm run test:simple
- Serve vanilla HTML test page
Testing Without Claude
You can test the browser application standalone:
- Start only the dev server:
npm run dev
- Open http://localhost:3000
- Use the command input to test locally (WebSocket connection will show as disconnected)
Troubleshooting
WebSocket Connection Issues
- Make sure the MCP server is running (
node dist/mcp-stdio-server.js
) - Check that port 8080 is not in use by another application
- Look for errors in the browser console
- Check the MCP server logs in the terminal
Claude Desktop Not Finding the Server
- Ensure the path in
claude_desktop_config.json
is absolute - Make sure the MCP server file exists at the specified path
- Restart Claude Desktop after configuration changes
- Check Claude Desktop logs for MCP-related errors
Build Errors
- Make sure all dependencies are installed:
npm install
- Clear the dist folder and rebuild:
rm -rf dist && npm run build
- Check TypeScript errors:
npm run typecheck
License
MIT