mcpforunityserver 9.4.0b20260203025228__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.
Files changed (105) hide show
  1. cli/__init__.py +3 -0
  2. cli/commands/__init__.py +3 -0
  3. cli/commands/animation.py +84 -0
  4. cli/commands/asset.py +280 -0
  5. cli/commands/audio.py +125 -0
  6. cli/commands/batch.py +171 -0
  7. cli/commands/code.py +182 -0
  8. cli/commands/component.py +190 -0
  9. cli/commands/editor.py +447 -0
  10. cli/commands/gameobject.py +487 -0
  11. cli/commands/instance.py +93 -0
  12. cli/commands/lighting.py +123 -0
  13. cli/commands/material.py +239 -0
  14. cli/commands/prefab.py +248 -0
  15. cli/commands/scene.py +231 -0
  16. cli/commands/script.py +222 -0
  17. cli/commands/shader.py +226 -0
  18. cli/commands/texture.py +540 -0
  19. cli/commands/tool.py +58 -0
  20. cli/commands/ui.py +258 -0
  21. cli/commands/vfx.py +421 -0
  22. cli/main.py +281 -0
  23. cli/utils/__init__.py +31 -0
  24. cli/utils/config.py +58 -0
  25. cli/utils/confirmation.py +37 -0
  26. cli/utils/connection.py +254 -0
  27. cli/utils/constants.py +23 -0
  28. cli/utils/output.py +195 -0
  29. cli/utils/parsers.py +112 -0
  30. cli/utils/suggestions.py +34 -0
  31. core/__init__.py +0 -0
  32. core/config.py +67 -0
  33. core/constants.py +4 -0
  34. core/logging_decorator.py +37 -0
  35. core/telemetry.py +551 -0
  36. core/telemetry_decorator.py +164 -0
  37. main.py +845 -0
  38. mcpforunityserver-9.4.0b20260203025228.dist-info/METADATA +328 -0
  39. mcpforunityserver-9.4.0b20260203025228.dist-info/RECORD +105 -0
  40. mcpforunityserver-9.4.0b20260203025228.dist-info/WHEEL +5 -0
  41. mcpforunityserver-9.4.0b20260203025228.dist-info/entry_points.txt +3 -0
  42. mcpforunityserver-9.4.0b20260203025228.dist-info/licenses/LICENSE +21 -0
  43. mcpforunityserver-9.4.0b20260203025228.dist-info/top_level.txt +7 -0
  44. models/__init__.py +4 -0
  45. models/models.py +56 -0
  46. models/unity_response.py +70 -0
  47. services/__init__.py +0 -0
  48. services/api_key_service.py +235 -0
  49. services/custom_tool_service.py +499 -0
  50. services/registry/__init__.py +22 -0
  51. services/registry/resource_registry.py +53 -0
  52. services/registry/tool_registry.py +51 -0
  53. services/resources/__init__.py +86 -0
  54. services/resources/active_tool.py +48 -0
  55. services/resources/custom_tools.py +57 -0
  56. services/resources/editor_state.py +304 -0
  57. services/resources/gameobject.py +243 -0
  58. services/resources/layers.py +30 -0
  59. services/resources/menu_items.py +35 -0
  60. services/resources/prefab.py +191 -0
  61. services/resources/prefab_stage.py +40 -0
  62. services/resources/project_info.py +40 -0
  63. services/resources/selection.py +56 -0
  64. services/resources/tags.py +31 -0
  65. services/resources/tests.py +88 -0
  66. services/resources/unity_instances.py +125 -0
  67. services/resources/windows.py +48 -0
  68. services/state/external_changes_scanner.py +245 -0
  69. services/tools/__init__.py +83 -0
  70. services/tools/batch_execute.py +93 -0
  71. services/tools/debug_request_context.py +86 -0
  72. services/tools/execute_custom_tool.py +43 -0
  73. services/tools/execute_menu_item.py +32 -0
  74. services/tools/find_gameobjects.py +110 -0
  75. services/tools/find_in_file.py +181 -0
  76. services/tools/manage_asset.py +119 -0
  77. services/tools/manage_components.py +131 -0
  78. services/tools/manage_editor.py +64 -0
  79. services/tools/manage_gameobject.py +260 -0
  80. services/tools/manage_material.py +111 -0
  81. services/tools/manage_prefabs.py +209 -0
  82. services/tools/manage_scene.py +111 -0
  83. services/tools/manage_script.py +645 -0
  84. services/tools/manage_scriptable_object.py +87 -0
  85. services/tools/manage_shader.py +71 -0
  86. services/tools/manage_texture.py +581 -0
  87. services/tools/manage_vfx.py +120 -0
  88. services/tools/preflight.py +110 -0
  89. services/tools/read_console.py +151 -0
  90. services/tools/refresh_unity.py +153 -0
  91. services/tools/run_tests.py +317 -0
  92. services/tools/script_apply_edits.py +1006 -0
  93. services/tools/set_active_instance.py +120 -0
  94. services/tools/utils.py +348 -0
  95. transport/__init__.py +0 -0
  96. transport/legacy/port_discovery.py +329 -0
  97. transport/legacy/stdio_port_registry.py +65 -0
  98. transport/legacy/unity_connection.py +910 -0
  99. transport/models.py +68 -0
  100. transport/plugin_hub.py +787 -0
  101. transport/plugin_registry.py +182 -0
  102. transport/unity_instance_middleware.py +262 -0
  103. transport/unity_transport.py +94 -0
  104. utils/focus_nudge.py +589 -0
  105. utils/module_discovery.py +55 -0
