34 lines
951 B
Python
34 lines
951 B
Python
from fastmcp import Context
|
|
|
|
from models import MCPResponse
|
|
from registry import mcp_for_unity_resource
|
|
from tools import get_unity_instance_from_context, async_send_with_unity_instance
|
|
from unity_connection import async_send_command_with_retry
|
|
|
|
|
|
class GetMenuItemsResponse(MCPResponse):
|
|
data: list[str] = []
|
|
|
|
|
|
@mcp_for_unity_resource(
|
|
uri="mcpforunity://menu-items",
|
|
name="get_menu_items",
|
|
description="Provides a list of all menu items."
|
|
)
|
|
async def get_menu_items(ctx: Context) -> GetMenuItemsResponse:
|
|
"""Provides a list of all menu items.
|
|
"""
|
|
unity_instance = get_unity_instance_from_context(ctx)
|
|
params = {
|
|
"refresh": True,
|
|
"search": "",
|
|
}
|
|
|
|
response = await async_send_with_unity_instance(
|
|
async_send_command_with_retry,
|
|
unity_instance,
|
|
"get_menu_items",
|
|
params,
|
|
)
|
|
return GetMenuItemsResponse(**response) if isinstance(response, dict) else response
|