Skip to content

Commit 730092d

Browse files
committed
refactor: update resource function return types to include MCPResponse union
1 parent 49d1fa9 commit 730092d

File tree

10 files changed

+11
-11
lines changed

10 files changed

+11
-11
lines changed

MCPForUnity/UnityMcpServer~/src/resources/active_tool.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class ActiveToolResponse(MCPResponse):
3131
name="editor_active_tool",
3232
description="Currently active editor tool (Move, Rotate, Scale, etc.) and transform handle settings."
3333
)
34-
async def get_active_tool() -> ActiveToolResponse:
34+
async def get_active_tool() -> ActiveToolResponse | MCPResponse:
3535
"""Get active editor tool information."""
3636
response = await async_send_command_with_retry("get_active_tool", {})
3737
return ActiveToolResponse(**response) if isinstance(response, dict) else response

MCPForUnity/UnityMcpServer~/src/resources/editor_state.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class EditorStateResponse(MCPResponse):
2626
name="editor_state",
2727
description="Current editor runtime state including play mode, compilation status, active scene, and selection summary. Refresh frequently for up-to-date information."
2828
)
29-
async def get_editor_state() -> EditorStateResponse:
29+
async def get_editor_state() -> EditorStateResponse | MCPResponse:
3030
"""Get current editor runtime state."""
3131
response = await async_send_command_with_retry("get_editor_state", {})
3232
return EditorStateResponse(**response) if isinstance(response, dict) else response

MCPForUnity/UnityMcpServer~/src/resources/layers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class LayersResponse(MCPResponse):
1313
name="project_layers",
1414
description="All layers defined in the project's TagManager with their indices (0-31). Read this before using add_layer or remove_layer tools."
1515
)
16-
async def get_layers() -> LayersResponse:
16+
async def get_layers() -> LayersResponse | MCPResponse:
1717
"""Get all project layers with their indices."""
1818
response = await async_send_command_with_retry("get_layers", {})
1919
return LayersResponse(**response) if isinstance(response, dict) else response

MCPForUnity/UnityMcpServer~/src/resources/menu_items.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class GetMenuItemsResponse(MCPResponse):
1515
name="menu_items",
1616
description="Provides a list of all menu items."
1717
)
18-
async def get_menu_items(ctx: Context) -> GetMenuItemsResponse:
18+
async def get_menu_items(ctx: Context) -> GetMenuItemsResponse | MCPResponse:
1919
"""Provides a list of all menu items.
2020
"""
2121
unity_instance = get_unity_instance_from_context(ctx)

MCPForUnity/UnityMcpServer~/src/resources/prefab_stage.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class PrefabStageResponse(MCPResponse):
2323
name="editor_prefab_stage",
2424
description="Current prefab editing context if a prefab is open in isolation mode. Returns isOpen=false if no prefab is being edited."
2525
)
26-
async def get_prefab_stage() -> PrefabStageResponse:
26+
async def get_prefab_stage() -> PrefabStageResponse | MCPResponse:
2727
"""Get current prefab stage information."""
2828
response = await async_send_command_with_retry("get_prefab_stage", {})
2929
return PrefabStageResponse(**response) if isinstance(response, dict) else response

MCPForUnity/UnityMcpServer~/src/resources/project_info.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class ProjectInfoResponse(MCPResponse):
2323
name="project_info",
2424
description="Static project information including root path, Unity version, and platform. This data rarely changes."
2525
)
26-
async def get_project_info() -> ProjectInfoResponse:
26+
async def get_project_info() -> ProjectInfoResponse | MCPResponse:
2727
"""Get static project configuration information."""
2828
response = await async_send_command_with_retry("get_project_info", {})
2929
return ProjectInfoResponse(**response) if isinstance(response, dict) else response

MCPForUnity/UnityMcpServer~/src/resources/selection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class SelectionResponse(MCPResponse):
3939
name="editor_selection",
4040
description="Detailed information about currently selected objects in the editor, including GameObjects, assets, and their properties."
4141
)
42-
async def get_selection() -> SelectionResponse:
42+
async def get_selection() -> SelectionResponse | MCPResponse:
4343
"""Get detailed editor selection information."""
4444
response = await async_send_command_with_retry("get_selection", {})
4545
return SelectionResponse(**response) if isinstance(response, dict) else response

MCPForUnity/UnityMcpServer~/src/resources/tags.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class TagsResponse(MCPResponse):
1414
name="project_tags",
1515
description="All tags defined in the project's TagManager. Read this before using add_tag or remove_tag tools."
1616
)
17-
async def get_tags() -> TagsResponse:
17+
async def get_tags() -> TagsResponse | MCPResponse:
1818
"""Get all project tags."""
1919
response = await async_send_command_with_retry("get_tags", {})
2020
return TagsResponse(**response) if isinstance(response, dict) else response

MCPForUnity/UnityMcpServer~/src/resources/tests.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class GetTestsResponse(MCPResponse):
2121

2222

2323
@mcp_for_unity_resource(uri="mcpforunity://tests", name="get_tests", description="Provides a list of all tests.")
24-
async def get_tests(ctx: Context) -> GetTestsResponse:
24+
async def get_tests(ctx: Context) -> GetTestsResponse | MCPResponse:
2525
"""Provides a list of all tests.
2626
"""
2727
unity_instance = get_unity_instance_from_context(ctx)
@@ -38,7 +38,7 @@ async def get_tests(ctx: Context) -> GetTestsResponse:
3838
async def get_tests_for_mode(
3939
ctx: Context,
4040
mode: Annotated[Literal["EditMode", "PlayMode"], Field(description="The mode to filter tests by.")],
41-
) -> GetTestsResponse:
41+
) -> GetTestsResponse | MCPResponse:
4242
"""Provides a list of tests for a specific mode.
4343
4444
Args:

MCPForUnity/UnityMcpServer~/src/resources/windows.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class WindowsResponse(MCPResponse):
3131
name="editor_windows",
3232
description="All currently open editor windows with their titles, types, positions, and focus state."
3333
)
34-
async def get_windows() -> WindowsResponse:
34+
async def get_windows() -> WindowsResponse | MCPResponse:
3535
"""Get all open editor windows."""
3636
response = await async_send_command_with_retry("get_windows", {})
3737
return WindowsResponse(**response) if isinstance(response, dict) else response

0 commit comments

Comments
 (0)