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.
To install the Three.js MCP server, you'll need to have Node.js installed on your system. Then follow these steps:
Clone the repository:
git clone https://github.com/username/three-js-mcp.git
Navigate to the project directory:
cd three-js-mcp
Install the dependencies:
npm install
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.
You can configure the server by modifying the configuration options:
const config = {
port: 3000,
host: 'localhost',
debug: false
};
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');
});
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 }
}
});
The Three.js MCP server supports these basic commands:
If you're having trouble connecting to the server:
If commands aren't working as expected:
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.
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"
]
}
}
}
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.
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.