Skip to content

Commit f06ff90

Browse files
authored
Merge pull request #1101 from JMartinezRuiz/docs/dev-package-source-guidance
docs: clarify development setup and package-source checks
2 parents 8d1813f + b90b811 commit f06ff90

2 files changed

Lines changed: 119 additions & 10 deletions

File tree

.github/pull_request_template.md

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,38 @@
22
<!-- Provide a brief description of your changes -->
33

44
## Type of Change
5-
<!-- Save the type of change you did -->
6-
Save your change type
7-
- Bug fix (non-breaking change that fixes an issue)
8-
- New feature (non-breaking change that adds functionality)
9-
- Breaking change (fix or feature that would cause existing functionality to change)
10-
- Documentation update
11-
- Refactoring (no functional changes)
12-
- Test update
5+
<!-- Check all that apply -->
6+
- [ ] Bug fix (non-breaking change that fixes an issue)
7+
- [ ] New feature (non-breaking change that adds functionality)
8+
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
9+
- [ ] Documentation update
10+
- [ ] Refactoring (no functional changes)
11+
- [ ] Test update
1312

1413
## Changes Made
1514
<!-- List the specific changes in this PR -->
1615

16+
## Compatibility / Package Source
17+
<!-- Especially important for Unity API compatibility, package-source, or transport changes -->
18+
- Unity version(s) tested:
19+
- Package source used (`#beta`, `#main`, tag, branch, or `file:`):
20+
- Resolved commit hash from `Packages/packages-lock.json` (if using a Git package URL):
1721

1822
## Testing/Screenshots/Recordings
1923
<!-- If applicable, add screenshots or recordings to demonstrate the changes -->
24+
- [ ] Python tests (`cd Server && uv run pytest tests/ -v`)
25+
- [ ] Unity EditMode tests
26+
- [ ] Unity PlayMode tests
27+
- [ ] Package import/compile check
28+
- [ ] Not applicable (explain why in Additional Notes)
2029

2130

2231
## Documentation Updates
2332
<!-- Check if you updated documentation for changes to tools/resources -->
2433
- [ ] I have added/removed/modified tools or resources
2534
- [ ] If yes, I have updated all documentation files using:
2635
- [ ] The LLM prompt at `tools/UPDATE_DOCS_PROMPT.md` (recommended)
27-
- [ ] Manual updates following the guide at `tools/UPDATE_DOCS.md`
36+
- [ ] Manual review of the generated changes
2837

2938

3039
## Related Issues

docs/development/README-DEV.md

Lines changed: 101 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,41 @@
99

1010
Before proposing major new features, please reach out to discuss - someone may already be working on it or it may have been considered previously. Open an issue or discussion to coordinate.
1111

12+
Keep PRs focused. A small fix with a clear repro and the exact Unity/package versions is much easier to review than a broad cleanup bundled with behavior changes.
13+
14+
For bug fixes, include:
15+
16+
- Unity version(s) tested
17+
- package source used (`#beta`, `#main`, tag, fork branch, or `file:`)
18+
- resolved Git commit from `Packages/packages-lock.json` when the package source is a Git URL
19+
- commands/tests run locally
20+
21+
Avoid mixing release/version bumps with feature or bug-fix PRs. The release workflows handle package and server version updates.
22+
23+
## Repository Map
24+
25+
- `MCPForUnity/` - the Unity package: Editor UI, C# tool handlers, resources, compatibility shims, package metadata.
26+
- `Server/` - the Python MCP server, CLI, FastMCP tool/resource registry, transports, and server-side tests.
27+
- `TestProjects/UnityMCPTests/` - Unity project used for EditMode/PlayMode tests. Its manifest points at `file:../../../MCPForUnity`.
28+
- `docs/` - user, contributor, release, migration, and reference documentation.
29+
- `tools/` - release/build helpers, documentation update prompt, stress tools, and publishing scripts.
30+
- `CustomTools/` - examples and support code for project-defined custom tools.
31+
1232
## Local Development Setup
1333

34+
### 0. Prepare the Python Server
35+
36+
For server work, use the same setup path as CI:
37+
38+
```bash
39+
cd Server
40+
uv sync
41+
uv pip install -e ".[dev]"
42+
uv run pytest tests/ -v --tb=short
43+
```
44+
45+
Most Python unit tests do not need Unity running. Integration tests that talk to the Editor require a Unity instance with the bridge connected.
46+
1447
### 1. Point Unity to Your Local Server
1548

1649
For the fastest iteration when working on the Python server:
@@ -36,9 +69,53 @@ Options:
3669

3770
After switching, open Package Manager in Unity and Refresh to re-resolve packages.
3871

