�
���g- � �8 � d dl mZmZ d dlmZ d dlmZ defd�Zy)� )�FastMCP�Context)�List)�get_unity_connection�mcpc �J � | j � ddt dt dt dt fd�� }| j � ddt dt dt d t d
t dt dt d
t dt fd�� }| j � ddt dt d
t dt dt dt fd�� }| j � ddt dt dt fd�� }| j � ddt dt dt dt dt f
d�� }y)z6Register all script-related tools with the MCP server.�ctx�script_path�require_exists�returnc �: � |j d� sd|� �}t d|� �� t � j d||d�� }|j dd� r|j dd� S |j d d
� S # t
$ r}dt
|� � �cY d}~S d}~ww xY w)
ay View the contents of a Unity script file.
Args:
ctx: The MCP context
script_path: Path to the script file relative to the Assets folder
require_exists: Whether to raise an error if the file doesn't exist (default: True)
Returns:
str: The contents of the script file or error message
�Assets/z+ViewScript - Using normalized script path: �VIEW_SCRIPT)r
r �existsT�contentzScript contents not available�messagezScript not foundzError viewing script: N)�
startswith�printr �send_command�get� Exception�str)r r
r �response�es ��C:\1_Sagyo\VRchat\Project\IshouJidouChouseiToul\Library\PackageCache\com.zundamonnovrchat.unity-mcp-ollama@994ecdcda9\Python\tools\script_tools.py�view_scriptz*register_script_tools.<locals>.view_script s� � � 5��)�)�)�4� '��}�5��
�?��}�M�N� ,�-�:�:�=�*�"0�K� �H�
�|�|�H�d�+��|�|�I�/N�O�O��|�|�I�/A�B�B��� 5�+�C��F�8�4�4�� 5�s$ �A$A9 �'A9 �9 B�
B�B�BN�script_name�script_type� namespace�template�
script_folder� overwriter c �� � t � }|re|j d� r|} nd|� �} | j d� r| � |� d�}
n| � d|� d�}
t d|� �� t d| � �� t d|
� �� nd|� d�}
t d|
� �� |||||d �}|r||d
<