coplay-mcp-server 1.4.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,240 @@
1
+ """Generated MCP tools from package_tool_schema.json"""
2
+
3
+ import logging
4
+ from typing import Annotated, Optional, Any, Dict, Literal
5
+ from pydantic import Field
6
+ from fastmcp import FastMCP
7
+ from ..unity_client import UnityRpcClient
8
+
9
+ logger = logging.getLogger(__name__)
10
+
11
+ # Global references to be set by register_tools
12
+ _mcp: Optional[FastMCP] = None
13
+ _unity_client: Optional[UnityRpcClient] = None
14
+
15
+
16
+ async def export_package(
17
+ asset_paths: Annotated[
18
+ str,
19
+ Field(
20
+ description="""Comma-separated list of asset paths to include."""
21
+ ),
22
+ ],
23
+ package_name: Annotated[
24
+ str,
25
+ Field(
26
+ description="""Name of the package file."""
27
+ ),
28
+ ],
29
+ ) -> Any:
30
+ """Exports selected assets as a Unity package."""
31
+ try:
32
+ logger.debug(f"Executing export_package with parameters: {locals()}")
33
+
34
+ # Prepare parameters for Unity RPC call
35
+ params = {}
36
+ if asset_paths is not None:
37
+ params['asset_paths'] = str(asset_paths)
38
+ if package_name is not None:
39
+ params['package_name'] = str(package_name)
40
+
41
+ # Execute Unity RPC call
42
+ result = await _unity_client.execute_request('export_package', params)
43
+ logger.debug(f"export_package completed successfully")
44
+ return result
45
+
46
+ except Exception as e:
47
+ logger.error(f"Failed to execute export_package: {e}")
48
+ raise RuntimeError(f"Tool execution failed for export_package: {e}")
49
+
50
+
51
+ async def install_unity_package(
52
+ package_name: Annotated[
53
+ str,
54
+ Field(
55
+ description="""The name of the Unity package to install."""
56
+ ),
57
+ ],
58
+ version: Annotated[
59
+ str | None,
60
+ Field(
61
+ description="""Optional version of the package. If not specified, the latest version will be installed."""
62
+ ),
63
+ ] = None,
64
+ ) -> Any:
65
+ """Installs a Unity package by name and optional version."""
66
+ try:
67
+ logger.debug(f"Executing install_unity_package with parameters: {locals()}")
68
+
69
+ # Prepare parameters for Unity RPC call
70
+ params = {}
71
+ if package_name is not None:
72
+ params['package_name'] = str(package_name)
73
+ if version is not None:
74
+ params['version'] = str(version)
75
+
76
+ # Execute Unity RPC call
77
+ result = await _unity_client.execute_request('install_unity_package', params)
78
+ logger.debug(f"install_unity_package completed successfully")
79
+ return result
80
+
81
+ except Exception as e:
82
+ logger.error(f"Failed to execute install_unity_package: {e}")
83
+ raise RuntimeError(f"Tool execution failed for install_unity_package: {e}")
84
+
85
+
86
+ async def install_git_package(
87
+ repository_url: Annotated[
88
+ str,
89
+ Field(
90
+ description="""The URL of the public Git repository containing the Unity package."""
91
+ ),
92
+ ],
93
+ branch: Annotated[
94
+ str | None,
95
+ Field(
96
+ description="""Optional branch to use. Defaults to the main or master branch."""
97
+ ),
98
+ ] = None,
99
+ package_name: Annotated[
100
+ str | None,
101
+ Field(
102
+ description="""Optional name for the package."""
103
+ ),
104
+ ] = None,
105
+ ) -> Any:
106
+ """Installs a Unity package from a public Git repository."""
107
+ try:
108
+ logger.debug(f"Executing install_git_package with parameters: {locals()}")
109
+
110
+ # Prepare parameters for Unity RPC call
111
+ params = {}
112
+ if repository_url is not None:
113
+ params['repository_url'] = str(repository_url)
114
+ if branch is not None:
115
+ params['branch'] = str(branch)
116
+ if package_name is not None:
117
+ params['package_name'] = str(package_name)
118
+
119
+ # Execute Unity RPC call
120
+ result = await _unity_client.execute_request('install_git_package', params)
121
+ logger.debug(f"install_git_package completed successfully")
122
+ return result
123
+
124
+ except Exception as e:
125
+ logger.error(f"Failed to execute install_git_package: {e}")
126
+ raise RuntimeError(f"Tool execution failed for install_git_package: {e}")
127
+
128
+
129
+ async def remove_unity_package(
130
+ package_name: Annotated[
131
+ str,
132
+ Field(
133
+ description="""The name of the Unity package to remove."""
134
+ ),
135
+ ],
136
+ ) -> Any:
137
+ """Removes a Unity package by its name."""
138
+ try:
139
+ logger.debug(f"Executing remove_unity_package with parameters: {locals()}")
140
+
141
+ # Prepare parameters for Unity RPC call
142
+ params = {}
143
+ if package_name is not None:
144
+ params['package_name'] = str(package_name)
145
+
146
+ # Execute Unity RPC call
147
+ result = await _unity_client.execute_request('remove_unity_package', params)
148
+ logger.debug(f"remove_unity_package completed successfully")
149
+ return result
150
+
151
+ except Exception as e:
152
+ logger.error(f"Failed to execute remove_unity_package: {e}")
153
+ raise RuntimeError(f"Tool execution failed for remove_unity_package: {e}")
154
+
155
+
156
+ async def list_packages(
157
+ ) -> Any:
158
+ """Retrieves a list of installed packages in this project."""
159
+ try:
160
+ logger.debug(f"Executing list_packages with parameters: {locals()}")
161
+
162
+ # Prepare parameters for Unity RPC call
163
+ params = {}
164
+
165
+ # Execute Unity RPC call
166
+ result = await _unity_client.execute_request('list_packages', params)
167
+ logger.debug(f"list_packages completed successfully")
168
+ return result
169
+
170
+ except Exception as e:
171
+ logger.error(f"Failed to execute list_packages: {e}")
172
+ raise RuntimeError(f"Tool execution failed for list_packages: {e}")
173
+
174
+
175
+ async def search_installed_packages(
176
+ package_name: Annotated[
177
+ str,
178
+ Field(
179
+ description="""The name of the package to search for."""
180
+ ),
181
+ ],
182
+ ) -> Any:
183
+ """Searches for installed packages in this project."""
184
+ try:
185
+ logger.debug(f"Executing search_installed_packages with parameters: {locals()}")
186
+
187
+ # Prepare parameters for Unity RPC call
188
+ params = {}
189
+ if package_name is not None:
190
+ params['package_name'] = str(package_name)
191
+
192
+ # Execute Unity RPC call
193
+ result = await _unity_client.execute_request('search_installed_packages', params)
194
+ logger.debug(f"search_installed_packages completed successfully")
195
+ return result
196
+
197
+ except Exception as e:
198
+ logger.error(f"Failed to execute search_installed_packages: {e}")
199
+ raise RuntimeError(f"Tool execution failed for search_installed_packages: {e}")
200
+
201
+
202
+ async def search_all_packages(
203
+ ) -> Any:
204
+ """Searches for packages in the Unity registry."""
205
+ try:
206
+ logger.debug(f"Executing search_all_packages with parameters: {locals()}")
207
+
208
+ # Prepare parameters for Unity RPC call
209
+ params = {}
210
+
211
+ # Execute Unity RPC call
212
+ result = await _unity_client.execute_request('search_all_packages', params)
213
+ logger.debug(f"search_all_packages completed successfully")
214
+ return result
215
+
216
+ except Exception as e:
217
+ logger.error(f"Failed to execute search_all_packages: {e}")
218
+ raise RuntimeError(f"Tool execution failed for search_all_packages: {e}")
219
+
220
+
221
+ def register_tools(mcp: FastMCP, unity_client: UnityRpcClient) -> None:
222
+ """Register all tools from package_tool_schema with the MCP server."""
223
+ global _mcp, _unity_client
224
+ _mcp = mcp
225
+ _unity_client = unity_client
226
+
227
+ # Register export_package
228
+ mcp.tool()(export_package)
229
+ # Register install_unity_package
230
+ mcp.tool()(install_unity_package)
231
+ # Register install_git_package
232
+ mcp.tool()(install_git_package)
233
+ # Register remove_unity_package
234
+ mcp.tool()(remove_unity_package)
235
+ # Register list_packages
236
+ mcp.tool()(list_packages)
237
+ # Register search_installed_packages
238
+ mcp.tool()(search_installed_packages)
239
+ # Register search_all_packages
240
+ mcp.tool()(search_all_packages)
@@ -0,0 +1,63 @@
1
+ """Generated MCP tools from profiler_functions_schema.json"""
2
+
3
+ import logging
4
+ from typing import Annotated, Optional, Any, Dict, Literal
5
+ from pydantic import Field
6
+ from fastmcp import FastMCP
7
+ from ..unity_client import UnityRpcClient
8
+
9
+ logger = logging.getLogger(__name__)
10
+
11
+ # Global references to be set by register_tools
12
+ _mcp: Optional[FastMCP] = None
13
+ _unity_client: Optional[UnityRpcClient] = None
14
+
15
+
16
+ async def get_worst_cpu_frames(
17
+ ) -> Any:
18
+ """Identifies the worst CPU frames in profiling data, formats their function calls and timings, and returns the result as a string."""
19
+ try:
20
+ logger.debug(f"Executing get_worst_cpu_frames with parameters: {locals()}")
21
+
22
+ # Prepare parameters for Unity RPC call
23
+ params = {}
24
+
25
+ # Execute Unity RPC call
26
+ result = await _unity_client.execute_request('get_worst_cpu_frames', params)
27
+ logger.debug(f"get_worst_cpu_frames completed successfully")
28
+ return result
29
+
30
+ except Exception as e:
31
+ logger.error(f"Failed to execute get_worst_cpu_frames: {e}")
32
+ raise RuntimeError(f"Tool execution failed for get_worst_cpu_frames: {e}")
33
+
34
+
35
+ async def get_worst_gc_frames(
36
+ ) -> Any:
37
+ """Identifies the worst GC frames in profiling data, formats their function calls and allocation sizes, and returns the result as a string."""
38
+ try:
39
+ logger.debug(f"Executing get_worst_gc_frames with parameters: {locals()}")
40
+
41
+ # Prepare parameters for Unity RPC call
42
+ params = {}
43
+
44
+ # Execute Unity RPC call
45
+ result = await _unity_client.execute_request('get_worst_gc_frames', params)
46
+ logger.debug(f"get_worst_gc_frames completed successfully")
47
+ return result
48
+
49
+ except Exception as e:
50
+ logger.error(f"Failed to execute get_worst_gc_frames: {e}")
51
+ raise RuntimeError(f"Tool execution failed for get_worst_gc_frames: {e}")
52
+
53
+
54
+ def register_tools(mcp: FastMCP, unity_client: UnityRpcClient) -> None:
55
+ """Register all tools from profiler_functions_schema with the MCP server."""
56
+ global _mcp, _unity_client
57
+ _mcp = mcp
58
+ _unity_client = unity_client
59
+
60
+ # Register get_worst_cpu_frames
61
+ mcp.tool()(get_worst_cpu_frames)
62
+ # Register get_worst_gc_frames
63
+ mcp.tool()(get_worst_gc_frames)
@@ -0,0 +1,58 @@
1
+ """Generated MCP tools from scene_view_functions_schema.json"""
2
+
3
+ import logging
4
+ from typing import Annotated, Optional, Any, Dict, Literal
5
+ from pydantic import Field
6
+ from fastmcp import FastMCP
7
+ from ..unity_client import UnityRpcClient
8
+
9
+ logger = logging.getLogger(__name__)
10
+
11
+ # Global references to be set by register_tools
12
+ _mcp: Optional[FastMCP] = None
13
+ _unity_client: Optional[UnityRpcClient] = None
14
+
15
+
16
+ async def scene_view_functions(
17
+ toggle_2d_mode: Annotated[
18
+ bool | None,
19
+ Field(
20
+ description="""Toggle between 2D and 3D Scene View mode. Set to true for 2D mode, false for 3D mode, or null to leave unchanged."""
21
+ ),
22
+ ] = None,
23
+ toggle_lighting: Annotated[
24
+ bool | None,
25
+ Field(
26
+ description="""Toggle Scene View lighting on/off. When enabled, shows realistic lighting in the Scene View. Set to true to enable, false to disable, or null to leave unchanged."""
27
+ ),
28
+ ] = None,
29
+ ) -> Any:
30
+ """Control Unity Scene View settings including 2D/3D mode, lighting."""
31
+ try:
32
+ logger.debug(f"Executing scene_view_functions with parameters: {locals()}")
33
+
34
+ # Prepare parameters for Unity RPC call
35
+ params = {}
36
+ if toggle_2d_mode is not None:
37
+ params['toggle_2d_mode'] = str(toggle_2d_mode)
38
+ if toggle_lighting is not None:
39
+ params['toggle_lighting'] = str(toggle_lighting)
40
+
41
+ # Execute Unity RPC call
42
+ result = await _unity_client.execute_request('scene_view_functions', params)
43
+ logger.debug(f"scene_view_functions completed successfully")
44
+ return result
45
+
46
+ except Exception as e:
47
+ logger.error(f"Failed to execute scene_view_functions: {e}")
48
+ raise RuntimeError(f"Tool execution failed for scene_view_functions: {e}")
49
+
50
+
51
+ def register_tools(mcp: FastMCP, unity_client: UnityRpcClient) -> None:
52
+ """Register all tools from scene_view_functions_schema with the MCP server."""
53
+ global _mcp, _unity_client
54
+ _mcp = mcp
55
+ _unity_client = unity_client
56
+
57
+ # Register scene_view_functions
58
+ mcp.tool()(scene_view_functions)
@@ -0,0 +1,87 @@
1
+ """Generated MCP tools from screenshot_tool_schema.json"""
2
+
3
+ import logging
4
+ from typing import Annotated, Optional, Any, Dict, Literal
5
+ from pydantic import Field
6
+ from fastmcp import FastMCP
7
+ from ..unity_client import UnityRpcClient
8
+
9
+ logger = logging.getLogger(__name__)
10
+
11
+ # Global references to be set by register_tools
12
+ _mcp: Optional[FastMCP] = None
13
+ _unity_client: Optional[UnityRpcClient] = None
14
+
15
+
16
+ async def get_scene_view_screenshot(
17
+ gameObjectPath: Annotated[
18
+ str | None,
19
+ Field(
20
+ description="""Optional path of a game object in the active hierarchy to focus on before taking the screenshot (e.g. '/Root/Parent/Child'). If provided, the scene view will be focused on this object. If empty or null, no focusing will be performed."""
21
+ ),
22
+ ] = None,
23
+ includeUI: Annotated[
24
+ bool | None,
25
+ Field(
26
+ description="""Optional flag to include UI elements (gizmos, handles, overlays) in the screenshot. Defaults to false if not specified. When false, only the camera view is captured without UI elements."""
27
+ ),
28
+ ] = None,
29
+ ) -> Any:
30
+ """Captures a screenshot of the current Scene view. Use this tool to inspect or analyze the visual appearance of objects after making visual changes to a scene or prefab. Do not use it for validating UI Canvases."""
31
+ try:
32
+ logger.debug(f"Executing get_scene_view_screenshot with parameters: {locals()}")
33
+
34
+ # Prepare parameters for Unity RPC call
35
+ params = {}
36
+ if gameObjectPath is not None:
37
+ params['gameObjectPath'] = str(gameObjectPath)
38
+ if includeUI is not None:
39
+ params['includeUI'] = str(includeUI)
40
+
41
+ # Execute Unity RPC call
42
+ result = await _unity_client.execute_request('get_scene_view_screenshot', params)
43
+ logger.debug(f"get_scene_view_screenshot completed successfully")
44
+ return result
45
+
46
+ except Exception as e:
47
+ logger.error(f"Failed to execute get_scene_view_screenshot: {e}")
48
+ raise RuntimeError(f"Tool execution failed for get_scene_view_screenshot: {e}")
49
+
50
+
51
+ async def capture_ui_canvas(
52
+ canvasPath: Annotated[
53
+ str | None,
54
+ Field(
55
+ description="""Optional path to the canvas in the scene hierarchy. If provided, the specified Canvas will be captured. If empty or null, the first Canvas found in the scene will be captured."""
56
+ ),
57
+ ] = None,
58
+ ) -> Any:
59
+ """Captures a screenshot of a UI Canvas. Use this tool to capture and analyze Unity UI Canvases in the Scene hierarchy after generating UI for validation."""
60
+ try:
61
+ logger.debug(f"Executing capture_ui_canvas with parameters: {locals()}")
62
+
63
+ # Prepare parameters for Unity RPC call
64
+ params = {}
65
+ if canvasPath is not None:
66
+ params['canvasPath'] = str(canvasPath)
67
+
68
+ # Execute Unity RPC call
69
+ result = await _unity_client.execute_request('capture_ui_canvas', params)
70
+ logger.debug(f"capture_ui_canvas completed successfully")
71
+ return result
72
+
73
+ except Exception as e:
74
+ logger.error(f"Failed to execute capture_ui_canvas: {e}")
75
+ raise RuntimeError(f"Tool execution failed for capture_ui_canvas: {e}")
76
+
77
+
78
+ def register_tools(mcp: FastMCP, unity_client: UnityRpcClient) -> None:
79
+ """Register all tools from screenshot_tool_schema with the MCP server."""
80
+ global _mcp, _unity_client
81
+ _mcp = mcp
82
+ _unity_client = unity_client
83
+
84
+ # Register get_scene_view_screenshot
85
+ mcp.tool()(get_scene_view_screenshot)
86
+ # Register capture_ui_canvas
87
+ mcp.tool()(capture_ui_canvas)