72+
When testing Unity package changes, prefer **Local workspace**. Do not patch `Library/PackageCache/` directly; Unity may overwrite it on the next resolve.
73+
74+
`#beta` and `#main` are moving branch names. When debugging a package-source issue, check `Packages/packages-lock.json` as well as `Packages/manifest.json`; the lock file tells you the commit Unity actually resolved.
75+
76+
Example Git package lock entry:
77+
78+
```json
79+
"com.coplaydev.unity-mcp": {
80+
"version": "https://github.com/CoplayDev/unity-mcp.git?path=/MCPForUnity#beta",
81+
"source": "git",
82+
"hash": "<resolved-git-commit>"
83+
}
84+
```
85+
86+
## Adding or Changing Tools and Resources
87+
88+
Built-in Unity tools usually have two sides:
89+
90+
- a C# handler under `MCPForUnity/Editor/Tools/`
91+
- a Python-facing tool under `Server/src/services/tools/`
92+
93+
Resources follow the same split:
94+
95+
- C# resources under `MCPForUnity/Editor/Resources/`
96+
- Python resources under `Server/src/services/resources/`
97+
98+
Use `[McpForUnityTool]` / `[McpForUnityResource]` on the Unity side and `@mcp_for_unity_tool` / `@mcp_for_unity_resource` on the server side. If the tool is long-running, use the existing `PendingResponse` / polling patterns instead of blocking the bridge.
99+
100+
Current server tool groups are:
101+
102+
- `core`
103+
- `docs`
104+
- `vfx`
105+
- `animation`
106+
- `ui`
107+
- `scripting_ext`
108+
- `testing`
109+
- `probuilder`
110+
- `profiling`
111+
112+
Tools with `group=None` are server meta-tools and are always visible. The default enabled group is `core`; other groups can be enabled through the Tools tab or `manage_tools`.
113+
114+
When adding, removing, or renaming tools/resources, update the public docs and client metadata. Start with `tools/UPDATE_DOCS_PROMPT.md`, then review the changes manually.
115+
39116
## Tool Selection & the Meta-Tool
40117

41-
MCP for Unity organizes tools into **groups** (Core, VFX & Shaders, Animation, UI Toolkit, Scripting Extensions, Testing). You can selectively enable or disable tools to control which capabilities are exposed to AI clients — reducing context window usage and focusing the AI on relevant tools.
118+
MCP for Unity organizes tools into **groups**. You can selectively enable or disable tools to control which capabilities are exposed to AI clients — reducing context window usage and focusing the AI on relevant tools.
42119

43120
### Using the Tools Tab in the Editor
44121

@@ -99,10 +176,20 @@ cd Server
99176
uv run pytest tests/ -v
100177
```
101178

179+
Useful narrower runs:
180+
181+
```bash
182+
uv run pytest tests/test_manage_camera.py -v
183+
uv run pytest tests/integration/test_run_tests_async.py -v
184+
uv run pytest tests/ -v --tb=short
185+
```
186+
102187
### Unity C# Tests
103188

104189
Located in `TestProjects/UnityMCPTests/Assets/Tests/`.
105190

191+
The test project consumes the local Unity package from this repo. Use it for package import/compile checks before opening a PR that touches `MCPForUnity/Runtime/`, `MCPForUnity/Editor/`, or package metadata.
192+
106193
**Using the CLI** (requires Unity running with MCP bridge connected):
107194

108195
```bash
@@ -138,6 +225,19 @@ uv run pytest tests/ --cov --cov-report=html
138225
open htmlcov/index.html
139226
```
140227

228+
## Compatibility Notes
229+
230+
The Unity package currently declares Unity `2021.3` as its minimum version in `MCPForUnity/package.json`. Code that uses Unity API conditionals (`UNITY_2022_3_OR_NEWER`, `UNITY_2023_1_OR_NEWER`, `UNITY_6000_*`) should be tested against the affected editor line, not just the oldest supported version.
231+
232+
For compatibility PRs, note the exact editor versions you tested in the PR body. If a Git package URL is involved, include the resolved `packages-lock.json` hash.
233+
234+
## Troubleshooting During Development
235+
236+
- **Unity still loads an old Git package**: close Unity, check `Packages/packages-lock.json`, then refresh Package Manager. If needed, remove only the stale `Library/PackageCache/com.coplaydev.unity-mcp@<hash>` folder while Unity is closed.
237+
- **Unity opens in Safe Mode after changing package source**: the package failed to compile before MCP can start. Fix the compile errors first; the MCP server cannot recover from package compile failures.
238+
- **Server changes are not picked up**: make sure **Server Source Override** points to your local `Server/` directory and **Dev Mode (Force fresh server install)** is enabled.
239+
- **Stdio tool visibility looks stale**: call `manage_tools(action="sync")` or restart the MCP session. HTTP mode can push `tools/list_changed` notifications automatically.
240+
- **Multiple Unity editors are open**: use `mcpforunity://instances` and `set_active_instance` to confirm which project the server is targeting.
141241
## Unity-version CI matrix
142242

143243
CI exercises the package across multiple Unity versions to catch breaks in `#if UNITY_*_OR_NEWER` branches. The matrix is configured in `tools/unity-versions.json` and consumed by `.github/workflows/unity-tests.yml`.

0 commit comments

Comments
 (0)