mcpforunityserver 8.6.0__tar.gz
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.
- mcpforunityserver-8.6.0/LICENSE +21 -0
- mcpforunityserver-8.6.0/PKG-INFO +194 -0
- mcpforunityserver-8.6.0/README.md +155 -0
- mcpforunityserver-8.6.0/pyproject.toml +56 -0
- mcpforunityserver-8.6.0/setup.cfg +4 -0
- mcpforunityserver-8.6.0/src/__init__.py +0 -0
- mcpforunityserver-8.6.0/src/core/__init__.py +0 -0
- mcpforunityserver-8.6.0/src/core/config.py +56 -0
- mcpforunityserver-8.6.0/src/core/logging_decorator.py +37 -0
- mcpforunityserver-8.6.0/src/core/telemetry.py +533 -0
- mcpforunityserver-8.6.0/src/core/telemetry_decorator.py +164 -0
- mcpforunityserver-8.6.0/src/main.py +479 -0
- mcpforunityserver-8.6.0/src/mcpforunityserver.egg-info/PKG-INFO +194 -0
- mcpforunityserver-8.6.0/src/mcpforunityserver.egg-info/SOURCES.txt +69 -0
- mcpforunityserver-8.6.0/src/mcpforunityserver.egg-info/dependency_links.txt +1 -0
- mcpforunityserver-8.6.0/src/mcpforunityserver.egg-info/entry_points.txt +2 -0
- mcpforunityserver-8.6.0/src/mcpforunityserver.egg-info/requires.txt +11 -0
- mcpforunityserver-8.6.0/src/mcpforunityserver.egg-info/top_level.txt +8 -0
- mcpforunityserver-8.6.0/src/models/__init__.py +4 -0
- mcpforunityserver-8.6.0/src/models/models.py +56 -0
- mcpforunityserver-8.6.0/src/models/unity_response.py +47 -0
- mcpforunityserver-8.6.0/src/routes/__init__.py +0 -0
- mcpforunityserver-8.6.0/src/services/__init__.py +0 -0
- mcpforunityserver-8.6.0/src/services/custom_tool_service.py +339 -0
- mcpforunityserver-8.6.0/src/services/registry/__init__.py +22 -0
- mcpforunityserver-8.6.0/src/services/registry/resource_registry.py +53 -0
- mcpforunityserver-8.6.0/src/services/registry/tool_registry.py +51 -0
- mcpforunityserver-8.6.0/src/services/resources/__init__.py +81 -0
- mcpforunityserver-8.6.0/src/services/resources/active_tool.py +47 -0
- mcpforunityserver-8.6.0/src/services/resources/custom_tools.py +57 -0
- mcpforunityserver-8.6.0/src/services/resources/editor_state.py +51 -0
- mcpforunityserver-8.6.0/src/services/resources/layers.py +29 -0
- mcpforunityserver-8.6.0/src/services/resources/menu_items.py +34 -0
- mcpforunityserver-8.6.0/src/services/resources/prefab_stage.py +39 -0
- mcpforunityserver-8.6.0/src/services/resources/project_info.py +39 -0
- mcpforunityserver-8.6.0/src/services/resources/selection.py +55 -0
- mcpforunityserver-8.6.0/src/services/resources/tags.py +30 -0
- mcpforunityserver-8.6.0/src/services/resources/tests.py +55 -0
- mcpforunityserver-8.6.0/src/services/resources/unity_instances.py +122 -0
- mcpforunityserver-8.6.0/src/services/resources/windows.py +47 -0
- mcpforunityserver-8.6.0/src/services/tools/__init__.py +76 -0
- mcpforunityserver-8.6.0/src/services/tools/batch_execute.py +78 -0
- mcpforunityserver-8.6.0/src/services/tools/debug_request_context.py +80 -0
- mcpforunityserver-8.6.0/src/services/tools/execute_custom_tool.py +38 -0
- mcpforunityserver-8.6.0/src/services/tools/execute_menu_item.py +29 -0
- mcpforunityserver-8.6.0/src/services/tools/find_in_file.py +174 -0
- mcpforunityserver-8.6.0/src/services/tools/manage_asset.py +143 -0
- mcpforunityserver-8.6.0/src/services/tools/manage_editor.py +63 -0
- mcpforunityserver-8.6.0/src/services/tools/manage_gameobject.py +254 -0
- mcpforunityserver-8.6.0/src/services/tools/manage_material.py +95 -0
- mcpforunityserver-8.6.0/src/services/tools/manage_prefabs.py +62 -0
- mcpforunityserver-8.6.0/src/services/tools/manage_scene.py +90 -0
- mcpforunityserver-8.6.0/src/services/tools/manage_script.py +602 -0
- mcpforunityserver-8.6.0/src/services/tools/manage_scriptable_object.py +75 -0
- mcpforunityserver-8.6.0/src/services/tools/manage_shader.py +64 -0
- mcpforunityserver-8.6.0/src/services/tools/read_console.py +98 -0
- mcpforunityserver-8.6.0/src/services/tools/run_tests.py +101 -0
- mcpforunityserver-8.6.0/src/services/tools/script_apply_edits.py +998 -0
- mcpforunityserver-8.6.0/src/services/tools/set_active_instance.py +112 -0
- mcpforunityserver-8.6.0/src/services/tools/utils.py +77 -0
- mcpforunityserver-8.6.0/src/transport/__init__.py +0 -0
- mcpforunityserver-8.6.0/src/transport/legacy/port_discovery.py +329 -0
- mcpforunityserver-8.6.0/src/transport/legacy/stdio_port_registry.py +65 -0
- mcpforunityserver-8.6.0/src/transport/legacy/unity_connection.py +785 -0
- mcpforunityserver-8.6.0/src/transport/models.py +62 -0
- mcpforunityserver-8.6.0/src/transport/plugin_hub.py +523 -0
- mcpforunityserver-8.6.0/src/transport/plugin_registry.py +123 -0
- mcpforunityserver-8.6.0/src/transport/unity_instance_middleware.py +231 -0
- mcpforunityserver-8.6.0/src/transport/unity_transport.py +113 -0
- mcpforunityserver-8.6.0/src/utils/module_discovery.py +55 -0
- mcpforunityserver-8.6.0/src/utils/reload_sentinel.py +9 -0
|
@@ -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,194 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: mcpforunityserver
|
|
3
|
+
Version: 8.6.0
|
|
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
|
+
Provides-Extra: dev
|
|
36
|
+
Requires-Dist: pytest>=8.0.0; extra == "dev"
|
|
37
|
+
Requires-Dist: pytest-asyncio>=0.23; extra == "dev"
|
|
38
|
+
Dynamic: license-file
|
|
39
|
+
|
|
40
|
+
# MCP for Unity Server
|
|
41
|
+
|
|
42
|
+
[](https://modelcontextprotocol.io/introduction)
|
|
43
|
+
[](https://www.python.org)
|
|
44
|
+
[](https://opensource.org/licenses/MIT)
|
|
45
|
+
[](https://discord.gg/y4p8KfzrN4)
|
|
46
|
+
|
|
47
|
+
Model Context Protocol server for Unity Editor integration. Control Unity through natural language using AI assistants like Claude, Cursor, and more.
|
|
48
|
+
|
|
49
|
+
**Maintained by [Coplay](https://www.coplay.dev/?ref=unity-mcp)** - This project is not affiliated with Unity Technologies.
|
|
50
|
+
|
|
51
|
+
💬 **Join our community:** [Discord Server](https://discord.gg/y4p8KfzrN4)
|
|
52
|
+
|
|
53
|
+
**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.
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## Installation
|
|
58
|
+
|
|
59
|
+
### Option 1: PyPI
|
|
60
|
+
|
|
61
|
+
Install and run directly from PyPI using `uvx`.
|
|
62
|
+
|
|
63
|
+
**Run Server (HTTP):**
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
uvx --from mcpforunityserver mcp-for-unity --transport http --http-url http://localhost:8080
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
**MCP Client Configuration (HTTP):**
|
|
70
|
+
|
|
71
|
+
```json
|
|
72
|
+
{
|
|
73
|
+
"mcpServers": {
|
|
74
|
+
"UnityMCP": {
|
|
75
|
+
"url": "http://localhost:8080/mcp"
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
**MCP Client Configuration (stdio):**
|
|
82
|
+
|
|
83
|
+
```json
|
|
84
|
+
{
|
|
85
|
+
"mcpServers": {
|
|
86
|
+
"UnityMCP": {
|
|
87
|
+
"command": "uvx",
|
|
88
|
+
"args": [
|
|
89
|
+
"--from",
|
|
90
|
+
"mcpforunityserver",
|
|
91
|
+
"mcp-for-unity",
|
|
92
|
+
"--transport",
|
|
93
|
+
"stdio"
|
|
94
|
+
]
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### Option 2: From GitHub Source
|
|
101
|
+
|
|
102
|
+
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.
|
|
103
|
+
|
|
104
|
+
```json
|
|
105
|
+
{
|
|
106
|
+
"mcpServers": {
|
|
107
|
+
"UnityMCP": {
|
|
108
|
+
"command": "uvx",
|
|
109
|
+
"args": [
|
|
110
|
+
"--from",
|
|
111
|
+
"git+https://github.com/CoplayDev/unity-mcp@v8.6.0#subdirectory=Server",
|
|
112
|
+
"mcp-for-unity",
|
|
113
|
+
"--transport",
|
|
114
|
+
"stdio"
|
|
115
|
+
]
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Option 3: Docker
|
|
122
|
+
|
|
123
|
+
**Use Pre-built Image:**
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
docker run -p 8080:8080 msanatan/mcp-for-unity-server:latest --transport http --http-url http://0.0.0.0:8080
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
**Build Locally:**
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
docker build -t unity-mcp-server .
|
|
133
|
+
docker run -p 8080:8080 unity-mcp-server --transport http --http-url http://0.0.0.0:8080
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
Configure your MCP client with `"url": "http://localhost:8080/mcp"`.
|
|
137
|
+
|
|
138
|
+
### Option 4: Local Development
|
|
139
|
+
|
|
140
|
+
For contributing or modifying the server code:
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
# Clone the repository
|
|
144
|
+
git clone https://github.com/CoplayDev/unity-mcp.git
|
|
145
|
+
cd unity-mcp/Server
|
|
146
|
+
|
|
147
|
+
# Run with uv
|
|
148
|
+
uv run src/main.py --transport stdio
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
---
|
|
152
|
+
|
|
153
|
+
## Configuration
|
|
154
|
+
|
|
155
|
+
The server connects to Unity Editor automatically when both are running. No additional configuration needed.
|
|
156
|
+
|
|
157
|
+
**Environment Variables:**
|
|
158
|
+
|
|
159
|
+
- `DISABLE_TELEMETRY=true` - Opt out of anonymous usage analytics
|
|
160
|
+
- `LOG_LEVEL=DEBUG` - Enable detailed logging (default: INFO)
|
|
161
|
+
|
|
162
|
+
---
|
|
163
|
+
|
|
164
|
+
## Example Prompts
|
|
165
|
+
|
|
166
|
+
Once connected, try these commands in your AI assistant:
|
|
167
|
+
|
|
168
|
+
- "Create a 3D player controller with WASD movement"
|
|
169
|
+
- "Add a rotating cube to the scene with a red material"
|
|
170
|
+
- "Create a simple platformer level with obstacles"
|
|
171
|
+
- "Generate a shader that creates a holographic effect"
|
|
172
|
+
- "List all GameObjects in the current scene"
|
|
173
|
+
|
|
174
|
+
---
|
|
175
|
+
|
|
176
|
+
## Documentation
|
|
177
|
+
|
|
178
|
+
For complete documentation, troubleshooting, and advanced usage:
|
|
179
|
+
|
|
180
|
+
📖 **[Full Documentation](https://github.com/CoplayDev/unity-mcp#readme)**
|
|
181
|
+
|
|
182
|
+
---
|
|
183
|
+
|
|
184
|
+
## Requirements
|
|
185
|
+
|
|
186
|
+
- **Python:** 3.10 or newer
|
|
187
|
+
- **Unity Editor:** 2021.3 LTS or newer
|
|
188
|
+
- **uv:** Python package manager ([Installation Guide](https://docs.astral.sh/uv/getting-started/installation/))
|
|
189
|
+
|
|
190
|
+
---
|
|
191
|
+
|
|
192
|
+
## License
|
|
193
|
+
|
|
194
|
+
MIT License - See [LICENSE](https://github.com/CoplayDev/unity-mcp/blob/main/LICENSE)
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
# MCP for Unity Server
|
|
2
|
+
|
|
3
|
+
[](https://modelcontextprotocol.io/introduction)
|
|
4
|
+
[](https://www.python.org)
|
|
5
|
+
[](https://opensource.org/licenses/MIT)
|
|
6
|
+
[](https://discord.gg/y4p8KfzrN4)
|
|
7
|
+
|
|
8
|
+
Model Context Protocol server for Unity Editor integration. Control Unity through natural language using AI assistants like Claude, Cursor, and more.
|
|
9
|
+
|
|
10
|
+
**Maintained by [Coplay](https://www.coplay.dev/?ref=unity-mcp)** - This project is not affiliated with Unity Technologies.
|
|
11
|
+
|
|
12
|
+
💬 **Join our community:** [Discord Server](https://discord.gg/y4p8KfzrN4)
|
|
13
|
+
|
|
14
|
+
**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.
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
### Option 1: PyPI
|
|
21
|
+
|
|
22
|
+
Install and run directly from PyPI using `uvx`.
|
|
23
|
+
|
|
24
|
+
**Run Server (HTTP):**
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
uvx --from mcpforunityserver mcp-for-unity --transport http --http-url http://localhost:8080
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
**MCP Client Configuration (HTTP):**
|
|
31
|
+
|
|
32
|
+
```json
|
|
33
|
+
{
|
|
34
|
+
"mcpServers": {
|
|
35
|
+
"UnityMCP": {
|
|
36
|
+
"url": "http://localhost:8080/mcp"
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
**MCP Client Configuration (stdio):**
|
|
43
|
+
|
|
44
|
+
```json
|
|
45
|
+
{
|
|
46
|
+
"mcpServers": {
|
|
47
|
+
"UnityMCP": {
|
|
48
|
+
"command": "uvx",
|
|
49
|
+
"args": [
|
|
50
|
+
"--from",
|
|
51
|
+
"mcpforunityserver",
|
|
52
|
+
"mcp-for-unity",
|
|
53
|
+
"--transport",
|
|
54
|
+
"stdio"
|
|
55
|
+
]
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Option 2: From GitHub Source
|
|
62
|
+
|
|
63
|
+
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.
|
|
64
|
+
|
|
65
|
+
```json
|
|
66
|
+
{
|
|
67
|
+
"mcpServers": {
|
|
68
|
+
"UnityMCP": {
|
|
69
|
+
"command": "uvx",
|
|
70
|
+
"args": [
|
|
71
|
+
"--from",
|
|
72
|
+
"git+https://github.com/CoplayDev/unity-mcp@v8.6.0#subdirectory=Server",
|
|
73
|
+
"mcp-for-unity",
|
|
74
|
+
"--transport",
|
|
75
|
+
"stdio"
|
|
76
|
+
]
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Option 3: Docker
|
|
83
|
+
|
|
84
|
+
**Use Pre-built Image:**
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
docker run -p 8080:8080 msanatan/mcp-for-unity-server:latest --transport http --http-url http://0.0.0.0:8080
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
**Build Locally:**
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
docker build -t unity-mcp-server .
|
|
94
|
+
docker run -p 8080:8080 unity-mcp-server --transport http --http-url http://0.0.0.0:8080
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Configure your MCP client with `"url": "http://localhost:8080/mcp"`.
|
|
98
|
+
|
|
99
|
+
### Option 4: Local Development
|
|
100
|
+
|
|
101
|
+
For contributing or modifying the server code:
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
# Clone the repository
|
|
105
|
+
git clone https://github.com/CoplayDev/unity-mcp.git
|
|
106
|
+
cd unity-mcp/Server
|
|
107
|
+
|
|
108
|
+
# Run with uv
|
|
109
|
+
uv run src/main.py --transport stdio
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
## Configuration
|
|
115
|
+
|
|
116
|
+
The server connects to Unity Editor automatically when both are running. No additional configuration needed.
|
|
117
|
+
|
|
118
|
+
**Environment Variables:**
|
|
119
|
+
|
|
120
|
+
- `DISABLE_TELEMETRY=true` - Opt out of anonymous usage analytics
|
|
121
|
+
- `LOG_LEVEL=DEBUG` - Enable detailed logging (default: INFO)
|
|
122
|
+
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
## Example Prompts
|
|
126
|
+
|
|
127
|
+
Once connected, try these commands in your AI assistant:
|
|
128
|
+
|
|
129
|
+
- "Create a 3D player controller with WASD movement"
|
|
130
|
+
- "Add a rotating cube to the scene with a red material"
|
|
131
|
+
- "Create a simple platformer level with obstacles"
|
|
132
|
+
- "Generate a shader that creates a holographic effect"
|
|
133
|
+
- "List all GameObjects in the current scene"
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
## Documentation
|
|
138
|
+
|
|
139
|
+
For complete documentation, troubleshooting, and advanced usage:
|
|
140
|
+
|
|
141
|
+
📖 **[Full Documentation](https://github.com/CoplayDev/unity-mcp#readme)**
|
|
142
|
+
|
|
143
|
+
---
|
|
144
|
+
|
|
145
|
+
## Requirements
|
|
146
|
+
|
|
147
|
+
- **Python:** 3.10 or newer
|
|
148
|
+
- **Unity Editor:** 2021.3 LTS or newer
|
|
149
|
+
- **uv:** Python package manager ([Installation Guide](https://docs.astral.sh/uv/getting-started/installation/))
|
|
150
|
+
|
|
151
|
+
---
|
|
152
|
+
|
|
153
|
+
## License
|
|
154
|
+
|
|
155
|
+
MIT License - See [LICENSE](https://github.com/CoplayDev/unity-mcp/blob/main/LICENSE)
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "mcpforunityserver"
|
|
3
|
+
version = "8.6.0"
|
|
4
|
+
description = "MCP for Unity Server: A Unity package for Unity Editor integration via the Model Context Protocol (MCP)."
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
license = "MIT"
|
|
7
|
+
authors = [
|
|
8
|
+
{name = "Marcus Sanatan", email = "msanatan@gmail.com"},
|
|
9
|
+
{name = "David Sarno", email = "david.sarno@gmail.com"},
|
|
10
|
+
{name = "Wu Shutong", email = "martinwfire@gmail.com"}
|
|
11
|
+
]
|
|
12
|
+
classifiers = [
|
|
13
|
+
"Development Status :: 5 - Production/Stable",
|
|
14
|
+
"Environment :: Console",
|
|
15
|
+
"Intended Audience :: Developers",
|
|
16
|
+
"Natural Language :: English",
|
|
17
|
+
"Programming Language :: Python :: 3",
|
|
18
|
+
"Programming Language :: Python :: 3.10",
|
|
19
|
+
"Programming Language :: Python :: 3.11",
|
|
20
|
+
"Programming Language :: Python :: 3.12",
|
|
21
|
+
"Programming Language :: Python :: 3.13",
|
|
22
|
+
"Programming Language :: Python :: 3.14",
|
|
23
|
+
"Programming Language :: Python :: Implementation :: CPython",
|
|
24
|
+
"Topic :: Internet :: WWW/HTTP :: HTTP Servers",
|
|
25
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
26
|
+
"Topic :: Games/Entertainment",
|
|
27
|
+
"Topic :: Software Development :: Code Generators",
|
|
28
|
+
]
|
|
29
|
+
keywords = ["mcp", "unity", "ai", "model context protocol", "gamedev", "unity3d", "automation", "llm", "agent"]
|
|
30
|
+
requires-python = ">=3.10"
|
|
31
|
+
dependencies = [
|
|
32
|
+
"httpx>=0.27.2",
|
|
33
|
+
"fastmcp==2.14.1",
|
|
34
|
+
"mcp>=1.16.0",
|
|
35
|
+
"pydantic>=2.12.5",
|
|
36
|
+
"tomli>=2.3.0",
|
|
37
|
+
"fastapi>=0.104.0",
|
|
38
|
+
"uvicorn>=0.35.0",
|
|
39
|
+
]
|
|
40
|
+
|
|
41
|
+
[project.optional-dependencies]
|
|
42
|
+
dev = [
|
|
43
|
+
"pytest>=8.0.0",
|
|
44
|
+
"pytest-asyncio>=0.23",
|
|
45
|
+
]
|
|
46
|
+
|
|
47
|
+
[project.urls]
|
|
48
|
+
Repository = "https://github.com/CoplayDev/unity-mcp.git"
|
|
49
|
+
Issues = "https://github.com/CoplayDev/unity-mcp/issues"
|
|
50
|
+
|
|
51
|
+
[project.scripts]
|
|
52
|
+
mcp-for-unity = "main:main"
|
|
53
|
+
|
|
54
|
+
[build-system]
|
|
55
|
+
requires = ["setuptools>=64.0.0", "wheel"]
|
|
56
|
+
build-backend = "setuptools.build_meta"
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Configuration settings for the MCP for Unity Server.
|
|
3
|
+
This file contains all configurable parameters for the server.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from dataclasses import dataclass
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@dataclass
|
|
10
|
+
class ServerConfig:
|
|
11
|
+
"""Main configuration class for the MCP server."""
|
|
12
|
+
|
|
13
|
+
# Network settings
|
|
14
|
+
unity_host: str = "localhost"
|
|
15
|
+
unity_port: int = 6400
|
|
16
|
+
mcp_port: int = 6500
|
|
17
|
+
|
|
18
|
+
# Connection settings
|
|
19
|
+
connection_timeout: float = 30.0
|
|
20
|
+
buffer_size: int = 16 * 1024 * 1024 # 16MB buffer
|
|
21
|
+
|
|
22
|
+
# STDIO framing behaviour
|
|
23
|
+
require_framing: bool = True
|
|
24
|
+
handshake_timeout: float = 1.0
|
|
25
|
+
framed_receive_timeout: float = 2.0
|
|
26
|
+
max_heartbeat_frames: int = 16
|
|
27
|
+
heartbeat_timeout: float = 2.0
|
|
28
|
+
|
|
29
|
+
# Logging settings
|
|
30
|
+
log_level: str = "INFO"
|
|
31
|
+
log_format: str = "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
|
|
32
|
+
|
|
33
|
+
# Server settings
|
|
34
|
+
max_retries: int = 5
|
|
35
|
+
retry_delay: float = 0.25
|
|
36
|
+
# Backoff hint returned to clients when Unity is reloading (milliseconds)
|
|
37
|
+
reload_retry_ms: int = 250
|
|
38
|
+
# Number of polite retries when Unity reports reloading
|
|
39
|
+
# 40 × 250ms ≈ 10s default window
|
|
40
|
+
reload_max_retries: int = 40
|
|
41
|
+
|
|
42
|
+
# Port discovery cache
|
|
43
|
+
port_registry_ttl: float = 5.0
|
|
44
|
+
|
|
45
|
+
# Telemetry settings
|
|
46
|
+
telemetry_enabled: bool = True
|
|
47
|
+
# Align with telemetry.py default Cloud Run endpoint
|
|
48
|
+
telemetry_endpoint: str = "https://api-prod.coplay.dev/telemetry/events"
|
|
49
|
+
|
|
50
|
+
def configure_logging(self) -> None:
|
|
51
|
+
level = getattr(logging, self.log_level, logging.INFO)
|
|
52
|
+
logging.basicConfig(level=level, format=self.log_format)
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
# Create a global config instance
|
|
56
|
+
config = ServerConfig()
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import functools
|
|
2
|
+
import inspect
|
|
3
|
+
import logging
|
|
4
|
+
from typing import Callable, Any
|
|
5
|
+
|
|
6
|
+
logger = logging.getLogger("mcp-for-unity-server")
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def log_execution(name: str, type_label: str):
|
|
10
|
+
"""Decorator to log input arguments and return value of a function."""
|
|
11
|
+
def decorator(func: Callable) -> Callable:
|
|
12
|
+
@functools.wraps(func)
|
|
13
|
+
def _sync_wrapper(*args, **kwargs) -> Any:
|
|
14
|
+
logger.info(
|
|
15
|
+
f"{type_label} '{name}' called with args={args} kwargs={kwargs}")
|
|
16
|
+
try:
|
|
17
|
+
result = func(*args, **kwargs)
|
|
18
|
+
logger.info(f"{type_label} '{name}' returned: {result}")
|
|
19
|
+
return result
|
|
20
|
+
except Exception as e:
|
|
21
|
+
logger.info(f"{type_label} '{name}' failed: {e}")
|
|
22
|
+
raise
|
|
23
|
+
|
|
24
|
+
@functools.wraps(func)
|
|
25
|
+
async def _async_wrapper(*args, **kwargs) -> Any:
|
|
26
|
+
logger.info(
|
|
27
|
+
f"{type_label} '{name}' called with args={args} kwargs={kwargs}")
|
|
28
|
+
try:
|
|
29
|
+
result = await func(*args, **kwargs)
|
|
30
|
+
logger.info(f"{type_label} '{name}' returned: {result}")
|
|
31
|
+
return result
|
|
32
|
+
except Exception as e:
|
|
33
|
+
logger.info(f"{type_label} '{name}' failed: {e}")
|
|
34
|
+
raise
|
|
35
|
+
|
|
36
|
+
return _async_wrapper if inspect.iscoroutinefunction(func) else _sync_wrapper
|
|
37
|
+
return decorator
|