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.
- coplay_mcp_server/__init__.py +3 -0
- coplay_mcp_server/code_generator.py +370 -0
- coplay_mcp_server/generated_tools/.gitignore +4 -0
- coplay_mcp_server/generated_tools/__init__.py +4 -0
- coplay_mcp_server/generated_tools/agent_tool_tools.py +347 -0
- coplay_mcp_server/generated_tools/coplay_tool_tools.py +58 -0
- coplay_mcp_server/generated_tools/image_tool_tools.py +146 -0
- coplay_mcp_server/generated_tools/input_action_tool_tools.py +718 -0
- coplay_mcp_server/generated_tools/package_tool_tools.py +240 -0
- coplay_mcp_server/generated_tools/profiler_functions_tools.py +63 -0
- coplay_mcp_server/generated_tools/scene_view_functions_tools.py +58 -0
- coplay_mcp_server/generated_tools/screenshot_tool_tools.py +87 -0
- coplay_mcp_server/generated_tools/snapping_functions_tools.py +409 -0
- coplay_mcp_server/generated_tools/ui_functions_tools.py +419 -0
- coplay_mcp_server/generated_tools/unity_functions_tools.py +1643 -0
- coplay_mcp_server/image_utils.py +96 -0
- coplay_mcp_server/process_discovery.py +168 -0
- coplay_mcp_server/server.py +236 -0
- coplay_mcp_server/unity_client.py +342 -0
- coplay_mcp_server-1.4.1.dist-info/METADATA +70 -0
- coplay_mcp_server-1.4.1.dist-info/RECORD +24 -0
- coplay_mcp_server-1.4.1.dist-info/WHEEL +4 -0
- coplay_mcp_server-1.4.1.dist-info/entry_points.txt +3 -0
- coplay_mcp_server-1.4.1.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,409 @@
|
|
|
1
|
+
"""Generated MCP tools from snapping_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 snap_to_grid(
|
|
17
|
+
gameObjectPath: Annotated[
|
|
18
|
+
str,
|
|
19
|
+
Field(
|
|
20
|
+
description="""Path to the GameObject in the scene or in a prefab asset. e.g Body/Head/Eyes"""
|
|
21
|
+
),
|
|
22
|
+
],
|
|
23
|
+
prefabPath: Annotated[
|
|
24
|
+
str | None,
|
|
25
|
+
Field(
|
|
26
|
+
description="""Optional. Filesystem path to a prefab asset i.e. files that end in .prefab. Example: Assets/MyPrefab.prefab. Only used when reading/modifying a prefab."""
|
|
27
|
+
),
|
|
28
|
+
] = None,
|
|
29
|
+
gridSize: Annotated[
|
|
30
|
+
float | None,
|
|
31
|
+
Field(
|
|
32
|
+
description="""Uniform grid size for all axes. Defaults to 1.0 if null."""
|
|
33
|
+
),
|
|
34
|
+
] = None,
|
|
35
|
+
gridSizeX: Annotated[
|
|
36
|
+
float | None,
|
|
37
|
+
Field(
|
|
38
|
+
description="""Grid size for the X axis (overrides gridSize if specified)."""
|
|
39
|
+
),
|
|
40
|
+
] = None,
|
|
41
|
+
gridSizeY: Annotated[
|
|
42
|
+
float | None,
|
|
43
|
+
Field(
|
|
44
|
+
description="""Grid size for the Y axis (overrides gridSize if specified)."""
|
|
45
|
+
),
|
|
46
|
+
] = None,
|
|
47
|
+
gridSizeZ: Annotated[
|
|
48
|
+
float | None,
|
|
49
|
+
Field(
|
|
50
|
+
description="""Grid size for the Z axis (overrides gridSize if specified)."""
|
|
51
|
+
),
|
|
52
|
+
] = None,
|
|
53
|
+
snapX: Annotated[
|
|
54
|
+
bool | None,
|
|
55
|
+
Field(
|
|
56
|
+
description="""Whether to snap on the X axis. Defaults to true if not specified."""
|
|
57
|
+
),
|
|
58
|
+
] = None,
|
|
59
|
+
snapY: Annotated[
|
|
60
|
+
bool | None,
|
|
61
|
+
Field(
|
|
62
|
+
description="""Whether to snap on the Y axis. Defaults to true if not specified."""
|
|
63
|
+
),
|
|
64
|
+
] = None,
|
|
65
|
+
snapZ: Annotated[
|
|
66
|
+
bool | None,
|
|
67
|
+
Field(
|
|
68
|
+
description="""Whether to snap on the Z axis. Defaults to true if not specified."""
|
|
69
|
+
),
|
|
70
|
+
] = None,
|
|
71
|
+
gridOrigin: Annotated[
|
|
72
|
+
str | None,
|
|
73
|
+
Field(
|
|
74
|
+
description="""Grid origin point in 'x,y,z' format. Defaults to '0,0,0' if not specified."""
|
|
75
|
+
),
|
|
76
|
+
] = None,
|
|
77
|
+
) -> Any:
|
|
78
|
+
"""Snaps a GameObject to a grid with configurable grid size and axes."""
|
|
79
|
+
try:
|
|
80
|
+
logger.debug(f"Executing snap_to_grid with parameters: {locals()}")
|
|
81
|
+
|
|
82
|
+
# Prepare parameters for Unity RPC call
|
|
83
|
+
params = {}
|
|
84
|
+
if gameObjectPath is not None:
|
|
85
|
+
params['gameObjectPath'] = str(gameObjectPath)
|
|
86
|
+
if prefabPath is not None:
|
|
87
|
+
params['prefabPath'] = str(prefabPath)
|
|
88
|
+
if gridSize is not None:
|
|
89
|
+
params['gridSize'] = str(gridSize)
|
|
90
|
+
if gridSizeX is not None:
|
|
91
|
+
params['gridSizeX'] = str(gridSizeX)
|
|
92
|
+
if gridSizeY is not None:
|
|
93
|
+
params['gridSizeY'] = str(gridSizeY)
|
|
94
|
+
if gridSizeZ is not None:
|
|
95
|
+
params['gridSizeZ'] = str(gridSizeZ)
|
|
96
|
+
if snapX is not None:
|
|
97
|
+
params['snapX'] = str(snapX)
|
|
98
|
+
if snapY is not None:
|
|
99
|
+
params['snapY'] = str(snapY)
|
|
100
|
+
if snapZ is not None:
|
|
101
|
+
params['snapZ'] = str(snapZ)
|
|
102
|
+
if gridOrigin is not None:
|
|
103
|
+
params['gridOrigin'] = str(gridOrigin)
|
|
104
|
+
|
|
105
|
+
# Execute Unity RPC call
|
|
106
|
+
result = await _unity_client.execute_request('snap_to_grid', params)
|
|
107
|
+
logger.debug(f"snap_to_grid completed successfully")
|
|
108
|
+
return result
|
|
109
|
+
|
|
110
|
+
except Exception as e:
|
|
111
|
+
logger.error(f"Failed to execute snap_to_grid: {e}")
|
|
112
|
+
raise RuntimeError(f"Tool execution failed for snap_to_grid: {e}")
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
async def snap_to_surface(
|
|
116
|
+
gameObjectPath: Annotated[
|
|
117
|
+
str,
|
|
118
|
+
Field(
|
|
119
|
+
description="""Path to the GameObject in the scene or in a prefab asset. e.g Body/Head/Eyes"""
|
|
120
|
+
),
|
|
121
|
+
],
|
|
122
|
+
prefabPath: Annotated[
|
|
123
|
+
str | None,
|
|
124
|
+
Field(
|
|
125
|
+
description="""Optional. Filesystem path to a prefab asset i.e. files that end in .prefab. Example: Assets/MyPrefab.prefab. Only used when reading/modifying a prefab."""
|
|
126
|
+
),
|
|
127
|
+
] = None,
|
|
128
|
+
raycastDirection: Annotated[
|
|
129
|
+
str | None,
|
|
130
|
+
Field(
|
|
131
|
+
description="""Raycast direction. Can be 'Down', 'Up', 'Forward', 'Back', 'Left', 'Right', or custom 'x,y,z' format. Defaults to 'Down'."""
|
|
132
|
+
),
|
|
133
|
+
] = None,
|
|
134
|
+
maxDistance: Annotated[
|
|
135
|
+
float | None,
|
|
136
|
+
Field(
|
|
137
|
+
description="""Maximum raycast distance. Defaults to 100 if not specified."""
|
|
138
|
+
),
|
|
139
|
+
] = None,
|
|
140
|
+
surfaceOffset: Annotated[
|
|
141
|
+
float | None,
|
|
142
|
+
Field(
|
|
143
|
+
description="""Offset distance from the surface. Defaults to 0 if not specified."""
|
|
144
|
+
),
|
|
145
|
+
] = None,
|
|
146
|
+
alignToSurfaceNormal: Annotated[
|
|
147
|
+
bool | None,
|
|
148
|
+
Field(
|
|
149
|
+
description="""Whether to align the object's rotation to the surface normal. Defaults to false if not specified."""
|
|
150
|
+
),
|
|
151
|
+
] = None,
|
|
152
|
+
layerMask: Annotated[
|
|
153
|
+
int | None,
|
|
154
|
+
Field(
|
|
155
|
+
description="""Layer mask for raycast filtering. Defaults to -1 (all layers) if not specified."""
|
|
156
|
+
),
|
|
157
|
+
] = None,
|
|
158
|
+
targetTag: Annotated[
|
|
159
|
+
str | None,
|
|
160
|
+
Field(
|
|
161
|
+
description="""Optional target tag filter. Only hit objects with this tag."""
|
|
162
|
+
),
|
|
163
|
+
] = None,
|
|
164
|
+
raycastOriginOffset: Annotated[
|
|
165
|
+
str | None,
|
|
166
|
+
Field(
|
|
167
|
+
description="""Optional raycast origin offset in 'x,y,z' format."""
|
|
168
|
+
),
|
|
169
|
+
] = None,
|
|
170
|
+
) -> Any:
|
|
171
|
+
"""Snaps a GameObject to the nearest surface using raycasting."""
|
|
172
|
+
try:
|
|
173
|
+
logger.debug(f"Executing snap_to_surface with parameters: {locals()}")
|
|
174
|
+
|
|
175
|
+
# Prepare parameters for Unity RPC call
|
|
176
|
+
params = {}
|
|
177
|
+
if gameObjectPath is not None:
|
|
178
|
+
params['gameObjectPath'] = str(gameObjectPath)
|
|
179
|
+
if prefabPath is not None:
|
|
180
|
+
params['prefabPath'] = str(prefabPath)
|
|
181
|
+
if raycastDirection is not None:
|
|
182
|
+
params['raycastDirection'] = str(raycastDirection)
|
|
183
|
+
if maxDistance is not None:
|
|
184
|
+
params['maxDistance'] = str(maxDistance)
|
|
185
|
+
if surfaceOffset is not None:
|
|
186
|
+
params['surfaceOffset'] = str(surfaceOffset)
|
|
187
|
+
if alignToSurfaceNormal is not None:
|
|
188
|
+
params['alignToSurfaceNormal'] = str(alignToSurfaceNormal)
|
|
189
|
+
if layerMask is not None:
|
|
190
|
+
params['layerMask'] = str(layerMask)
|
|
191
|
+
if targetTag is not None:
|
|
192
|
+
params['targetTag'] = str(targetTag)
|
|
193
|
+
if raycastOriginOffset is not None:
|
|
194
|
+
params['raycastOriginOffset'] = str(raycastOriginOffset)
|
|
195
|
+
|
|
196
|
+
# Execute Unity RPC call
|
|
197
|
+
result = await _unity_client.execute_request('snap_to_surface', params)
|
|
198
|
+
logger.debug(f"snap_to_surface completed successfully")
|
|
199
|
+
return result
|
|
200
|
+
|
|
201
|
+
except Exception as e:
|
|
202
|
+
logger.error(f"Failed to execute snap_to_surface: {e}")
|
|
203
|
+
raise RuntimeError(f"Tool execution failed for snap_to_surface: {e}")
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
async def snap_to_vertex(
|
|
207
|
+
gameObjectPath: Annotated[
|
|
208
|
+
str,
|
|
209
|
+
Field(
|
|
210
|
+
description="""Path to the GameObject in the scene or in a prefab asset. e.g Body/Head/Eyes"""
|
|
211
|
+
),
|
|
212
|
+
],
|
|
213
|
+
targetObjectPath: Annotated[
|
|
214
|
+
str,
|
|
215
|
+
Field(
|
|
216
|
+
description="""Path to the target GameObject whose vertices to snap to."""
|
|
217
|
+
),
|
|
218
|
+
],
|
|
219
|
+
prefabPath: Annotated[
|
|
220
|
+
str | None,
|
|
221
|
+
Field(
|
|
222
|
+
description="""Optional. Filesystem path to a prefab asset i.e. files that end in .prefab. Example: Assets/MyPrefab.prefab. Only used when reading/modifying a prefab."""
|
|
223
|
+
),
|
|
224
|
+
] = None,
|
|
225
|
+
maxDistance: Annotated[
|
|
226
|
+
float | None,
|
|
227
|
+
Field(
|
|
228
|
+
description="""Maximum distance to search for vertices. Defaults to 10 if not specified."""
|
|
229
|
+
),
|
|
230
|
+
] = None,
|
|
231
|
+
snapToClosest: Annotated[
|
|
232
|
+
bool | None,
|
|
233
|
+
Field(
|
|
234
|
+
description="""Whether to snap to the closest vertex (true) or first found within range (false). Defaults to true if not specified."""
|
|
235
|
+
),
|
|
236
|
+
] = None,
|
|
237
|
+
referencePoint: Annotated[
|
|
238
|
+
str | None,
|
|
239
|
+
Field(
|
|
240
|
+
description="""Reference point on the object to use for distance calculation. Can be 'Center', 'Pivot', or 'x,y,z' offset. Defaults to 'Pivot'."""
|
|
241
|
+
),
|
|
242
|
+
] = None,
|
|
243
|
+
) -> Any:
|
|
244
|
+
"""Snaps a GameObject to the nearest vertex of another GameObject."""
|
|
245
|
+
try:
|
|
246
|
+
logger.debug(f"Executing snap_to_vertex with parameters: {locals()}")
|
|
247
|
+
|
|
248
|
+
# Prepare parameters for Unity RPC call
|
|
249
|
+
params = {}
|
|
250
|
+
if gameObjectPath is not None:
|
|
251
|
+
params['gameObjectPath'] = str(gameObjectPath)
|
|
252
|
+
if prefabPath is not None:
|
|
253
|
+
params['prefabPath'] = str(prefabPath)
|
|
254
|
+
if targetObjectPath is not None:
|
|
255
|
+
params['targetObjectPath'] = str(targetObjectPath)
|
|
256
|
+
if maxDistance is not None:
|
|
257
|
+
params['maxDistance'] = str(maxDistance)
|
|
258
|
+
if snapToClosest is not None:
|
|
259
|
+
params['snapToClosest'] = str(snapToClosest)
|
|
260
|
+
if referencePoint is not None:
|
|
261
|
+
params['referencePoint'] = str(referencePoint)
|
|
262
|
+
|
|
263
|
+
# Execute Unity RPC call
|
|
264
|
+
result = await _unity_client.execute_request('snap_to_vertex', params)
|
|
265
|
+
logger.debug(f"snap_to_vertex completed successfully")
|
|
266
|
+
return result
|
|
267
|
+
|
|
268
|
+
except Exception as e:
|
|
269
|
+
logger.error(f"Failed to execute snap_to_vertex: {e}")
|
|
270
|
+
raise RuntimeError(f"Tool execution failed for snap_to_vertex: {e}")
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
async def snap_to_bounds(
|
|
274
|
+
gameObjectPath: Annotated[
|
|
275
|
+
str,
|
|
276
|
+
Field(
|
|
277
|
+
description="""Path to the GameObject in the scene or in a prefab asset. e.g Body/Head/Eyes"""
|
|
278
|
+
),
|
|
279
|
+
],
|
|
280
|
+
targetObjectPath: Annotated[
|
|
281
|
+
str,
|
|
282
|
+
Field(
|
|
283
|
+
description="""Path to the target GameObject whose bounds to snap to."""
|
|
284
|
+
),
|
|
285
|
+
],
|
|
286
|
+
prefabPath: Annotated[
|
|
287
|
+
str | None,
|
|
288
|
+
Field(
|
|
289
|
+
description="""Optional. Filesystem path to a prefab asset i.e. files that end in .prefab. Example: Assets/MyPrefab.prefab. Only used when reading/modifying a prefab."""
|
|
290
|
+
),
|
|
291
|
+
] = None,
|
|
292
|
+
targetReferenceX: Annotated[
|
|
293
|
+
str | None,
|
|
294
|
+
Field(
|
|
295
|
+
description="""X-axis reference point for the target object. Can be 'minX', 'centerX', 'maxX', or a custom numeric value. Defaults to 'centerX' if not specified."""
|
|
296
|
+
),
|
|
297
|
+
] = None,
|
|
298
|
+
targetReferenceY: Annotated[
|
|
299
|
+
str | None,
|
|
300
|
+
Field(
|
|
301
|
+
description="""Y-axis reference point for the target object. Can be 'minY', 'centerY', 'maxY', or a custom numeric value. Defaults to 'centerY' if not specified."""
|
|
302
|
+
),
|
|
303
|
+
] = None,
|
|
304
|
+
targetReferenceZ: Annotated[
|
|
305
|
+
str | None,
|
|
306
|
+
Field(
|
|
307
|
+
description="""Z-axis reference point for the target object. Can be 'minZ', 'centerZ', 'maxZ', or a custom numeric value. Defaults to 'centerZ' if not specified."""
|
|
308
|
+
),
|
|
309
|
+
] = None,
|
|
310
|
+
sourceReferenceX: Annotated[
|
|
311
|
+
str | None,
|
|
312
|
+
Field(
|
|
313
|
+
description="""X-axis reference point for the source object. Can be 'minX', 'centerX', 'maxX', or a custom numeric value. Defaults to 'centerX' if not specified."""
|
|
314
|
+
),
|
|
315
|
+
] = None,
|
|
316
|
+
sourceReferenceY: Annotated[
|
|
317
|
+
str | None,
|
|
318
|
+
Field(
|
|
319
|
+
description="""Y-axis reference point for the source object. Can be 'minY', 'centerY', 'maxY', or a custom numeric value. Defaults to 'centerY' if not specified."""
|
|
320
|
+
),
|
|
321
|
+
] = None,
|
|
322
|
+
sourceReferenceZ: Annotated[
|
|
323
|
+
str | None,
|
|
324
|
+
Field(
|
|
325
|
+
description="""Z-axis reference point for the source object. Can be 'minZ', 'centerZ', 'maxZ', or a custom numeric value. Defaults to 'centerZ' if not specified."""
|
|
326
|
+
),
|
|
327
|
+
] = None,
|
|
328
|
+
snapX: Annotated[
|
|
329
|
+
bool | None,
|
|
330
|
+
Field(
|
|
331
|
+
description="""Whether to snap on the X axis. Defaults to true if not specified."""
|
|
332
|
+
),
|
|
333
|
+
] = None,
|
|
334
|
+
snapY: Annotated[
|
|
335
|
+
bool | None,
|
|
336
|
+
Field(
|
|
337
|
+
description="""Whether to snap on the Y axis. Defaults to true if not specified."""
|
|
338
|
+
),
|
|
339
|
+
] = None,
|
|
340
|
+
snapZ: Annotated[
|
|
341
|
+
bool | None,
|
|
342
|
+
Field(
|
|
343
|
+
description="""Whether to snap on the Z axis. Defaults to true if not specified."""
|
|
344
|
+
),
|
|
345
|
+
] = None,
|
|
346
|
+
offset: Annotated[
|
|
347
|
+
str | None,
|
|
348
|
+
Field(
|
|
349
|
+
description="""Additional offset to apply after snapping in 'x,y,z' format."""
|
|
350
|
+
),
|
|
351
|
+
] = None,
|
|
352
|
+
) -> Any:
|
|
353
|
+
"""Snaps a GameObject to the bounds of another GameObject with per-axis reference point control for both source and target objects. Useful for aligning objects based on their bounding boxes."""
|
|
354
|
+
try:
|
|
355
|
+
logger.debug(f"Executing snap_to_bounds with parameters: {locals()}")
|
|
356
|
+
|
|
357
|
+
# Prepare parameters for Unity RPC call
|
|
358
|
+
params = {}
|
|
359
|
+
if gameObjectPath is not None:
|
|
360
|
+
params['gameObjectPath'] = str(gameObjectPath)
|
|
361
|
+
if prefabPath is not None:
|
|
362
|
+
params['prefabPath'] = str(prefabPath)
|
|
363
|
+
if targetObjectPath is not None:
|
|
364
|
+
params['targetObjectPath'] = str(targetObjectPath)
|
|
365
|
+
if targetReferenceX is not None:
|
|
366
|
+
params['targetReferenceX'] = str(targetReferenceX)
|
|
367
|
+
if targetReferenceY is not None:
|
|
368
|
+
params['targetReferenceY'] = str(targetReferenceY)
|
|
369
|
+
if targetReferenceZ is not None:
|
|
370
|
+
params['targetReferenceZ'] = str(targetReferenceZ)
|
|
371
|
+
if sourceReferenceX is not None:
|
|
372
|
+
params['sourceReferenceX'] = str(sourceReferenceX)
|
|
373
|
+
if sourceReferenceY is not None:
|
|
374
|
+
params['sourceReferenceY'] = str(sourceReferenceY)
|
|
375
|
+
if sourceReferenceZ is not None:
|
|
376
|
+
params['sourceReferenceZ'] = str(sourceReferenceZ)
|
|
377
|
+
if snapX is not None:
|
|
378
|
+
params['snapX'] = str(snapX)
|
|
379
|
+
if snapY is not None:
|
|
380
|
+
params['snapY'] = str(snapY)
|
|
381
|
+
if snapZ is not None:
|
|
382
|
+
params['snapZ'] = str(snapZ)
|
|
383
|
+
if offset is not None:
|
|
384
|
+
params['offset'] = str(offset)
|
|
385
|
+
|
|
386
|
+
# Execute Unity RPC call
|
|
387
|
+
result = await _unity_client.execute_request('snap_to_bounds', params)
|
|
388
|
+
logger.debug(f"snap_to_bounds completed successfully")
|
|
389
|
+
return result
|
|
390
|
+
|
|
391
|
+
except Exception as e:
|
|
392
|
+
logger.error(f"Failed to execute snap_to_bounds: {e}")
|
|
393
|
+
raise RuntimeError(f"Tool execution failed for snap_to_bounds: {e}")
|
|
394
|
+
|
|
395
|
+
|
|
396
|
+
def register_tools(mcp: FastMCP, unity_client: UnityRpcClient) -> None:
|
|
397
|
+
"""Register all tools from snapping_functions_schema with the MCP server."""
|
|
398
|
+
global _mcp, _unity_client
|
|
399
|
+
_mcp = mcp
|
|
400
|
+
_unity_client = unity_client
|
|
401
|
+
|
|
402
|
+
# Register snap_to_grid
|
|
403
|
+
mcp.tool()(snap_to_grid)
|
|
404
|
+
# Register snap_to_surface
|
|
405
|
+
mcp.tool()(snap_to_surface)
|
|
406
|
+
# Register snap_to_vertex
|
|
407
|
+
mcp.tool()(snap_to_vertex)
|
|
408
|
+
# Register snap_to_bounds
|
|
409
|
+
mcp.tool()(snap_to_bounds)
|