Unreal Engine MCP

repository·main·Indexed 22 days ago

https://github.com/flopperam/unreal-engine-mcp

A Model Context Protocol (MCP) server that enables AI agents in IDEs like Cursor and Claude Code to control the Unreal Engine editor via natural language. It offers a hosted service with 50+ advanced tools for Blueprint authoring, Materials, VFX, and Animation, as well as an open-source local version for basic scene manipulation, actor management, and world building.

Tokens
36.9K
Snippets
102
Records
184
Agent score
74%

What's inside unreal-engine-mcp

  1. What is Blueprint Graph Programming?

    main
    Blueprint Graph Programming allows you to programmatically create and manipulate Unreal Engine Blueprint graphs using the MCP server. You can add nodes, connect them to create execution and data flow, and create variables with custom types and default values. This enables building complete Blueprint logic through natural language commands without manually opening the Blueprint editor.
  2. Available Blueprint Creation and Inspection Tools

    main

    The MCP server provides two categories of tools for working with Blueprints:

    Creation Tools

    • add_node: Add a node to a Blueprint graph (e.g., Print, Events, Variables).
    • connect_nodes: Connect two nodes together to build execution flow and data connections.
    • disconnect_nodes: Remove connections between nodes.
    • create_variable: Add new properties/variables to your Blueprints.

    Inspection Tools

    • read_blueprint_content: Read the complete Blueprint structure (variables, functions, components, event graph).
    • analyze_blueprint_graph: Analyze detailed graph structure including nodes, pins, and connections.
    • get_blueprint_variable_details: Get variable information like types, defaults, and metadata.
    • get_blueprint_function_details: Get function signatures, parameters, and graphs.
  3. The Blueprint Authoring Cycle

    main

    The Flopperam Unreal Engine MCP follows a structured lifecycle for creating and editing Blueprints. For complex work, follow the full cycle. For trivial edits (like a single variable tweak), you can skip directly from reading to writing.

    Full Cycle:

    1. Orient (Read): Use bp_brief or bp_inspect to understand the existing structure.
    2. Probe (Optional): Use bp_dry_run to validate intent or specs without making changes.
    3. Create: Use bp_create to generate new assets.
    4. Author: Perform "narrow writes" using specific tools (variables, components, nodes, etc.).
    5. Commit: Use bp_commit to compile and layout the changes.
    6. Verify: Use bp_inspect or pie_test_bp to confirm structural and runtime correctness.

    Trivial Edit Shortcut: bp_read_tool $\rightarrow$ bp_write_tool $\rightarrow$ bp_commit.

  4. Best practices for efficient MCP tool usage

    main

    To optimize performance and avoid hitting constraints when using the Unreal Engine MCP, follow these efficiency rules:

    • Batch everything: Use tools that accept arrays (e.g., queries, variables, components, nodes, edges, operations) to perform multiple operations in a single call.
    • Parallelize calls: Call independent tools in parallel (e.g., you can call search_assets and scene_query simultaneously if they don't depend on each other).
    • Use filters: Leverage filters in inspection tools like bp_inspect, material_inspect, widget_inspect, and animation_inspect to reduce data volume.
    • Defer compilation: When performing multiple Blueprint writes using bp_* tools, defer the compilation step. Batch your writes first, then call bp_commit once at the end.

    Critical Constraints

    • Response Limits: Responses are capped at 512KB. Use filters and targeted queries to stay within this limit.
    • Path Resolution:
      • search_assets returns paths in PackageName.AssetName format. Always use the FULL path returned by this tool.
      • Do not guess /Game/... paths; they resolve to nullptr if incorrect. Always resolve paths via search_assets first.
    • Actor Labels: scene_query returns actor labels, which are NOT asset paths.
  5. Understand Blueprint Graph tool architecture

    main

    The Blueprint Graph tools consist of a high-performance C++ core and a Python MCP wrapper layer.

    C++ Core (Performance Layer)

    • NodeManager.cpp: Handles node creation logic.
    • BPConnector.cpp: Manages node connections.
    • BPVariables.cpp: Handles variable creation and management.

    Python Wrapper (MCP Interface)

    • node_manager.py: Provides the add_node tool.
    • connector_manager.py: Provides connect_nodes and disconnect_nodes tools.
    • variable_manager.py: Provides the create_variable tool.

    Performance Benchmarks

    • Node creation: ~10-50ms per node
    • Connection: ~5-20ms per connection
    • Variable creation: ~20-50ms
    • Blueprint compilation: ~100-500ms (depending on complexity)

    Recommendation: Use batch operations where possible to minimize round-trip latency.

  6. Understand the Unreal Engine MCP Architectures

    main

    There are two distinct ways to integrate AI with Unreal Engine using MCP, depending on whether you want a managed service or a local open-source setup.

    This is a managed service that uses a streamable HTTP MCP protocol. It connects your AI client (like Cursor, Claude Code, or Windsurf) to a hosted server, which then communicates via WebSockets to the FlopAI Unreal plugin. This setup provides access to over 50+ specialized tools covering Blueprint authoring, Scene & Level management, Materials, VFX, Animation, and more.

    2. Open-Source Local MCP

    This is the version provided in this repository. It uses the stdio MCP protocol to connect your AI client to a local Python server (unreal_mcp_server_advanced.py). The Python server communicates with the UnrealMCP C++ plugin via a TCP socket. This setup is focused on core tools like World Building, Physics, Materials, Blueprint Systems, and Actor Management.

  7. Multi-AI Collaboration Patterns

    main

    You can orchestrate multiple AI agents to work on different zones or districts of a single world.

    Competition Pattern: Assign agents to specific coordinate zones (e.g., West vs East) and provide them with distinct toolsets and architectural styles to build competing cities.

    Collaborative World Building: Assign specific districts to different agents (e.g., Agent 1 handles Residential with construct_house, Agent 2 handles Commercial with create_town, and Agent 3 handles Entertainment with create_maze).

    ### Collaborative World Building
    **User Prompt:** *"Have multiple AIs work together to build different districts of the same city"*
    
    **District Assignments:**
    ```bash
    # AI 1: Residential District
    construct_house(house_style="cottage", location=[-1000, -1000, 0])
    construct_house(house_style="modern", location=[-500, -1000, 0])
    construct_house(house_style="cottage", location=[-1000, -500, 0])
    
    # AI 2: Commercial District  
    create_town(town_size="small", architectural_style="downtown", location=[0, 0, 0])
    create_tower(height=15, base_size=5, tower_style="square", location=[200, 200, 0])
    
    # AI 3: Entertainment District
    create_maze(rows=10, cols=10, location=[1000, 0, 0])
  8. Reference: Unreal Engine Coordinate System

    main

    Understanding the Unreal Engine coordinate system for positioning actors:

    • X-axis (Red): Forward/Backward (positive = forward)
    • Y-axis (Green): Left/Right (positive = right)
    • Z-axis (Blue): Up/Down (positive = up)
    • Units: Centimeters (100 = 1 meter)

    Safe Positioning Guidelines

    • Ground Level: Z = 0
    • Above Ground: Z = 200+ (2 meters up)
    • Horizontal Spacing: 300+ units between objects
    • Large Objects: 500+ units spacing
  9. Core Scene & World Building Workflow

    main

    The Flopperam Unreal Engine MCP follows a three-step pattern for scene and world building to ensure stability and correctness:

    1. Observe: Use scene_brief for a high-level level overview, scene_query to find specific actors, or search_assets to find meshes and materials.
    2. Execute: Use scene_compose for batch actor placement/modification or use domain-specific tools (e.g., landscape_edit, foliage_edit) for specialized systems.
    3. Verify: Use scene_query with spatial filters to confirm placement, or pie_test_scene to test runtime behavior.

    Important Distinction:

    • Scene tools work on actors (instances already placed in the level).
    • Asset tools (like search_assets) work on assets (reusable files in the Content Browser).
  10. Compare Hosted Flop MCP vs. Open-Source Local MCP

    main

    There are two ways to use the Unreal Engine MCP. Choose based on your requirements for tool depth and setup complexity:

    • Best for: Production use, advanced Blueprint authoring, and full feature sets.
    • Capabilities: 50+ tools across 9 domains (Blueprint lifecycle, Materials, VFX, Animation, AI, etc.).
    • Setup: Minimal. Requires an API key and the FlopAI Unreal plugin. No local Python dependencies.
    • Server: Hosted at https://agent.flopperam.com/mcp.

    Open-Source Local MCP

    • Best for: Community use and basic scene/actor manipulation.
    • Capabilities: Basic toolset for scene manipulation, actor management, world building, and foundational Blueprint operations.
    • Setup: Requires cloning the repo, Python 3.12+, and compiling the UnrealMCP plugin bundled in the repo.
    • Server: Run locally from the Python/ folder.
  11. How to use the Flopperam Unreal Engine MCP

    main

    The Flopperam Unreal Engine MCP server controls a live Unreal Editor instance via WebSocket. All tools operate directly on the running editor. If you encounter connection errors, ensure the Unreal Editor is running and the FlopAI plugin is loaded.

    Core Workflow

    To interact with the editor effectively, follow this three-step pattern:

    1. Orient: Use tools like bp_brief, scene_brief, search_assets, or project_context to understand the current state.
    2. Execute: Use domain-specific tools (e.g., bp_graph, material_edit, niagara_edit) to perform tasks.
    3. Verify: Re-examine changes using inspection tools (e.g., bp_inspect, actor_inspect) or run PIE (Play In Editor) tests to confirm runtime behavior.

    Intent Classification Guidelines

    Before calling a tool, determine the user's intent to avoid accidental modifications:

    • Question / explanation: Answer from knowledge. Use read-only tools for specifics. Do NOT make changes.
    • Inspection / analysis: Use read-only tools and report findings. Do NOT modify anything.
    • Modification / creation: Proceed with the full observe → execute → verify workflow.