You signed in with another tab or window. Reload
to refresh your session. You signed out in another tab or window. Reload
to refresh your session. You switched accounts on another tab or window. Reload
to refresh your session. Dismiss alert
Azreal42 / YetAnotherUnityMcp Public
Yet Another Unity Mcp client / server
7 stars
4 forks
Branches
Tags
Activity
Notifications
You must be signed in to change notification settings
main
Go to file
Code
| Name | | Name | Last commit message | Last commit date |
| --- | --- | --- | --- |
| Latest commit
-------------
Azreal42
and
Claude
Update MCP implementation to match official specification
Mar 25, 2025
710f4bb
· Mar 25, 2025
History
-------
63 Commits
| | |
| plugin | | plugin | Update MCP implementation to match official specification | Mar 25, 2025 |
| server | | server | Update MCP implementation to match official specification | Mar 25, 2025 |
| tests | | tests | Update MCP implementation to match official specification | Mar 25, 2025 |
| .gitignore | | .gitignore | bootstrap (claude code / wip) | Mar 16, 2025 |
| CLAUDE.md | | CLAUDE.md | Update MCP implementation to match official specification | Mar 25, 2025 |
| CorrectMcpJson.md | | CorrectMcpJson.md | Update MCP implementation to match official specification | Mar 25, 2025 |
| LICENSE | | LICENSE | Improve Unity-Python WebSocket communication performance | Mar 20, 2025 |
| MCP_MIGRATION_GUIDE.md | | MCP_MIGRATION_GUIDE.md | Update MCP implementation to match official specification | Mar 25, 2025 |
| README.md | | README.md | Update MCP implementation to match official specification | Mar 25, 2025 |
| TECH_DETAILS.md | | TECH_DETAILS.md | Update MCP implementation to match official specification | Mar 25, 2025 |
| conftest.py | | conftest.py | Update MCP implementation to match official specification | Mar 25, 2025 |
| pyproject.toml | | pyproject.toml | Update MCP implementation to match official specification | Mar 25, 2025 |
| schema_debug.json | | schema_debug.json | Update MCP implementation to match official specification | Mar 25, 2025 |
| uv.lock | | uv.lock | Update MCP implementation to match official specification | Mar 25, 2025 |
| View all files | | |
DO NOT USE THIS. THIS IS A TOY PROJECT TO SEE WHAT I CAN DO WITH CLAUDE CODE. I'M TRYING TO ASSESS IF A DEV CAN CORRECTLY WORK WITH JUST VIBE CODING SO FAR, IT SEEMS NOT TO BE THE CASE !
A Unity Master Control Protocol (MCP) implementation that allows AI agents to control and interact with Unity.
YetAnotherUnityMcp is a system that bridges the Unity game engine with AI-driven tools using the Model Context Protocol (MCP). It consists of a Unity .NET/C# plugin acting as the MCP TCP server, and a Python MCP client (built with FastMCP) that handles requests from AI agents. Communication between Unity and the client is done via a custom TCP protocol, enabling real-time, bidirectional exchange of JSON messages and image data.
This architecture cleanly separates the game engine concerns from the AI logic, improving scalability and maintainability. The goal is to allow AI agents (e.g. an LLM-based assistant) to inspect and control a running Unity scene in a structured, safe manner. The container-based approach for organizing resources and tools further improves code organization and reduces boilerplate.
Key components include:
The Model Context Protocol (MCP)
is a standardized way for AI models to interact with applications. It separates the concerns of providing context from the LLM interaction itself, allowing for:
YetAnotherUnityMcp implements the official MCP specification with full compliance, including:
Import the YetAnotherUnityMcp plugin using one of these methods:
plugin/Scripts
folder to your Unity project's Assets directoryCreate a symbolic link for development (Windows PowerShell example):
powershell
New-Item -ItemType SymbolicLink -Target "D:\Dev\YetAnotherUnityMcp\plugin" -Path "C:\Users\azrea\My project\Assets\Plugins\YetAnotherUnityMcp"
Start the TCP server:
# Clone the repository
git clone https://github.com/yourusername/YetAnotherUnityMcp.git
cd YetAnotherUnityMcp
# Create and activate a virtual environment using uv
uv venv -p 3.11
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# Install the server with development dependencies
uv pip install -e ".[dev]"
# Run the MCP client
python -m server.mcp_server
# Install FastMCP and tools
uv pip install fastmcp
# Run the client with MCP inspector for debugging
fastmcp dev server/mcp_server.py
# Install in Claude Desktop
fastmcp install server/mcp_server.py --name "Unity Controller"
YetAnotherUnityMcp/
├── server/ # Python MCP client
│ ├── unity_client_util.py # Unity client utility functions
│ ├── unity_tcp_client.py # High-level Unity TCP client
│ ├── mcp_server.py # MCP server implementation
│ ├── dynamic_tool_invoker.py # Dynamic tool invocation system
│ ├── dynamic_tools.py # Dynamic tool manager
│ ├── connection_manager.py # Connection lifecycle management
│ └── websocket_client.py # Low-level TCP client (legacy name)
├── plugin/ # Unity C# plugin
│ ├── Scripts/ # Plugin source code
│ │ ├── Editor/ # Editor extensions
│ │ │ ├── Commands/ # Editor command implementations
│ │ │ ├── MCPWindow.cs # Server control window
│ │ │ ├── MCPMenu.cs # Unity menu integration
│ │ │ ├── MCPTcpServer.cs # Primary TCP server implementation
│ │ │ ├── CommandExecutionMonitor.cs # Performance monitoring
│ │ │ ├── Models/ # Data models for Editor
│ │ │ └── Net/ # TCP communication implementation
│ │ └── YetAnotherUnityMcp.asmdef # Assembly definition
│ └── README.md # Plugin documentation
└── tests/ # Test suite
The Unity plugin hosts a TCP server that listens for connections from MCP clients. This server:
For detailed information about the container-based approach, see the MCP Container Documentation
.
The Python client connects to the Unity TCP server and provides an MCP interface for AI tools. It:
unity://info
- Basic information about the Unity environmentunity://logs
- Editor logs for debuggingunity://scene/{scene_name}
- Information about a specific sceneunity://object/{object_id}
- Details about a specific GameObjectexecute_code_in_unity
- Run C# code in the Unity Editorunity_screenshot
- Take screenshots of the Unity Editorunity_modify_object
- Change properties of Unity GameObjectsunity_logs
- Get logs from UnityAll communication between the Unity server and the Python client uses a TCP socket connection with a simple framing protocol, which allows persistent, low-latency bidirectional messaging. The connection is initiated by the Python client to the Unity server's TCP endpoint (e.g. localhost:8080
).
The protocol uses a simple framing mechanism:
Every message is a JSON object containing at least a command or response type, a unique ID (to pair requests with responses), and a parameters or result object. The connection is maintained with periodic ping/pong messages. For more details on the communication protocol, see the Technical Details
document.
# Python client development
python -m pytest # Run tests
python -m black . # Format code
python -m flake8 # Lint code
python -m mypy . # Type check
# MCP Development
fastmcp dev server/mcp_server.py # Run with MCP Inspector UI
# Unity server development
# Use the MCP Server window in Unity for debugging
# Monitor connections and messages in real-time
This project is licensed under the MIT License - see the LICENSE file for details.
For more details on architecture, implementation, and extensibility, see the Technical Details
document.
Yet Another Unity Mcp client / server
No releases published
No packages published
You can’t perform that action at this time.