@@ -0,0 +1,328 @@
1
+ Metadata-Version: 2.4
2
+ Name: mcpforunityserver
3
+ Version: 9.4.0b20260203025228
4
+ Summary: MCP for Unity Server: A Unity package for Unity Editor integration via the Model Context Protocol (MCP).
5
+ Author-email: Marcus Sanatan <msanatan@gmail.com>, David Sarno <david.sarno@gmail.com>, Wu Shutong <martinwfire@gmail.com>
6
+ License-Expression: MIT
7
+ Project-URL: Repository, https://github.com/CoplayDev/unity-mcp.git
8
+ Project-URL: Issues, https://github.com/CoplayDev/unity-mcp/issues
9
+ Keywords: mcp,unity,ai,model context protocol,gamedev,unity3d,automation,llm,agent
10
+ Classifier: Development Status :: 5 - Production/Stable
11
+ Classifier: Environment :: Console
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Natural Language :: English
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Programming Language :: Python :: 3.14
20
+ Classifier: Programming Language :: Python :: Implementation :: CPython
21
+ Classifier: Topic :: Internet :: WWW/HTTP :: HTTP Servers
22
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
23
+ Classifier: Topic :: Games/Entertainment
24
+ Classifier: Topic :: Software Development :: Code Generators
25
+ Requires-Python: >=3.10
26
+ Description-Content-Type: text/markdown
27
+ License-File: LICENSE
28
+ Requires-Dist: httpx>=0.27.2
29
+ Requires-Dist: fastmcp==2.14.1
30
+ Requires-Dist: mcp>=1.16.0
31
+ Requires-Dist: pydantic>=2.12.5
32
+ Requires-Dist: tomli>=2.3.0
33
+ Requires-Dist: fastapi>=0.104.0
34
+ Requires-Dist: uvicorn>=0.35.0
35
+ Requires-Dist: click>=8.1.0
36
+ Provides-Extra: dev
37
+ Requires-Dist: pytest>=8.0.0; extra == "dev"
38
+ Requires-Dist: pytest-asyncio>=0.23; extra == "dev"
39
+ Requires-Dist: pytest-cov>=4.1.0; extra == "dev"
40
+ Dynamic: license-file
41
+
42
+ # MCP for Unity Server
43
+
44
+ [![MCP](https://badge.mcpx.dev?status=on 'MCP Enabled')](https://modelcontextprotocol.io/introduction)
45
+ [![python](https://img.shields.io/badge/Python-3.10+-3776AB.svg?style=flat&logo=python&logoColor=white)](https://www.python.org)
46
+ [![License](https://img.shields.io/badge/License-MIT-red.svg 'MIT License')](https://opensource.org/licenses/MIT)
47
+ [![Discord](https://img.shields.io/badge/discord-join-red.svg?logo=discord&logoColor=white)](https://discord.gg/y4p8KfzrN4)
48
+
49
+ Model Context Protocol server for Unity Editor integration. Control Unity through natural language using AI assistants like Claude, Cursor, and more.
50
+
51
+ **Maintained by [Coplay](https://www.coplay.dev/?ref=unity-mcp)** - This project is not affiliated with Unity Technologies.
52
+
53
+ 💬 **Join our community:** [Discord Server](https://discord.gg/y4p8KfzrN4)
54
+
55
+ **Required:** Install the [Unity MCP Plugin](https://github.com/CoplayDev/unity-mcp?tab=readme-ov-file#-step-1-install-the-unity-package) to connect Unity Editor with this MCP server. You also need `uvx` (requires [uv](https://docs.astral.sh/uv/)) to run the server.
56
+
57
+ ---
58
+
59
+ ## Installation
60
+
61
+ ### Option 1: PyPI
62
+
63
+ Install and run directly from PyPI using `uvx`.
64
+
65
+ **Run Server (HTTP):**
66
+
67
+ ```bash
68
+ uvx --from mcpforunityserver mcp-for-unity --transport http --http-url http://localhost:8080
69
+ ```
70
+
71
+ **MCP Client Configuration (HTTP):**
72
+
73
+ ```json
74
+ {
75
+ "mcpServers": {
76
+ "UnityMCP": {
77
+ "url": "http://localhost:8080/mcp"
78
+ }
79
+ }
80
+ }
81
+ ```
82
+
83
+ **MCP Client Configuration (stdio):**
84
+
85
+ ```json
86
+ {
87
+ "mcpServers": {
88
+ "UnityMCP": {
89
+ "command": "uvx",
90
+ "args": [
91
+ "--from",
92
+ "mcpforunityserver",
93
+ "mcp-for-unity",
94
+ "--transport",
95
+ "stdio"
96
+ ]
97
+ }
98
+ }
99
+ }
100
+ ```
101
+
102
+ ### Option 2: From GitHub Source
103
+
104
+ Use this to run the latest released version from the repository. Change the version to `main` to run the latest unreleased changes from the repository.
105
+
106
+ ```json
107
+ {
108
+ "mcpServers": {
109
+ "UnityMCP": {
110
+ "command": "uvx",
111
+ "args": [
112
+ "--from",
113
+ "git+https://github.com/CoplayDev/unity-mcp@v9.3.1#subdirectory=Server",
114
+ "mcp-for-unity",
115
+ "--transport",
116
+ "stdio"
117
+ ]
118
+ }
119
+ }
120
+ }
121
+ ```
122
+
123
+ ### Option 3: Docker
124
+
125
+ **Use Pre-built Image:**
126
+
127
+ ```bash
128
+ docker run -p 8080:8080 msanatan/mcp-for-unity-server:latest --transport http --http-url http://0.0.0.0:8080
129
+ ```
130
+
131
+ **Build Locally:**
132
+
133
+ ```bash
134
+ docker build -t unity-mcp-server .
135
+ docker run -p 8080:8080 unity-mcp-server --transport http --http-url http://0.0.0.0:8080
136
+ ```
137
+
138
+ Configure your MCP client with `"url": "http://localhost:8080/mcp"`.
139
+
140
+ ### Option 4: Local Development
141
+
142
+ For contributing or modifying the server code:
143
+
144
+ ```bash
145
+ # Clone the repository
146
+ git clone https://github.com/CoplayDev/unity-mcp.git
147
+ cd unity-mcp/Server
148
+
149
+ # Run with uv
150
+ uv run src/main.py --transport stdio
151
+ ```
152
+
153
+ ---
154
+
155
+ ## Configuration
156
+
157
+ The server connects to Unity Editor automatically when both are running. Most users do not need to change any settings.
158
+
159
+ ### CLI options
160
+
161
+ These options apply to the `mcp-for-unity` command (whether run via `uvx`, Docker, or `python src/main.py`).
162
+
163
+ - `--transport {stdio,http}` - Transport protocol (default: `stdio`)
164
+ - `--http-url URL` - Base URL used to derive host/port defaults (default: `http://localhost:8080`)
165
+ - `--http-host HOST` - Override HTTP bind host (overrides URL host)
166
+ - `--http-port PORT` - Override HTTP bind port (overrides URL port)
167
+ - `--http-remote-hosted` - Treat HTTP transport as remotely hosted
168
+ - Requires API key authentication (see below)
169
+ - Disables local/CLI-only HTTP routes (`/api/command`, `/api/instances`, `/api/custom-tools`)
170
+ - Forces explicit Unity instance selection for MCP tool/resource calls
171
+ - Isolates Unity sessions per user
172
+ - `--api-key-validation-url URL` - External endpoint to validate API keys (required when `--http-remote-hosted` is set)
173
+ - `--api-key-login-url URL` - URL where users can obtain/manage API keys (served by `/api/auth/login-url`)
174
+ - `--api-key-cache-ttl SECONDS` - Cache duration for validated keys (default: `300`)
175
+ - `--api-key-service-token-header HEADER` - Header name for server-to-auth-service authentication (e.g. `X-Service-Token`)
176
+ - `--api-key-service-token TOKEN` - Token value sent to the auth service for server authentication
177
+ - `--default-instance INSTANCE` - Default Unity instance to target (project name, hash, or `Name@hash`)
178
+ - `--project-scoped-tools` - Keep custom tools scoped to the active Unity project and enable the custom tools resource
179
+ - `--unity-instance-token TOKEN` - Optional per-launch token set by Unity for deterministic lifecycle management
180
+ - `--pidfile PATH` - Optional path where the server writes its PID on startup (used by Unity-managed terminal launches)
181
+
182
+ ### Environment variables
183
+
184
+ - `UNITY_MCP_TRANSPORT` - Transport protocol: `stdio` or `http`
185
+ - `UNITY_MCP_HTTP_URL` - HTTP server URL (default: `http://localhost:8080`)
186
+ - `UNITY_MCP_HTTP_HOST` - HTTP bind host (overrides URL host)
187
+ - `UNITY_MCP_HTTP_PORT` - HTTP bind port (overrides URL port)
188
+ - `UNITY_MCP_HTTP_REMOTE_HOSTED` - Enable remote-hosted mode (`true`, `1`, or `yes`)
189
+ - `UNITY_MCP_DEFAULT_INSTANCE` - Default Unity instance to target (project name, hash, or `Name@hash`)
190
+ - `UNITY_MCP_SKIP_STARTUP_CONNECT=1` - Skip initial Unity connection attempt on startup
191
+
192
+ API key authentication (remote-hosted mode):
193
+
194
+ - `UNITY_MCP_API_KEY_VALIDATION_URL` - External endpoint to validate API keys
195
+ - `UNITY_MCP_API_KEY_LOGIN_URL` - URL where users can obtain/manage API keys
196
+ - `UNITY_MCP_API_KEY_CACHE_TTL` - Cache TTL for validated keys in seconds (default: `300`)
197
+ - `UNITY_MCP_API_KEY_SERVICE_TOKEN_HEADER` - Header name for server-to-auth-service authentication
198
+ - `UNITY_MCP_API_KEY_SERVICE_TOKEN` - Token value sent to the auth service for server authentication
199
+
200
+ Telemetry:
201
+
202
+ - `DISABLE_TELEMETRY=1` - Disable anonymous telemetry (opt-out)
203
+ - `UNITY_MCP_DISABLE_TELEMETRY=1` - Same as `DISABLE_TELEMETRY`
204
+ - `MCP_DISABLE_TELEMETRY=1` - Same as `DISABLE_TELEMETRY`
205
+ - `UNITY_MCP_TELEMETRY_ENDPOINT` - Override telemetry endpoint URL
206
+ - `UNITY_MCP_TELEMETRY_TIMEOUT` - Override telemetry request timeout (seconds)
207
+
208
+ ### Examples
209
+
210
+ **Stdio (default):**
211
+
212
+ ```bash
213
+ uvx --from mcpforunityserver mcp-for-unity --transport stdio
214
+ ```
215
+
216
+ **HTTP (local):**
217
+
218
+ ```bash
219
+ uvx --from mcpforunityserver mcp-for-unity --transport http --http-host 127.0.0.1 --http-port 8080
220
+ ```
221
+
222
+ **HTTP (remote-hosted with API key auth):**
223
+
224
+ ```bash
225
+ uvx --from mcpforunityserver mcp-for-unity \
226
+ --transport http \
227
+ --http-host 0.0.0.0 \
228
+ --http-port 8080 \
229
+ --http-remote-hosted \
230
+ --api-key-validation-url https://auth.example.com/api/validate-key \
231
+ --api-key-login-url https://app.example.com/api-keys
232
+ ```
233
+
234
+ **Disable telemetry:**
235
+
236
+ ```bash
237
+ DISABLE_TELEMETRY=1 uvx --from mcpforunityserver mcp-for-unity --transport stdio
238
+ ```
239
+
240
+ ---
241
+
242
+ ## Remote-Hosted Mode
243
+
244
+ When deploying the server as a shared remote service (e.g. for a team or Asset Store users), enable `--http-remote-hosted` to activate API key authentication and per-user session isolation.
245
+
246
+ **Requirements:**
247
+
248
+ - An external HTTP endpoint that validates API keys. The server POSTs `{"api_key": "..."}` and expects `{"valid": true, "user_id": "..."}` or `{"valid": false}` in response.
249
+ - `--api-key-validation-url` must be provided (or `UNITY_MCP_API_KEY_VALIDATION_URL`). The server exits with code 1 if this is missing.
250
+
251
+ **What changes in remote-hosted mode:**
252
+
253
+ - All MCP tool/resource calls and Unity plugin WebSocket connections require a valid `X-API-Key` header.
254
+ - Each user only sees Unity instances that connected with their API key (session isolation).
255
+ - Auto-selection of a sole Unity instance is disabled; users must explicitly call `set_active_instance`.
256
+ - CLI REST routes (`/api/command`, `/api/instances`, `/api/custom-tools`) are disabled.
257
+ - `/health` and `/api/auth/login-url` remain accessible without authentication.
258
+
259
+ **MCP client config with API key:**
260
+
261
+ ```json
262
+ {
263
+ "mcpServers": {
264
+ "UnityMCP": {
265
+ "url": "http://remote-server:8080/mcp",
266
+ "headers": {
267
+ "X-API-Key": "<your-api-key>"
268
+ }
269
+ }
270
+ }
271
+ }
272
+ ```
273
+
274
+ For full details, see [Remote Server Auth Guide](../docs/guides/REMOTE_SERVER_AUTH.md) and [Architecture Reference](../docs/reference/REMOTE_SERVER_AUTH_ARCHITECTURE.md).
275
+
276
+ ---
277
+
278
+ ## MCP Resources
279
+
280
+ The server provides read-only MCP resources for querying Unity Editor state. Resources provide up-to-date information about your Unity project without modifying it.
281
+
282
+ **Accessing Resources:**
283
+
284
+ Resources are accessed by their URI (not their name). Always use `ListMcpResources` to get the correct URI format.
285
+
286
+ **Example URIs:**
287
+ - `mcpforunity://editor/state` - Editor readiness snapshot
288
+ - `mcpforunity://project/tags` - All project tags
289
+ - `mcpforunity://scene/gameobject/{instance_id}` - GameObject details by ID
290
+ - `mcpforunity://prefab/{encoded_path}` - Prefab info by asset path
291
+
292
+ **Important:** Resource names use underscores (e.g., `editor_state`) but URIs use slashes/hyphens (e.g., `mcpforunity://editor/state`). Always use the URI from `ListMcpResources()` when reading resources.
293
+
294
+ **All resource descriptions now include their URI** for easy reference. List available resources to see the complete catalog with URIs.
295
+
296
+ ---
297
+
298
+ ## Example Prompts
299
+
300
+ Once connected, try these commands in your AI assistant:
301
+
302
+ - "Create a 3D player controller with WASD movement"
303
+ - "Add a rotating cube to the scene with a red material"
304
+ - "Create a simple platformer level with obstacles"
305
+ - "Generate a shader that creates a holographic effect"
306
+ - "List all GameObjects in the current scene"
307
+
308
+ ---
309
+
310
+ ## Documentation
311
+
312
+ For complete documentation, troubleshooting, and advanced usage:
313
+
314
+ 📖 **[Full Documentation](https://github.com/CoplayDev/unity-mcp#readme)**
315
+
316
+ ---
317
+
318
+ ## Requirements
319
+
320
+ - **Python:** 3.10 or newer
321
+ - **Unity Editor:** 2021.3 LTS or newer
322
+ - **uv:** Python package manager ([Installation Guide](https://docs.astral.sh/uv/getting-started/installation/))
323
+
324
+ ---
325
+
326
+ ## License
327
+
328
+ MIT License - See [LICENSE](https://github.com/CoplayDev/unity-mcp/blob/main/LICENSE)
@@ -0,0 +1,105 @@
1
+ main.py,sha256=xNuZrgxhsjVOYl1C-NBzpW-eb8YW3_m_E2Npz9a5vao,35040
2
+ cli/__init__.py,sha256=f2HjXqR9d8Uhibru211t9HPpdrb_1vdDC2v_NwF_eqA,63
3
+ cli/main.py,sha256=V_VFa8tA-CDHNv9J5NzNSLxRuEGjRVZWDe4xn6rYdog,8457
4
+ cli/commands/__init__.py,sha256=xQHf6o0afDV2HsU9gwSxjcrzS41cMCSGZyWYWxblPIk,69
5
+ cli/commands/animation.py,sha256=a7ZqTkP7CRou9wL7MB8b3TSB7v0PFG_1LcjdxW5_zQ0,2388
6
+ cli/commands/asset.py,sha256=Cm18PFLGLisTLRhycTbxaGT8XU3WnJWcPOwsWiB5E2s,7164
7
+ cli/commands/audio.py,sha256=gTW4F6uutgQezAwDqL6_-i8vM588V-AVwxAaJ4LzGN8,3088
8
+ cli/commands/batch.py,sha256=eo2DD62FzRPDk0mQ5WhFVAXS0qXf8_znT_5kdN0BoG4,5388
9
+ cli/commands/code.py,sha256=N6MaBjH7QkYjjCP4wEhAoAQSwvboh2ub3rrI6qYv8AM,5226
10
+ cli/commands/component.py,sha256=OqjuNOyA2n5UOy-0-vMeiIRCQHOq_OnhVqW4ZzMgqrE,5736
11
+ cli/commands/editor.py,sha256=F_KOfQiE-uuwGHXZQ9o9BF5nURG1nKcWuiL-9hjAFHc,12704
12
+ cli/commands/gameobject.py,sha256=D4h8xuMHjOoc_mdyZToNSzYCGrJKjeOpwrMWCXR0OCU,12881
13
+ cli/commands/instance.py,sha256=5qYJtptOFGCzfhXEMIPoEYcJtpkKlfM76dq36i_ZK5s,2780
14
+ cli/commands/lighting.py,sha256=4OpbzPvR8pesTTUVYmKV554SwbTyCVBRwDwTGlnmh2w,3558
15
+ cli/commands/material.py,sha256=_9atAdD0Wo_mEpZ2FP9Opl54ZBi2ak96euydHD_xGa4,6999
16
+ cli/commands/prefab.py,sha256=ef8mFF5pcBDH8X3zWANuD4Hq23sT3gK1mAXsHSbP1iM,7480
17
+ cli/commands/scene.py,sha256=HRDOcOUMpS6RhqL3FNF4JphjseCZFhTuDrJ0l-MOSRc,5652
18
+ cli/commands/script.py,sha256=70i3I6IuKWq5f49QvHIpTzC9fafYmJrWfynJl4ZAAMU,5966
19
+ cli/commands/shader.py,sha256=w_n8g6GJcFmqqZMulPdJGbvWWOirbfzHr6_vUx_2nVE,5985
20
+ cli/commands/texture.py,sha256=lLiPNMfcWNNcfHbyeNA1ZN16tKv1ljHkzhmr7SM5e50,18595
21
+ cli/commands/tool.py,sha256=A-jC9qFAs-LkWY0rav-vrye0yytgfKxQ7y2FraIAzZ4,1605
22
+ cli/commands/ui.py,sha256=u9rpeF_eT7qxdlYmaA2G4ARSe3a16Y4yt-3if7CKmxY,7225
23
+ cli/commands/vfx.py,sha256=gdx5a_N7Ulu960xjaJIV0E_1Ii422C211KaipoRO6nQ,14453
24
+ cli/utils/__init__.py,sha256=Gbm9hYC7UqwloFwdirXgo6z1iBktR9Y96o3bQcrYudc,613
25
+ cli/utils/config.py,sha256=_k3XAFmXG22sv8tYIb5JmO46kNl3T1sGqFptySAayfc,1550
26
+ cli/utils/confirmation.py,sha256=7NGu0I5ogowpdWRTUndn3g5nmWmJM9mV3e0wWMLJwA8,1234
27
+ cli/utils/connection.py,sha256=fx2o3J9AI6HdSC6rRDKh6KO8sPmBWkzR-ElY1dDkhes,8123
28
+ cli/utils/constants.py,sha256=xCyRMY1L3cc-sbCyl-TGyqkY5hMCOl5tU6L4ZVbN9w4,1046
29
+ cli/utils/output.py,sha256=96daU55ta_hl7UeOhNh5Iy7OJ4psbdR9Nfx1-q2k3xA,6370
30
+ cli/utils/parsers.py,sha256=mnpH2bhZn3L3Lyl8e7Sh7Zr2UW9Xzu3aUuCaLxpV2pk,3430
31
+ cli/utils/suggestions.py,sha256=n6KG3Mrvub28X9rPFYFLRTtZ6HePp3PhhAeojG2WOJw,929
32
+ core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
33
+ core/config.py,sha256=VlCLUFPm73DfInCVZkJFq4_7KZKVqSFbDS-n0HMA8WA,2118
34
+ core/constants.py,sha256=PhZs926Nie7Muigju1xkVBynVaUktZlP9lJMHgu4_to,114
35
+ core/logging_decorator.py,sha256=D9CD7rFvQz-MBG-G4inizQj0Ivr6dfc9RBmTrw7q8mI,1383
36
+ core/telemetry.py,sha256=zIjmQKUNW0S822SSlkXyjjCIuX0ZpSTaZP4pAU0rCjw,20426
37
+ core/telemetry_decorator.py,sha256=ycSTrzVNCDQHSd-xmIWOpVfKFURPxpiZe_XkOQAGDAo,6705
38
+ mcpforunityserver-9.4.0b20260203025228.dist-info/licenses/LICENSE,sha256=bv5lDJZQEqxBgjjc1rkRbkEwpSIHF-8N-1Od0VnEJFw,1066
39
+ models/__init__.py,sha256=J2ozraI5aDkqLb53KvXjTDaWgh_xVFxpWrcRMekOwPk,231
40
+ models/models.py,sha256=heXuvdBtdats1SGwW8wKFFHM0qR4hA6A7qETn5s9BZ0,1827
41
+ models/unity_response.py,sha256=xvgJhJ3pS8-ATQhnU5owijgO4141UW59f5dQm1ohVew,2278
42
+ services/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
43
+ services/api_key_service.py,sha256=Wq8BJDHXurN0hSiotqI37ta7G-Q9QAxHCD5hHbokxYs,8755
44
+ services/custom_tool_service.py,sha256=WJxljL-hdJE5GMlAhVimHVhQwwnWHCd0StgWhWEFgaI,18592
45
+ services/registry/__init__.py,sha256=QCwcYThvGF0kBt3WR6DBskdyxkegJC7NymEChgJA-YM,470
46
+ services/registry/resource_registry.py,sha256=T_Kznqgvt5kKgV7mU85nb0LlFuB4rg-Tm4Cjhxt-IcI,1467
47
+ services/registry/tool_registry.py,sha256=9tMwOP07JE92QFYUS4KvoysO0qC9pkBD5B79kjRsSPw,1304
48
+ services/resources/__init__.py,sha256=G8uSEYJtiyX3yg0QsfoeGdDXOdbU89l5m0B5Anay1Fc,3054
49
+ services/resources/active_tool.py,sha256=O2tKtId1-UCZXFAVigIN4WzuiihmyZe24sCGn1k16HA,1558
50
+ services/resources/custom_tools.py,sha256=uujlJEuqv5svCvSZLILgiY6hiiWZqWHVzTBJpTTL3as,1751
51
+ services/resources/editor_state.py,sha256=OEPdb7VFFzk6LGN1r5FouBFv4sQdfKs-8sMKZxXCHwA,11004
52
+ services/resources/gameobject.py,sha256=cviektt_GHmwgria5pkvNrzvD5-6hzBi64Ogm0YGIv8,9356
53
+ services/resources/layers.py,sha256=6CjGfHH2XqLX6FYAoBLgePZH3srVO-9psZV8TJ93Okw,1160
54
+ services/resources/menu_items.py,sha256=tNyHlqC9mFkllN3JW9fyouecTvnV4YbnlSAysbAjVbQ,1091
55
+ services/resources/prefab.py,sha256=4TLEBsrlnQdi5FOKWZZ9eesiUCG5Ryxh7FZvd02FcTc,7434
56
+ services/resources/prefab_stage.py,sha256=APVPbzxSO4vUR0YgYDi4WI_woywqoc0KcTyUwgbGmJQ,1467
57
+ services/resources/project_info.py,sha256=xGSFTxOs4y7ok7iO3XVdGhxxyjAXpg1czbapybqp-NI,1401
58
+ services/resources/selection.py,sha256=E2thI4vWqk2SE3gm6mcDvYWSG0UuRpC1tja2Y6J2BRc,1921
59
+ services/resources/tags.py,sha256=fROK2Bj9VBiyQSQt0jdXxYatX-3d4vtAH8i6Zhgj5Vw,1127
60
+ services/resources/tests.py,sha256=6aqhZWxO6YPMGBzaw_dxMUm1wCJMFRNLeu6Nf_wXieo,3474
61
+ services/resources/unity_instances.py,sha256=Ix6YtTWKnTLXZ4v4mrn_d0IhLr7gcjfe9d605zf2V5w,4564
62
+ services/resources/windows.py,sha256=UT8-CDstsBXyggzJ8A9pVFIqNr8jr9oP77rOEBsWQCk,1507
63
+ services/state/external_changes_scanner.py,sha256=ZiXu8ZcK5B-hv7CaJLmnEIa9JxzgOBpdmrsRDY2eK5I,9052
64
+ services/tools/__init__.py,sha256=J-woLzm3aLF0uPC1-VroqG7QV9xLXHDmVYee2ZXuCgk,2746
65
+ services/tools/batch_execute.py,sha256=hjh67kgWvQDHyGd2N-Tfezv9WAj5x_pWTt_Vybmmq7s,3501
66
+ services/tools/debug_request_context.py,sha256=Duq5xiuSmRO5GdvWAlZhCfOfmrwvK7gGkRC4wYnXmXk,2907
67
+ services/tools/execute_custom_tool.py,sha256=hiZbm2A9t84f92jitzvkE2G4CMOIUiDVm7u5B8K-RbU,1527
68
+ services/tools/execute_menu_item.py,sha256=k4J89LlXmEGyo9z3NK8Q0vREIzr11ucF_9tN_JeQq9M,1248
69
+ services/tools/find_gameobjects.py,sha256=Qyls8HxBgXjA5OtdJfXuIX0qNGMleQSt3NOvQwjP25E,3963
70
+ services/tools/find_in_file.py,sha256=SxhMeo8lRrt0OiGApGZSFUnq671bxVfK8qgAsHxLua8,6493
71
+ services/tools/manage_asset.py,sha256=St_iWQWg9icztnRthU78t6JNhJN0AlC6ELiZhn-SNZU,5990
72
+ services/tools/manage_components.py,sha256=2_nKPk9iPAf5VyYiXuRxSkN8U76VNQbMtE68UTPngrw,5061
73
+ services/tools/manage_editor.py,sha256=ShvlSBQRfoNQ0DvqBWak_Hi3MB7tv2WkMKEhrKQipk0,3279
74
+ services/tools/manage_gameobject.py,sha256=SP-y3_7Ckw12JO6bLJy01Jrx303JXF-7RMROaQuA1kU,14154
75
+ services/tools/manage_material.py,sha256=LSn9Kp-cSMZ5caU6Ux0M_OSMghCtZgOKkmvwf0xLTFE,4311
76
+ services/tools/manage_prefabs.py,sha256=7K-6kTavqu2-oxbA49Ug-vTh1Jt39ua02lWcijwM1DI,10163
77
+ services/tools/manage_scene.py,sha256=-ARtRuj7ZNk_14lmMSORnQs0qTAYKBTPtUfk0sNDo6A,5370
78
+ services/tools/manage_script.py,sha256=tT8JmhTtAYgW8CQla71cfn6IjiUw-tiPjBWVd4ipuCE,28551
79
+ services/tools/manage_scriptable_object.py,sha256=tezG_mbGzPLNpL3F7l5JJLyyjJN3rJi1thGMU8cpOC4,3659
80
+ services/tools/manage_shader.py,sha256=bucRKzQww7opy6DK5nf6isVaEECWWqJ-DVkFulp8CV8,3185
81
+ services/tools/manage_texture.py,sha256=uUicuxKl_uSnP2jBrMbYAhAEWnh7RETusgJfnBI1P8c,22538
82
+ services/tools/manage_vfx.py,sha256=7KFbRohF8EzaD0m7vVIEwjUz-QwC7NEXS5cVcU6Die0,4710
83
+ services/tools/preflight.py,sha256=0nvo0BmZMdIGop1Ha_vypkjn2VLiRvskF0uxh_SlZgE,4162
84
+ services/tools/read_console.py,sha256=ps23debJcQkj3Ap-MqTYVhopYnKGspJs9QHLJHZAAkE,6826
85
+ services/tools/refresh_unity.py,sha256=KrRA8bmLkDLFO1XBv2NmagQAp1dmyaXdUAap567Hcv4,7100
86
+ services/tools/run_tests.py,sha256=Wd7hNZqy-OOZ9ZedonxUJ5bVlhta_aOEmD-2uxmrmyM,11743
87
+ services/tools/script_apply_edits.py,sha256=0f-SaP5NUYGuivl4CWHjR8F-CXUpt3-5qkHpf_edn1U,47677
88
+ services/tools/set_active_instance.py,sha256=j_d0GhFwhBh-HwoNKzrice1haNyWPdK-RtVrNasYH7c,4408
89
+ services/tools/utils.py,sha256=ETCiNnWdMZEtnJcDD-CtPsCJ7TBp5x5sPsYuhufkxac,13962
90
+ transport/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
91
+ transport/models.py,sha256=1XFpxHGM9mzxcKU3LBGsejqReT8DiCEd2Ls3kEa_0t4,1426
92
+ transport/plugin_hub.py,sha256=wgTO1oJz-dM6KhZk_TbUIVdn7Vnmc3yU8PXwz_f7N9I,33647
93
+ transport/plugin_registry.py,sha256=Zn2QaDbpDj9Ad-oXs3q7CXxnZz3mc5SJ61GzIToEBPI,7160
94
+ transport/unity_instance_middleware.py,sha256=r_Q8GtMnHXLEWWACmG2R1wqZT6zoQ6jHFkAWGZxMHCg,11941
95
+ transport/unity_transport.py,sha256=Xj3phVcd4bhLMj2--Hq-sFpSvFzKhuMxH10IhzSfD14,3305
96
+ transport/legacy/port_discovery.py,sha256=JDSCqXLodfTT7fOsE0DFC1jJ3QsU6hVaYQb7x7FgdxY,12728
97
+ transport/legacy/stdio_port_registry.py,sha256=j4iARuP6wetppNDG8qKeuvo1bJKcSlgEhZvSyl_uf0A,2313
98
+ transport/legacy/unity_connection.py,sha256=jxPxrI0tQ9e82m9I3mzsIcY40kn-g9tGVt6P3YVz-v8,38309
99
+ utils/focus_nudge.py,sha256=0MCOms-SxUW7sN2hT3syy1epMdli2zc-6UHBICAfBSM,21330
100
+ utils/module_discovery.py,sha256=My48ofB1BUqxiBoAZAGbEaLQYdsrDhMm8MayBP_bUSQ,2005
101
+ mcpforunityserver-9.4.0b20260203025228.dist-info/METADATA,sha256=TRh6rEMIFKNA168UjDehgOYUF_7aRyOPZb2rQ7Wn2_U,11877
102
+ mcpforunityserver-9.4.0b20260203025228.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
103
+ mcpforunityserver-9.4.0b20260203025228.dist-info/entry_points.txt,sha256=pPm70RXQvkt3uBhPOtViDa47ZTA03RaQ6rwXvyi8oiI,70
104
+ mcpforunityserver-9.4.0b20260203025228.dist-info/top_level.txt,sha256=3-A65WsmBO6UZYH8O5mINdyhhZ63SDssr8LncRd1PSQ,46
105
+ mcpforunityserver-9.4.0b20260203025228.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (80.10.2)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,3 @@
1
+ [console_scripts]
2
+ mcp-for-unity = main:main
3
+ unity-mcp = cli.main:main
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 CoplayDev
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,7 @@
1
+ cli
2
+ core
3
+ main
4
+ models
5
+ services
6
+ transport
7
+ utils
models/__init__.py ADDED
@@ -0,0 +1,4 @@
1
+ from .models import MCPResponse, UnityInstanceInfo
2
+ from .unity_response import normalize_unity_response, parse_resource_response
3
+
4
+ __all__ = ['MCPResponse', 'UnityInstanceInfo', 'normalize_unity_response', 'parse_resource_response']
models/models.py ADDED
@@ -0,0 +1,56 @@
1
+ from typing import Any
2
+ from datetime import datetime
3
+ from pydantic import BaseModel, Field
4
+
5
+
6
+ class MCPResponse(BaseModel):
7
+ success: bool
8
+ message: str | None = None
9
+ error: str | None = None
10
+ data: Any | None = None
11
+ # Optional hint for clients about how to handle the response.
12
+ # Supported values:
13
+ # - "retry": Unity is temporarily reloading; call should be retried politely.
14
+ hint: str | None = None
15
+
16
+
17
+ class ToolParameterModel(BaseModel):
18
+ name: str
19
+ description: str | None = None
20
+ type: str = Field(default="string")
21
+ required: bool = Field(default=True)
22
+ default_value: str | None = None
23
+
24
+
25
+ class ToolDefinitionModel(BaseModel):
26
+ name: str
27
+ description: str | None = None
28
+ structured_output: bool | None = True
29
+ requires_polling: bool | None = False
30
+ poll_action: str | None = "status"
31
+ parameters: list[ToolParameterModel] = Field(default_factory=list)
32
+
33
+
34
+ class UnityInstanceInfo(BaseModel):
35
+ """Information about a Unity Editor instance"""
36
+ id: str # "ProjectName@hash" or fallback to hash
37
+ name: str # Project name extracted from path
38
+ path: str # Full project path (Assets folder)
39
+ hash: str # 8-char hash of project path
40
+ port: int # TCP port
41
+ status: str # "running", "reloading", "offline"
42
+ last_heartbeat: datetime | None = None
43
+ unity_version: str | None = None
44
+
45
+ def to_dict(self) -> dict[str, Any]:
46
+ """Convert to dictionary for JSON serialization"""
47
+ return {
48
+ "id": self.id,
49
+ "name": self.name,
50
+ "path": self.path,
51
+ "hash": self.hash,
52
+ "port": self.port,
53
+ "status": self.status,
54
+ "last_heartbeat": self.last_heartbeat.isoformat() if self.last_heartbeat else None,
55
+ "unity_version": self.unity_version
56
+ }
@@ -0,0 +1,70 @@
1
+ """Utilities for normalizing Unity transport responses."""
2
+ from __future__ import annotations
3
+
4
+ from typing import Any, Type
5
+
6
+ from models.models import MCPResponse
7
+
8
+
9
+ def normalize_unity_response(response: Any) -> Any:
10
+ """Normalize Unity's {status,result} payloads into MCPResponse shape."""
11
+ if not isinstance(response, dict):
12
+ return response
13
+
14
+ status = response.get("status")
15
+ result = response.get("result") if isinstance(
16
+ response.get("result"), dict) else response.get("result")
17
+
18
+ # Already MCPResponse-shaped
19
+ if "success" in response:
20
+ return response
21
+ if isinstance(result, dict) and "success" in result:
22
+ return result
23
+
24
+ if status is None:
25
+ return response
26
+
27
+ payload = result if isinstance(result, dict) else {}
28
+ success = status == "success"
29
+ message = payload.get("message") or response.get("message")
30
+ error = payload.get("error") or response.get("error")
31
+
32
+ data = payload.get("data")
33
+ if data is None and isinstance(payload, dict) and payload:
34
+ data = {k: v for k, v in payload.items() if k not in {
35
+ "message", "error", "status", "code"}}
36
+ if not data:
37
+ data = None
38
+
39
+ normalized: dict[str, Any] = {
40
+ "success": success,
41
+ "message": message,
42
+ "error": error if not success else None,
43
+ "data": data,
44
+ }
45
+
46
+ if not success and not normalized["error"]:
47
+ normalized["error"] = message or "Unity command failed"
48
+
49
+ return normalized
50
+
51
+
52
+ def parse_resource_response(response: Any, typed_cls: Type[MCPResponse]) -> MCPResponse:
53
+ """Parse a Unity response into a typed response class.
54
+
55
+ Returns a base ``MCPResponse`` for error responses so that typed subclasses
56
+ with strict ``data`` fields (e.g. ``list[str]``) don't raise Pydantic
57
+ validation errors when ``data`` is ``None``.
58
+ """
59
+ if not isinstance(response, dict):
60
+ return response
61
+
62
+ # Detect errors from both normalized (success=False) and raw (status="error") shapes.
63
+ if response.get("success") is False or response.get("status") == "error":
64
+ return MCPResponse(
65
+ success=False,
66
+ error=response.get("error"),
67
+ message=response.get("message"),
68
+ )
69
+
70
+ return typed_cls(**response)
services/__init__.py ADDED
File without changes