Skip to content

Commit 2b188e3

Browse files
committed
docs: fix license link case, zh-CN anchors, dedupe ja FAQ
1 parent 2dda463 commit 2b188e3

File tree

3 files changed

+349
-82
lines changed

3 files changed

+349
-82
lines changed

README-ja.md

Lines changed: 172 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,6 @@ MCP Unityは、Unityの`Library/PackedCache`フォルダーをワークスペー
114114
- Node.js 18以降 - [サーバーを起動](#start-server)するため
115115
- npm 9以降 - [サーバーをデバッグ](#debug-server)するため
116116

117-
## <a name="install-server"></a>インストール
118-
119117
> [!IMPORTANT]
120118
> **プロジェクトパスにスペースを含めることはできません**
121119
>
@@ -128,6 +126,8 @@ MCP Unityは、Unityの`Library/PackedCache`フォルダーをワークスペー
128126
>
129127
> インストールを進める前に、プロジェクトがスペースを含まないパスにあることを確認してください。
130128
129+
## <a name="install-server"></a>インストール
130+
131131
このMCP Unityサーバーのインストールは複数ステップのプロセスです:
132132

133133
### ステップ1: Node.jsをインストール
@@ -213,35 +213,24 @@ AIクライアントのMCP設定ファイル(例:Claude Desktopのclaude_des
213213

214214
## <a name="start-server"></a>サーバーの起動
215215

216-
MCP Unityサーバーを起動するには2つの方法があります:
217-
218-
## オプション: Node.jsサーバーのインストール
219-
デフォルトでは、Node.jsサーバーは `Server~/` ディレクトリにインストールされます。
220-
問題が発生した場合は、以下の手順で強制的にインストールできます:
221-
222216
1. Unityエディターを開く
223-
2. メニューから Tools > MCP Unity > Server Window に移動
224-
3. 「Force Install Server」ボタンをクリック
217+
2. Tools > MCP Unity > Server Window に移動
218+
3. "Start Server" をクリックして WebSocket サーバーを起動
219+
4. Claude Desktop または AI コーディング IDE(例:Cursor IDE、Windsurf IDE など)を開き、Unity ツールの実行を開始
220+
221+
![connect](https://github.com/user-attachments/assets/2e266a8b-8ba3-4902-b585-b220b11ab9a2)
225222

226-
> [!TIP]
227-
> Node.js サーバーは `Server~/` ディレクトリにインストールされます。
223+
> AI クライアントが WebSocket サーバーに接続すると、ウィンドウの緑色のボックスに自動的に表示されます
228224
225+
## オプション:WebSocket ポートを設定
226+
デフォルトでは、WebSocket サーバーは '8090' ポートで動作します。次の手順でポートを変更できます:
229227

230-
### オプション1: Unityエディター経由で起動
231228
1. Unityエディターを開く
232-
2. Tools > MCP Unity > Server Windowに移動
233-
3. "Start Server"ボタンをクリック
234-
4. Open Claude Desktop or your AI Coding IDE (e.g. Cursor IDE, Windsurf IDE, etc.) and start executing Unity tools
235-
236-
![connect](https://github.com/user-attachments/assets/2e266a8b-8ba3-4902-b585-b220b11ab9a2)
237-
238-
### オプション2: コマンドラインから起動
239-
1. ターミナルまたはコマンドプロンプトを開く
240-
2. MCP Unityサーバーディレクトリに移動
241-
3. 以下のコマンドを実行:
242-
```bash
243-
node Server~/build/index.js
244-
```
229+
2. Tools > MCP Unity > Server Window に移動
230+
3. "WebSocket Port" の値を希望のポート番号に変更
231+
4. Unity はシステム環境変数 UNITY_PORT を新しいポート番号に設定
232+
5. Node.js サーバーを再起動
233+
6. 再度 "Start Server" をクリックして、Unity Editor の WebSocket を Node.js MCP サーバーに再接続
245234

246235
## オプション: タイムアウト設定
247236

@@ -270,29 +259,74 @@ MCP Unityサーバーを起動するには2つの方法があります:
270259
6. リモートで MCP ブリッジを実行する場合は、環境変数 UNITY_HOST を Unity 実行マシンの IP アドレスに設定して起動:
271260
`UNITY_HOST=192.168.1.100 node server.js`
272261

273-
## サポート & フィードバック
262+
## <a name="debug-server"></a>サーバーのデバッグ
274263

275-
ご質問やサポートが必要な場合は、このリポジトリの[Issue](https://github.com/CoderGamester/mcp-unity/issues)を開くか、以下までご連絡ください:
276-
- LinkedIn: [![](https://img.shields.io/badge/LinkedIn-0077B5?style=flat&logo=linkedin&logoColor=white 'LinkedIn')](https://www.linkedin.com/in/miguel-tomas/)
277-
- Discord: gamester7178
278-
- Email: game.gamester@gmail.com
264+
<details>
265+
<summary><span style="font-size: 1.1em; font-weight: bold;">Node.js サーバーのビルド</span></summary>
279266

280-
## 貢献
267+
MCP Unity サーバーは Node.js で構築されています。TypeScript コードを `build` ディレクトリにコンパイルする必要があります。問題がある場合は、以下の手順で強制的にインストールできます:
281268

282-
貢献は大歓迎です!プルリクエストを送信するか、Issueを開いてください。
269+
1. Unityエディターを開く
270+
2. Tools > MCP Unity > Server Window に移動
271+
3. 「Force Install Server」ボタンをクリック
283272

284-
**コミットメッセージ**[Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/)形式に従ってください。
273+
![install](docs/install.jpg)
285274

286-
## ライセンス
275+
手動でビルドする場合は、以下の手順に従ってください:
287276

288-
本プロジェクトは[MIT License](License.md)の下で提供されます。
277+
1. ターミナル/PowerShell/コマンドプロンプトを開く
278+
2. Server ディレクトリに移動:
279+
```bash
280+
cd ABSOLUTE/PATH/TO/mcp-unity/Server~
281+
```
282+
3. 依存関係をインストール:
283+
```bash
284+
npm install
285+
```
286+
4. サーバーをビルド:
287+
```bash
288+
npm run build
289+
```
290+
5. サーバーを実行:
291+
```bash
292+
node build/index.js
293+
```
289294

290-
## 謝辞
295+
</details>
296+
297+
<details>
298+
<summary><span style="font-size: 1.1em; font-weight: bold;">MCP Inspector でデバッグ</span></summary>
291299

292-
- Model Context Protocol
293-
- Unity Technologies
294-
- Node.js
295-
- WebSocket-Sharp
300+
[@modelcontextprotocol/inspector](https://github.com/modelcontextprotocol/inspector) を使用してサーバーをデバッグします:
301+
- Powershell
302+
```powershell
303+
npx @modelcontextprotocol/inspector node Server~/build/index.js
304+
```
305+
- コマンドプロンプト/ターミナル
306+
```cmd
307+
npx @modelcontextprotocol/inspector node Server~/build/index.js
308+
```
309+
310+
ターミナルを閉じる前、または [MCP Inspector](https://github.com/modelcontextprotocol/inspector) でデバッグする前に、必ず `Ctrl + C` でサーバーを終了してください。
311+
312+
</details>
313+
314+
<details>
315+
<summary><span style="font-size: 1.1em; font-weight: bold;">コンソールログを有効化</span></summary>
316+
317+
1. ターミナルまたは log.txt ファイルにログ出力を有効化:
318+
- Powershell
319+
```powershell
320+
$env:LOGGING = "true"
321+
$env:LOGGING_FILE = "true"
322+
```
323+
- コマンドプロンプト/ターミナル
324+
```cmd
325+
set LOGGING=true
326+
set LOGGING_FILE=true
327+
```
328+
329+
</details>
296330

297331
## よくある質問
298332

@@ -374,3 +408,100 @@ MCP Unityは、MCPクライアントとして機能できるAIアシスタント
374408

375409
<details>
376410
<summary><span style="font-size: 1.1em; font-weight: bold;">MCP Unityに接続できないのはなぜですか?</span></summary>
411+
412+
- WebSocket サーバーが起動していることを確認(Unity の Server Window を確認)
413+
- MCP クライアントからコンソールログを 1 件送信して、MCP クライアントと Unity サーバー間の再接続をトリガー
414+
- Unity Editor の MCP Server ウィンドウ(Tools > MCP Unity > Server Window)でポート番号を変更
415+
416+
</details>
417+
418+
<details>
419+
<summary><span style="font-size: 1.1em; font-weight: bold;">MCP Unity サーバーが起動しないのはなぜですか?</span></summary>
420+
421+
- Unity コンソールにエラーメッセージがないか確認
422+
- Node.js が正しくインストールされ、PATH から実行できることを確認
423+
- Server ディレクトリで依存関係がインストールされていることを確認
424+
425+
</details>
426+
427+
<details>
428+
<summary><span style="font-size: 1.1em; font-weight: bold;">Play Mode テストを実行すると接続失敗エラーが発生するのはなぜですか?</span></summary>
429+
430+
`run_tests` ツールは次のレスポンスを返すことがあります:
431+
```
432+
Error:
433+
Connection failed: Unknown error
434+
```
435+
436+
これは、Play Mode に切り替える際のドメインリロードでブリッジ接続が失われるために発生します。回避策として、**Edit > Project Settings > Editor > "Enter Play Mode Settings"****Reload Domain** をオフにしてください。
437+
438+
</details>
439+
440+
## トラブルシューティング:WSL2(Windows 11)のネットワーク
441+
442+
WSL2 内で MCP(Node.js)サーバーを実行し、Unity が Windows 11 上で動作している場合、`ws://localhost:8090/McpUnity` への接続が `ECONNREFUSED` で失敗することがあります。
443+
444+
原因:WSL2 と Windows は別々のネットワーク名前空間を持ち、WSL2 内の `localhost` は Windows ホストを指しません。既定では Unity は `localhost:8090` で待ち受けます。
445+
446+
### 解決策 1 — WSL2 のミラー化ネットワークを有効化(推奨)
447+
- Windows 11: 設定 → システム → 開発者向け → WSL → 「ミラー化モードのネットワーク」を有効化。
448+
- または `.wslconfig` で設定(適用後に `wsl --shutdown` を実行して WSL を再起動):
449+
450+
```ini
451+
[wsl2]
452+
networkingMode=mirrored
453+
```
454+
455+
有効化後は Windows と WSL2 で `localhost` が共有され、既定設定(`localhost:8090`)で動作します。
456+
457+
### 解決策 2 — Node クライアントを Windows ホストに向ける
458+
MCP クライアントを起動する前に、WSL シェルで以下を設定します:
459+
460+
```bash
461+
# resolv.conf から検出した Windows ホスト IP を使用
462+
export UNITY_HOST=$(grep -m1 nameserver /etc/resolv.conf | awk '{print $2}')
463+
```
464+
465+
これにより、`Server~/src/unity/mcpUnity.ts``localhost` の代わりに `ws://$UNITY_HOST:8090/McpUnity` に接続します(`UNITY_HOST` を参照し、必要に応じて `ProjectSettings/McpUnitySettings.json``Host` も使用されます)。
466+
467+
### 解決策 3 — Unity からのリモート接続を許可
468+
- Unity: Tools → MCP Unity → Server Window → 「Allow Remote Connections」を有効化(`0.0.0.0` にバインド)。
469+
- Windows ファイアウォールで、設定したポート(既定 8090)への受信 TCP を許可します。
470+
- WSL2 からは、Windows ホストの IP(解決策 2 を参照)またはミラー化有効時は `localhost` へ接続します。
471+
472+
> [!NOTE]
473+
> 既定のポートは `8090` です。Unity の Server Window(Tools → MCP Unity → Server Window)で変更できます。値は `McpUnitySettings` に対応し、`ProjectSettings/McpUnitySettings.json` に保存されます。
474+
475+
#### 接続確認
476+
477+
```bash
478+
npm i -g wscat
479+
# ミラー化ネットワーク有効化後
480+
wscat -c ws://localhost:8090/McpUnity
481+
# または Windows ホスト IP を使用
482+
wscat -c ws://$UNITY_HOST:8090/McpUnity
483+
```
484+
485+
## サポート & フィードバック
486+
487+
ご質問やサポートが必要な場合は、このリポジトリの[Issue](https://github.com/CoderGamester/mcp-unity/issues)を開くか、以下までご連絡ください:
488+
- LinkedIn: [![](https://img.shields.io/badge/LinkedIn-0077B5?style=flat&logo=linkedin&logoColor=white 'LinkedIn')](https://www.linkedin.com/in/miguel-tomas/)
489+
- Discord: gamester7178
490+
- Email: game.gamester@gmail.com
491+
492+
## 貢献
493+
494+
貢献は大歓迎です!プルリクエストを送信するか、Issueを開いてください。
495+
496+
**コミットメッセージ**[Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/)形式に従ってください。
497+
498+
## ライセンス
499+
500+
本プロジェクトは[MIT License](LICENSE.md)の下で提供されます。
501+
502+
## 謝辞
503+
504+
- [Model Context Protocol](https://modelcontextprotocol.io)
505+
- [Unity Technologies](https://unity.com)
506+
- [Node.js](https://nodejs.org)
507+
- [WebSocket-Sharp](https://github.com/sta/websocket-sharp)

README.md

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -438,11 +438,55 @@ Error:
438438
Connection failed: Unknown error
439439
```
440440

441-
This error occurs because the bridge connection is lost when the domain reloads upon switching to Play Mode.
442-
The workaround is to turn off **Reload Domain** in **Edit > Project Settings > Editor > "Enter Play Mode Settings"**.
441+
This error occurs because the bridge connection is lost when the domain reloads upon switching to Play Mode. The workaround is to turn off **Reload Domain** in **Edit > Project Settings > Editor > "Enter Play Mode Settings"**.
443442

444443
</details>
445444

445+
## Troubleshooting: WSL2 (Windows 11) networking
446+
447+
When running the MCP (Node.js) server inside WSL2 while Unity runs on Windows 11, connecting to `ws://localhost:8090/McpUnity` may fail with `ECONNREFUSED`.
448+
449+
Cause: WSL2 and Windows have separate network namespaces — `localhost` inside WSL2 does not point to the Windows host. By default, Unity listens on `localhost:8090`.
450+
451+
### Solution 1 — Enable WSL2 Mirrored mode networking (preferred)
452+
- Windows 11: Settings → System → For developers → WSL → Enable “Mirrored mode networking”.
453+
- Or via `.wslconfig` (then run `wsl --shutdown` and reopen WSL):
454+
455+
```ini
456+
[wsl2]
457+
networkingMode=mirrored
458+
```
459+
460+
After enabling, `localhost` is shared between Windows and WSL2, so the default config (`localhost:8090`) works.
461+
462+
### Solution 2 — Point the Node client to the Windows host
463+
Set in your WSL shell before starting the MCP client:
464+
465+
```bash
466+
# Use the Windows host IP detected from resolv.conf
467+
export UNITY_HOST=$(grep -m1 nameserver /etc/resolv.conf | awk '{print $2}')
468+
```
469+
470+
With this, `Server~/src/unity/mcpUnity.ts` will connect to `ws://$UNITY_HOST:8090/McpUnity` instead of `localhost` (it reads `UNITY_HOST`, and may also honor a `Host` in `ProjectSettings/McpUnitySettings.json` if present).
471+
472+
### Solution 3 — Allow remote connections from Unity
473+
- Unity: Tools → MCP Unity → Server Window → enable “Allow Remote Connections” (Unity binds to `0.0.0.0`).
474+
- Ensure Windows Firewall allows inbound TCP on your configured port (default 8090).
475+
- From WSL2, connect to the Windows host IP (see Solution 2) or to `localhost` if mirrored mode is enabled.
476+
477+
> [!NOTE]
478+
> Default port is `8090`. You can change it in the Unity Server Window (Tools → MCP Unity → Server Window). The value maps to `McpUnitySettings` and is persisted in `ProjectSettings/McpUnitySettings.json`.
479+
480+
#### Validate connectivity
481+
482+
```bash
483+
npm i -g wscat
484+
# After enabling mirrored networking
485+
wscat -c ws://localhost:8090/McpUnity
486+
# Or using the Windows host IP
487+
wscat -c ws://$UNITY_HOST:8090/McpUnity
488+
```
489+
446490
## Support & Feedback
447491

448492
If you have any questions or need support, please open an [issue](https://github.com/CoderGamester/mcp-unity/issues) on this repository or alternative you can reach out on:
@@ -458,7 +502,7 @@ Contributions are welcome! Please feel free to submit a Pull Request or open an
458502

459503
## License
460504

461-
This project is under [MIT License](License.md)
505+
This project is under [MIT License](LICENSE.md)
462506

463507
## Acknowledgements
464508

0 commit comments

Comments
 (0)