Three.js MCP server

Enables real-time manipulation of Three.js 3D scenes through WebSocket connections, allowing natural language control of object creation, movement, rotation, and scene state retrieval without direct code modification.
Back to servers
Provider
Loc Chung
Release date
Mar 24, 2025
Language
TypeScript
Stats
8 stars

This MCP server offers basic functionality for controlling Three.js source code through the Model Context Protocol. It provides a streamlined interface for Three.js manipulation, allowing developers to interact with Three.js scenes programmatically.

Installation

To install the Three.js MCP server, you'll need to have Node.js installed on your system. Then follow these steps:

  1. Clone the repository:

    git clone https://github.com/username/three-js-mcp.git
    
  2. Navigate to the project directory:

    cd three-js-mcp
    
  3. Install the dependencies:

    npm install
    

Usage

Starting the Server

To start the MCP server, run:

npm start

This will launch the server on the default port. The console will display connection information once the server is running.

Basic Configuration

You can configure the server by modifying the configuration options:

const config = {
  port: 3000,
  host: 'localhost',
  debug: false
};

Connecting to the Server

You can connect to the MCP server using any MCP client. Here's a basic example:

import MCPClient from 'mcp-client';

const client = new MCPClient({
  url: 'ws://localhost:3000'
});

client.connect().then(() => {
  console.log('Connected to Three.js MCP server');
});

Controlling Three.js Content

Once connected, you can send commands to control Three.js scenes:

// Creating a new scene
client.send('scene.create', { id: 'main-scene' });

// Adding a cube to the scene
client.send('object.create', {
  type: 'BoxGeometry',
  material: 'MeshBasicMaterial',
  properties: {
    position: { x: 0, y: 0, z: 0 },
    rotation: { x: 0, y: 0, z: 0 },
    scale: { x: 1, y: 1, z: 1 },
    materialOptions: { color: 0xff0000 }
  }
});

// Rotating an object
client.send('object.update', {
  id: 'cube1',
  properties: {
    rotation: { x: Math.PI/4, y: Math.PI/4, z: 0 }
  }
});

Available Commands

The Three.js MCP server supports these basic commands:

  • scene.create - Create a new Three.js scene
  • scene.clear - Clear all objects from a scene
  • object.create - Create a new 3D object
  • object.update - Update properties of an existing object
  • object.delete - Remove an object from the scene
  • camera.update - Update camera position and properties
  • render - Trigger a new render of the scene

Troubleshooting

Connection Issues

If you're having trouble connecting to the server:

  1. Check that the server is running
  2. Verify you're using the correct port in your client
  3. Ensure your firewall isn't blocking WebSocket connections

Command Errors

If commands aren't working as expected:

  • Check the server console for error messages
  • Verify the command syntax against the documentation
  • Make sure object IDs match existing objects in the scene

How to add this MCP server to Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "cursor-rules-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "cursor-rules-mcp"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later