File tree Expand file tree Collapse file tree 2 files changed +6
-29
lines changed
UnityMcpServer~/src/tools Expand file tree Collapse file tree 2 files changed +6
-29
lines changed Original file line number Diff line number Diff line change @@ -36,23 +36,12 @@ public static object Execute(JObject @params)
36
36
37
37
try
38
38
{
39
- // Execute on main thread using delayCall
40
- EditorApplication . delayCall += ( ) =>
39
+ bool executed = EditorApplication . ExecuteMenuItem ( menuPath ) ;
40
+ if ( ! executed )
41
41
{
42
- try
43
- {
44
- bool executed = EditorApplication . ExecuteMenuItem ( menuPath ) ;
45
- if ( ! executed )
46
- {
47
- McpLog . Error ( $ "[MenuItemExecutor] Failed to execute menu item via delayCall: '{ menuPath } '. It might be invalid, disabled, or context-dependent.") ;
48
- }
49
- }
50
- catch ( Exception delayEx )
51
- {
52
- McpLog . Error ( $ "[MenuItemExecutor] Exception during delayed execution of '{ menuPath } ': { delayEx } ") ;
53
- }
54
- } ;
55
-
42
+ McpLog . Error ( $ "[MenuItemExecutor] Failed to execute menu item via delayCall: '{ menuPath } '. It might be invalid, disabled, or context-dependent.") ;
43
+ return Response . Error ( $ "Failed to execute menu item '{ menuPath } '. It might be invalid, disabled, or context-dependent.") ;
44
+ }
56
45
return Response . Success ( $ "Attempted to execute menu item: '{ menuPath } '. Check Unity logs for confirmation or errors.") ;
57
46
}
58
47
catch ( Exception e )
Original file line number Diff line number Diff line change 13
13
def register_manage_menu_item_tools (mcp : FastMCP ):
14
14
"""Registers the manage_menu_item tool with the MCP server."""
15
15
16
- @mcp .tool ()
16
+ @mcp .tool (description = "Manage Unity menu items (execute/list/exists)" )
17
17
@telemetry_tool ("manage_menu_item" )
18
18
async def manage_menu_item (
19
19
ctx : Context ,
@@ -25,18 +25,6 @@ async def manage_menu_item(
25
25
refresh : Annotated [bool | None ,
26
26
"Optional flag to force refresh of the menu cache when listing" ] = None ,
27
27
) -> dict [str , Any ]:
28
- """Manage Unity menu items (execute/list/exists).
29
-
30
- Args:
31
- ctx: The MCP context.
32
- action: One of 'execute', 'list', 'exists'.
33
- menu_path: Menu path for 'execute' or 'exists' (e.g., "File/Save Project").
34
- search: Optional filter string for 'list'.
35
- refresh: Optional flag to force refresh of the menu cache when listing.
36
-
37
- Returns:
38
- A dictionary with operation results ('success', 'data', 'error').
39
- """
40
28
# Prepare parameters for the C# handler
41
29
params_dict : dict [str , Any ] = {
42
30
"action" : action ,
You can’t perform that action at this time.
0 commit comments