A comprehensive bridge for automating VFX workflows in Foundry's Nuke using the Model Context Protocol.
This project provides an enhanced MCP server implementation that connects to Foundry's Nuke compositing software, enabling comprehensive automation of VFX workflows. It expands on the basic functionality of creating and manipulating nodes by adding tools for camera tracking, deep compositing, template management, machine learning, and common VFX operations.
- Node creation and manipulation
- Node graph management
- Group and LiveGroup creation
- Template/Toolset management
- Camera tracking and 3D scene setup
- Deep compositing pipelines
- Batch processing
- Machine learning with CopyCat
- Common VFX operations (keying, motion blur, etc.)
- Script management
- Foundry's Nuke 13.0 or later
- Node.js 14.0 or later
- Python 3.6 or later
- Clone this repository:
git clone https://github.com/yourusername/nuke-mcp.git
cd nuke-mcp- Install dependencies:
npm install- Set up the bridge in Nuke:
- Change the SCRIPTS_BASE_DIR to the location of the nuke-mcp project
- Copy the contents od full_bridge.py and paste in nuke script editor and run it
npm startOnce the server is running, you can interact with Nuke using the MCP tools. Here's an example using the createNode tool:
const result = await mcp.createNode({
nodeType: "Blur",
name: "BlurNode1"
});Creates a node in Nuke.
mcp.createNode({
nodeType: "Blur",
name: "BlurNode1",
inputs: ["Read1"]
});Sets a knob value on a node.
mcp.setKnobValue({
nodeName: "BlurNode1",
knobName: "size",
value: 5.5
});Gets information about a node.
mcp.getNode({
nodeName: "BlurNode1"
});Renders frames using a Write node.
mcp.execute({
writeNodeName: "Write1",
frameRangeStart: 1,
frameRangeEnd: 100
});Connects nodes in the node graph.
mcp.connectNodes({
inputNode: "Read1",
outputNode: "Blur1",
inputIndex: 0
});Sets the position of a node in the node graph.
mcp.setNodePosition({
nodeName: "Blur1",
xPos: 100,
yPos: 200
});Gets the position of a node in the node graph.
mcp.getNodePosition({
nodeName: "Blur1"
});Creates a group node containing the specified nodes.
mcp.createGroup({
name: "BlurGroup",
nodeNames: ["Blur1", "Grade1"]
});Creates a LiveGroup node for collaborative work.
mcp.createLiveGroup({
name: "CompositeGroup",
nodeNames: ["Merge1", "Grade1", "ColorCorrect1"],
filePath: "/path/to/save/livegroup.nk"
});Loads a Nuke template (Toolset) into the current script.
mcp.loadTemplate({
templateName: "LensFlare",
position: {
x: 500,
y: 300
}
});Saves selected nodes as a template (Toolset).
mcp.saveTemplate({
templateName: "MyKeyer",
nodeNames: ["Primatte1", "EdgeBlur1", "Premult1"],
category: "Keying"
});Creates and sets up a CameraTracker node.
mcp.createCameraTracker({
sourceName: "Read1",
trackingFeatures: {
numberFeatures: 200,
featureSize: 15,
featureSeparation: 20
}
});Solves a camera track using the specified CameraTracker node.
mcp.solveCameraTrack({
cameraTrackerNode: "CameraTracker1",
solveMethod: "Match-Moving"
});Creates a 3D scene with optional camera and geometry.
mcp.createScene({
cameraNode: "Camera1",
geometryNodes: ["Sphere1", "Card1"]
});Sets up a Deep compositing pipeline.
mcp.setupDeepPipeline({
inputNodes: ["Read1", "Read2", "Read3"],
mergeOperation: "over"
});Batch processes a directory of files using Nuke.
mcp.batchProcess({
inputDirectory: "/path/to/input",
outputDirectory: "/path/to/output",
filePattern: "*.exr",
processScript: "/path/to/process.nk"
});Runs a Python script in Nuke.
mcp.runPythonScript({
script: "nuke.nodes.Blur(size=5)",
args: {
blurSize: 5
}
});Loads a Nuke script file.
mcp.loadScript({
filePath: "/path/to/script.nk"
});Saves the current Nuke script to a file.
mcp.saveScript({
filePath: "/path/to/save/script.nk"
});Sets up a CopyCat node for machine learning.
mcp.setupCopyCat({
trainingInputNode: "Read1",
trainingOutputNode: "Read2",
networkType: "UNet"
});Trains a CopyCat neural network model.
mcp.trainCopyCatModel({
copyCatNodeName: "CopyCat1",
epochs: 200,
batchSize: 8
});Sets up a basic compositing tree with the provided elements.
mcp.setupBasicComp({
plateNode: "Read1",
fgElements: ["Read2", "Read3"],
bgElements: ["Read4"]
});Sets up a keying pipeline for the input node.
mcp.setupKeyer({
inputNodeName: "Read1",
keyerType: "Primatte",
screenColor: [0, 0.7, 0]
});Sets up motion blur for the input node.
mcp.setupMotionBlur({
inputNodeName: "Read1",
vectorNodeName: "VectorGenerator1",
motionBlurSamples: 15
});Sets project settings like frame range, resolution and FPS.
mcp.setProjectSettings({
frameRange: {
first: 1001,
last: 1100
},
resolution: {
width: 1920,
height: 1080
},
fps: 24
});Lists all nodes in the current script, optionally filtered by type.
mcp.listNodes({
filter: "Read"
});This MCP implementation is designed to work seamlessly with AI assistants like Claude or GPT, allowing them to automate complex VFX tasks through natural language instructions. The comprehensive set of tools enables AI assistants to:
- Set up complete compositing workflows
- Create and manage templates for common operations
- Execute camera tracking and 3D integration tasks
- Implement sophisticated deep compositing pipelines
- Train and apply machine learning models for automated effects
// Load a template for a standard shot
await mcp.loadTemplate({
templateName: "StandardShotSetup",
position: { x: 0, y: 0 }
});
// Set the plate
await mcp.setKnobValue({
nodeName: "ReadPlate",
knobName: "file",
value: "/path/to/plate.####.exr"
});
// Configure shot-specific parameters
await mcp.setKnobValue({
nodeName: "ColorCorrect1",
knobName: "gamma",
value: 0.9
});// Create a read node for the plate
const readResult = await mcp.createNode({
nodeType: "Read",
name: "Plate"
});
// Set up the file path
await mcp.setKnobValue({
nodeName: "Plate",
knobName: "file",
value: "/path/to/tracking_plate.####.exr"
});
// Create and set up the camera tracker
await mcp.createCameraTracker({
sourceName: "Plate",
trackingFeatures: {
numberFeatures: 300,
featureSize: 12
}
});
// Solve the camera
await mcp.solveCameraTrack({
cameraTrackerNode: "CameraTracker1",
solveMethod: "Full"
});
// Create a 3D scene with the solved camera
await mcp.createScene({
cameraNode: "Camera1"
});If you encounter issues with the bridge:
- Make sure Nuke is running and the bridge script is loaded
- Check that the TCP port (8765) is not in use by another application
- Check the Nuke script editor for any Python errors
- Make sure your
nuke_bridge_server.pyis properly loaded in your Nuke's initialization scripts
MIT
Developed by [Your Name/Organization]