winyunq / umg-material-mcp
Use when Codex needs to create, inspect, edit, delete, or validate UE5.8 material assets through Unreal Motion Graphics MCP/FabUmgMcp HLSL material tools, especially one-HLSL Custom-node authoring, UI-default versus non-UI material type selection, union-only writes, semantic outputs, hlsl_delete recovery, or Material ToolMode protocol work.
UMG Material MCP
Use the Material HLSL MCP path for material authoring. Do not mutate .uasset files directly. Keep Unreal Editor open with the UMG MCP bridge listening before runtime tool calls.
For concrete command examples and regression cases, read [demo-cases.md](references/demo-cases.md).
Primary Workflow
Set or create the HLSL target with
hlsl_set_target.- New targets default to UI material behavior.
- For non-UI materials, pass type fields directly on
hlsl_set_target:domain,blend_mode,shading_model,two_sided. - Prefer this over
material_modify_type; that command is compatibility-only.
Read with
hlsl_get.- Treat the response as semantic state: HLSL text, parameter snapshot, and
output_contract. - Do not request or reconstruct full material graphs unless the HLSL protocol cannot express the task.
- Treat the response as semantic state: HLSL text, parameter snapshot, and
Write with
hlsl_set(hlsl?, parameters?, outputs?).hlsl_setis union-only: update existing entries and append missing entries.- It must not delete parameters or outputs.
- Use
parametersfor Custom node inputs such as{"name":"Intensity","kind":"Scalar"}. - Use
outputsfor root material outputs such as"Roughness","Metallic","Normal", or objects withname,target, andtype. - Additional outputs are UE5.8 Custom node
AdditionalOutputs; assign same-name variables in HLSL, for exampleRoughness = 0.35;.
Delete with
hlsl_delete(names, confirm_delete=true, kind?).- Omit
kindin the normal path. - If a name matches both parameter and output, expect failure with
requires_kind: true; retry withkind="parameter"orkind="output". - Do not use
hlsl_delete_parameterorhlsl_delete_outputin primary flows; they are compatibility aliases.
- Omit
Compile with
hlsl_compile.- Treat compile diagnostics as the feedback loop.
- Prefer small repair writes with
hlsl_set(hlsl=...)rather than resetting the target.
Protocol Rules
- The material is represented as one HLSL program on a single Custom node.
- The Custom node primary return is
float4. output_contractdescribes where rgb/a and any additional outputs are wired.- UI, PostProcess, LightFunction, and Unlit output rgb to
EmissiveColor; lit Surface output rgb usually maps toBaseColor. - Alpha maps only when semantically useful: UI/translucent to
Opacity, masked toOpacityMask. - Do not fall back to legacy
material_*graph editing unless the requested operation cannot be modeled by HLSL target, parameters, outputs, delete, and compile.
Validation
Use the narrowest relevant checks:
python -m py_compile Resources\Python\UmgMcpServer.py Resources\Python\Material\UMGMaterial.py Resources\Python\APITest\Material_HLSL_Type_Demo.py Resources\Python\APITest\Material_Protocol_Static_Check.py
python Resources\Python\APITest\Material_Protocol_Static_Check.py
& 'D:\UE_5.8\Engine\Build\BatchFiles\Build.bat' FabUMGMCPEditor Win64 Development -Project='D:\UE5Project\FabUMGMCP\FabUMGMCP.uproject' -NoHotReloadFromIDE -Progress
python Resources\Python\APITest\Material_HLSL_Type_Demo.pyThe runtime demo requires Unreal Editor to be open and the MCP socket in Resources/Python/mcp_config.py to be reachable.