Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 5 additions & 16 deletions UnityMcpBridge/Editor/Tools/MenuItems/MenuItemExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,12 @@ public static object Execute(JObject @params)

try
{
// Execute on main thread using delayCall
EditorApplication.delayCall += () =>
bool executed = EditorApplication.ExecuteMenuItem(menuPath);
if (!executed)
{
try
{
bool executed = EditorApplication.ExecuteMenuItem(menuPath);
if (!executed)
{
McpLog.Error($"[MenuItemExecutor] Failed to execute menu item via delayCall: '{menuPath}'. It might be invalid, disabled, or context-dependent.");
}
}
catch (Exception delayEx)
{
McpLog.Error($"[MenuItemExecutor] Exception during delayed execution of '{menuPath}': {delayEx}");
}
};

McpLog.Error($"[MenuItemExecutor] Failed to execute menu item via delayCall: '{menuPath}'. It might be invalid, disabled, or context-dependent.");
return Response.Error($"Failed to execute menu item '{menuPath}'. It might be invalid, disabled, or context-dependent.");
}
return Response.Success($"Attempted to execute menu item: '{menuPath}'. Check Unity logs for confirmation or errors.");
}
catch (Exception e)
Expand Down
14 changes: 1 addition & 13 deletions UnityMcpBridge/UnityMcpServer~/src/tools/manage_menu_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
def register_manage_menu_item_tools(mcp: FastMCP):
"""Registers the manage_menu_item tool with the MCP server."""

@mcp.tool()
@mcp.tool(description="Manage Unity menu items (execute/list/exists)")
@telemetry_tool("manage_menu_item")
async def manage_menu_item(
ctx: Context,
Expand All @@ -25,18 +25,6 @@ async def manage_menu_item(
refresh: Annotated[bool | None,
"Optional flag to force refresh of the menu cache when listing"] = None,
) -> dict[str, Any]:
"""Manage Unity menu items (execute/list/exists).

Args:
ctx: The MCP context.
action: One of 'execute', 'list', 'exists'.
menu_path: Menu path for 'execute' or 'exists' (e.g., "File/Save Project").
search: Optional filter string for 'list'.
refresh: Optional flag to force refresh of the menu cache when listing.

Returns:
A dictionary with operation results ('success', 'data', 'error').
"""
# Prepare parameters for the C# handler
params_dict: dict[str, Any] = {
"action": action,
Expand Down