- Published on
CH11. unity-mcp-setting: Connecting a Unity Project over MCP
- Authors

- Name
- seren-wib
Contents
0. Introduction
Part 11 of the series. What a skill is and why these live outside the instruction files is in CH0. Skills Overview.
Connecting a Unity project to Claude Code means walking through the steps in a fixed order. Add the package, let Unity fetch it, make sure the server inside Unity is up, and only then reload the VS Code window. Get one step out of order and the tools never show up.
In restaurant terms, it is the procedure for opening a new branch and taking the first customer. You bring in the kitchen equipment, add the branch to the head office ledger, wait until the kitchen has its fire lit, and only then open the dining-room door. Open it before the fire is lit and the customer gets an empty menu. The kitchen is the MCP server running inside the Unity Editor, bringing in the equipment is adding a UPM dependency, the ledger entry is registering an MCP client on the Claude Code side, and opening the door is reloading the VS Code window.
unity-mcp-setting is the skill that has the agent walk that order for me. The skill body is 49 lines with two PowerShell scripts (63 and 72 lines) beside it, and 2 commits in the dotfiles repo have touched the folder. It is closer to a run procedure than a writing rule, so its 135 lines of script are longer than its 49-line body (numbers in 7. Skill size and timeout values).
1. The skill's seven steps
The 7 steps of unity-mcp-setting
The skill handles four things: the MCP server running inside the Unity Editor, adding a UPM (Unity Package Manager) dependency, registering it as an MCP client on the Claude Code side, and reloading the VS Code window. MCP itself is covered in the Model Context Protocol post.
The skill body goes in this order.
- Check that the path given as an argument, or the current folder, has
Packages/manifest.json. If not, say it is not a Unity project and stop. - Put one package line at the top of
dependenciesinmanifest.json. Skip if it is already there. - If
claude mcp get unityMCPfails, register the server. - Search for
unitywith ToolSearch. If Unity tools such asmanage_sceneare already in the session, say no reload is needed and stop. - Bring the Unity window to the front so the package import starts.
- Wait up to 300 seconds for the server to come up.
- Reload the VS Code window.
Steps 1 to 4 need only Claude Code's built-in tools (file edits, shell), and the scripts in the skill folder handle 5 to 7. The line added in step 2 is this one.
"com.coplaydev.unity-mcp": "https://github.com/CoplayDev/unity-mcp.git?path=/MCPForUnity#main",
UPM accepts a Git URL as a dependency. ?path= is the package folder inside the repo and #main is the branch. Since it points at a branch rather than a version tag, Unity pulls whatever main is at that moment every time it fetches the package again. Why it was left this way: no record.
The two cautions at the end of the skill are about this file too. manifest.json is the project's whole package list, so it never goes into .gitignore, and it is committed only when I ask. Success means unityMCP shows as Connected in the /mcp list after the reload.
2. Why the order matters
The cause is tool list loading at session start. When a Claude Code session starts, it connects to the registered MCP servers and fetches their tool lists. If the Unity server is not up at that moment, the session settles without those tools. Even if the server comes up later, they do not appear in the same session; the VS Code window has to be reloaded so the extension and the session start fresh.
The guide that wrote down the manual steps (~/projects/unity-projects/mcp-guide.md, 2,245 bytes, last modified 2026-10-03) keeps this order in one line.
4번 다음에 5번. 서버가 켜지기 전에 리로드하면 도구가 안 들어온다.
("Step 5 after step 4. If you reload before the server is on, the tools do not come in.") Step 4 there is "check that the server is on" and step 5 is "Reload Window". The manual procedure needed a person to keep this order while switching between the Unity and VS Code windows. The skill turned "check the server" into a script (step 6) and "reload" into automated key input (step 7), so a machine keeps the order. The same guide already lists /unity-mcp-setting as the "quick way", so the skill existed by 2026-10-03 at the latest. Exactly when it was made: no record. All three files are in the first commit of the dotfiles repo (2026-10-06).
3. Register the server at local scope
The registration range is set by MCP scope. user scope attaches a server to sessions in every folder, while local scope attaches it only in the folder it was registered in. The command in step 3 is this.
claude mcp add --scope local --transport http unityMCP http://127.0.0.1:8080/mcp
It started out in user scope. A commit on 2026-10-15 changed that, and the reason for the changed line sits right in the skill body.
user 스코프는 쓰지 않는다. Unity를 열지 않은 폴더에서도 매 세션 연결 실패가 뜬다.
("Do not use user scope. Every session shows a connection failure, even in folders where Unity is not open.") The same commit renamed the server from UnityMCP to unityMCP. Today mcp/sync.mjs and the VS Code mcp.json use unityMCP as well. The change was not about Unity alone; it was part of a cleanup that took every local Claude Code MCP server out of user scope and attached each one only to the folders that need it. That rule is in the MCP section of the agent environment post. mcp/sync.mjs already registers ~/projects/unity-projects in local scope, so for projects directly under it step 3 has nothing to do.
4. Checking it is my project's server
A response does not tell me whether it came from my project's server. Another Unity project may have started a server on the same address.
The two checks wait-unity-mcp.ps1 runs every 5 seconds
What it checks is the readiness check and port ownership. The MCP for Unity server uses the fixed address http://127.0.0.1:8080/mcp. Open two Unity projects and they compete for the same port. So wait-unity-mcp.ps1 looks at two things every 5 seconds.
- endpoint: POST an MCP
initializerequest and see whether HTTP 200 comes back. Each request times out after 3 seconds. - pid file: the project that started the server leaves
<project>/Library/MCPForUnity/RunState/mcp_http_8080.pid. Is that file in the target project, and is the process with that PID alive?
Looking at the endpoint alone would also accept a server another project started. So it checks both and splits the outcome into exit codes.
| State | Exit code | What the skill does |
|---|---|---|
| Endpoint answers, target project has the pid | 0 | Go to step 7 |
| Endpoint answers, target has none but a sibling project has it | 2 | Tell me to close that project or stop its server, then stop |
| Not confirmed within 300 seconds | 1 | Check the Unity console, point to the server Start, then stop |
Looking at sibling folders assumes the Unity projects sit side by side under one folder, ~/projects/unity-projects. The script prints a line only when the state changes, so the same line does not pile up every 5 seconds. The skill says to give the PowerShell tool a 360,000 ms timeout: the script's 300 seconds plus one minute of slack. If it stops on a timeout, calling /unity-mcp-setting again skips step 2 and carries on.
5. Finding windows and reloading
This step is built from window focus and key input injection. window.ps1 walks the window titles with the Win32 API (EnumWindows and SetForegroundWindow in user32.dll) to find the VS Code or Unity window whose title has the project folder name. The title patterns are <file> - <folder> - Visual Studio Code for VS Code and <folder> - <scene> - ... - Unity 6.x for Unity. How Unity and VS Code split their jobs is in the Unity basics post.
The script comments record two workarounds.
- A background process may be blocked by Windows' focus-stealing rules from bringing another window to the front. So it presses and releases Alt once before
SetForegroundWindow. If the foreground window is not the target 400 ms later, it reports failure with exit code 2. - The reload opens the command palette with
Ctrl+Shift+P, entersDeveloper: Reload Window, and sends Enter. Typing that command name as keystrokes garbles it while the Korean IME is on, so it goes through the clipboard andCtrl+V. The previous clipboard content is saved first and restored at the end.
The reload kills the Claude Code session running inside VS Code. So the skill pins step 7 as the last tool call and has the agent report the result first (whether the package was added, the server check, the reload coming up). After the reload a new session starts, and since it starts with the server already up, the Unity tools are in its tool list. If the key input fails (a non-zero exit code), it tells me to run Ctrl+Shift+P → Developer: Reload Window by hand.
6. Known limits
The limit is a platform dependency. The scripts for steps 5 to 7 rely on PowerShell, the Win32 API and System.Windows.Forms.SendKeys, so they run only on Windows. Windows and the Mac share the same dotfiles, but the Mac has no ~/projects/unity-projects folder and so no unityMCP registration. If it is ever needed on the Mac, the window control part has to be written separately.
The port is fixed at 8080, so there is no way to open several Unity projects at once and connect each of them. The skill only reports the clash through exit code 2 from section 4.
How many times this skill has actually run: no record. The worklog and the memory change log only hold the change in how it registers (2026-10-15), not any runs.
7. Skill size and timeout values
As of 2026-11-28.
| Item | Value | Source |
|---|---|---|
SKILL.md | 49 lines, 3,433 bytes | wc |
wait-unity-mcp.ps1 | 63 lines, 2,723 bytes | wc |
window.ps1 | 72 lines, 3,617 bytes | wc |
| Commits that changed the folder | 2 (2026-10-06 first commit, 2026-10-15) | dotfiles git log |
| 2026-10-15 change | SKILL.md +4 lines −3 lines | dotfiles git show |
| Manual guide | 2,245 bytes, last modified 2026-10-03 | mcp-guide.md |
| Steps | 7 | SKILL.md |
| Server wait | up to 300 s, every 5 s, 3 s per request | wait-unity-mcp.ps1 |
| PowerShell tool timeout | 360,000 ms | SKILL.md |
| Pauses between reload keystrokes | 600 ms, 400 ms, 300 ms | window.ps1 |
| Number of runs | no record |
8. Reflection
The skill turns "check the server" into a script and "reload" into automated key input, so a machine keeps the order.