Skip to main content
Glama

Unreal Engine MCP Bridge

by gingerol
blueprint_tools.py12.5 kB
#!/usr/bin/env python """ Blueprint Tools for Unreal Engine MCP Provides tools for creating and manipulating Blueprint assets in Unreal Engine. """ import logging from typing import Dict, Any, List, Optional, Union logger = logging.getLogger("UnrealMCP.BlueprintTools") def register_blueprint_tools(mcp): """Register all Blueprint tools with the MCP server.""" @mcp.tool() def create_blueprint( name: str, parent_class: str = "Actor", path: str = "/Game/Blueprints" ) -> Dict[str, Any]: """Create a new Blueprint class. Args: name: The name of the Blueprint class to create. parent_class: The parent class for the Blueprint (e.g., Actor, Pawn, Character). path: The content browser path where the Blueprint should be created. Returns: A dictionary containing the result of the operation and the Blueprint details. """ from unreal_mcp_server import get_unreal_connection conn = get_unreal_connection() if not conn: return {"status": "error", "error": "Not connected to Unreal Engine"} params = { "name": name, "parent_class": parent_class, "path": path } response = conn.send_command("create_blueprint", params) return response @mcp.tool() def add_component_to_blueprint( blueprint_name: str, component_type: str, component_name: str, location: List[float] = [0, 0, 0], rotation: List[float] = [0, 0, 0], scale: List[float] = [1, 1, 1], properties: Dict[str, Any] = None ) -> Dict[str, Any]: """Add a component to a Blueprint class. Args: blueprint_name: The name or path of the Blueprint to modify. component_type: The type of component to add (e.g., StaticMeshComponent, PointLightComponent). component_name: The name to give the new component. location: [X, Y, Z] coordinates for the component's position relative to parent. rotation: [Pitch, Yaw, Roll] in degrees for the component's rotation. scale: [X, Y, Z] scale factors for the component. properties: Optional dictionary of property values to set on the component. Returns: A dictionary containing the result of the operation and the component details. """ from unreal_mcp_server import get_unreal_connection conn = get_unreal_connection() if not conn: return {"status": "error", "error": "Not connected to Unreal Engine"} params = { "blueprint_name": blueprint_name, "component_type": component_type, "component_name": component_name, "location": location, "rotation": rotation, "scale": scale } if properties: params["properties"] = properties response = conn.send_command("add_component_to_blueprint", params) return response @mcp.tool() def set_static_mesh_properties( blueprint_name: str, component_name: str, static_mesh: str, materials: List[str] = None, collision_enabled: bool = True ) -> Dict[str, Any]: """Set the static mesh and related properties for a StaticMeshComponent in a Blueprint. Args: blueprint_name: The name or path of the Blueprint to modify. component_name: The name of the StaticMeshComponent to modify. static_mesh: The path to the static mesh asset to use. materials: Optional list of material paths to apply to the mesh. collision_enabled: Whether collision should be enabled for this mesh. Returns: A dictionary containing the result of the operation. """ from unreal_mcp_server import get_unreal_connection conn = get_unreal_connection() if not conn: return {"status": "error", "error": "Not connected to Unreal Engine"} params = { "blueprint_name": blueprint_name, "component_name": component_name, "static_mesh": static_mesh, "collision_enabled": collision_enabled } if materials: params["materials"] = materials response = conn.send_command("set_static_mesh_properties", params) return response @mcp.tool() def set_component_property( blueprint_name: str, component_name: str, property_name: str, property_value: Any ) -> Dict[str, Any]: """Set a property on a component within a Blueprint. Args: blueprint_name: The name or path of the Blueprint to modify. component_name: The name of the component to modify. property_name: The name of the property to set. property_value: The value to set for the property. Returns: A dictionary containing the result of the operation. """ from unreal_mcp_server import get_unreal_connection conn = get_unreal_connection() if not conn: return {"status": "error", "error": "Not connected to Unreal Engine"} params = { "blueprint_name": blueprint_name, "component_name": component_name, "property_name": property_name, "property_value": property_value } response = conn.send_command("set_component_property", params) return response @mcp.tool() def compile_blueprint(blueprint_name: str) -> Dict[str, Any]: """Compile a Blueprint class. Args: blueprint_name: The name or path of the Blueprint to compile. Returns: A dictionary containing the result of the operation. """ from unreal_mcp_server import get_unreal_connection conn = get_unreal_connection() if not conn: return {"status": "error", "error": "Not connected to Unreal Engine"} params = {"blueprint_name": blueprint_name} response = conn.send_command("compile_blueprint", params) return response @mcp.tool() def set_blueprint_property( blueprint_name: str, property_name: str, property_value: Any ) -> Dict[str, Any]: """Set a property on a Blueprint class. Args: blueprint_name: The name or path of the Blueprint to modify. property_name: The name of the property to set. property_value: The value to set for the property. Returns: A dictionary containing the result of the operation. """ from unreal_mcp_server import get_unreal_connection conn = get_unreal_connection() if not conn: return {"status": "error", "error": "Not connected to Unreal Engine"} params = { "blueprint_name": blueprint_name, "property_name": property_name, "property_value": property_value } response = conn.send_command("set_blueprint_property", params) return response @mcp.tool() def set_physics_properties( blueprint_name: str, component_name: str, simulate_physics: bool = True, mass: float = 1.0, linear_damping: float = 0.01, angular_damping: float = 0.01, enable_gravity: bool = True ) -> Dict[str, Any]: """Set physics properties for a component in a Blueprint. Args: blueprint_name: The name or path of the Blueprint to modify. component_name: The name of the component to modify. simulate_physics: Whether physics simulation should be enabled. mass: The mass of the component in kg. linear_damping: Linear movement damping factor. angular_damping: Angular movement damping factor. enable_gravity: Whether gravity should affect this component. Returns: A dictionary containing the result of the operation. """ from unreal_mcp_server import get_unreal_connection conn = get_unreal_connection() if not conn: return {"status": "error", "error": "Not connected to Unreal Engine"} params = { "blueprint_name": blueprint_name, "component_name": component_name, "simulate_physics": simulate_physics, "mass": mass, "linear_damping": linear_damping, "angular_damping": angular_damping, "enable_gravity": enable_gravity } response = conn.send_command("set_physics_properties", params) return response @mcp.tool() def set_pawn_properties( blueprint_name: str, use_controller_rotation_yaw: bool = False, use_controller_rotation_pitch: bool = False, use_controller_rotation_roll: bool = False, can_be_possessed: bool = True ) -> Dict[str, Any]: """Set Pawn-specific properties for a Pawn or Character Blueprint. Args: blueprint_name: The name or path of the Pawn/Character Blueprint to modify. use_controller_rotation_yaw: Whether the Pawn should use controller rotation yaw. use_controller_rotation_pitch: Whether the Pawn should use controller rotation pitch. use_controller_rotation_roll: Whether the Pawn should use controller rotation roll. can_be_possessed: Whether the Pawn can be possessed by a controller. Returns: A dictionary containing the result of the operation. """ from unreal_mcp_server import get_unreal_connection conn = get_unreal_connection() if not conn: return {"status": "error", "error": "Not connected to Unreal Engine"} params = { "blueprint_name": blueprint_name, "use_controller_rotation_yaw": use_controller_rotation_yaw, "use_controller_rotation_pitch": use_controller_rotation_pitch, "use_controller_rotation_roll": use_controller_rotation_roll, "can_be_possessed": can_be_possessed } response = conn.send_command("set_pawn_properties", params) return response @mcp.tool() def get_blueprint_components(blueprint_name: str) -> Dict[str, Any]: """Get a list of components in a Blueprint class. Args: blueprint_name: The name or path of the Blueprint. Returns: A dictionary containing the list of components with their types and properties. """ from unreal_mcp_server import get_unreal_connection conn = get_unreal_connection() if not conn: return {"status": "error", "error": "Not connected to Unreal Engine"} params = {"blueprint_name": blueprint_name} response = conn.send_command("get_blueprint_components", params) return response @mcp.tool() def remove_component_from_blueprint( blueprint_name: str, component_name: str ) -> Dict[str, Any]: """Remove a component from a Blueprint class. Args: blueprint_name: The name or path of the Blueprint to modify. component_name: The name of the component to remove. Returns: A dictionary containing the result of the operation. """ from unreal_mcp_server import get_unreal_connection conn = get_unreal_connection() if not conn: return {"status": "error", "error": "Not connected to Unreal Engine"} params = { "blueprint_name": blueprint_name, "component_name": component_name } response = conn.send_command("remove_component_from_blueprint", params) return response logger.info("Registered blueprint tools")

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/gingerol/UnrealEngine-ai-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server