mcp unity
An implementation of the Model Context Protocol for Unity Editor, allowing AI assistants to interact with Unity projects through tools for executing menu items, selecting objects, managing packages, running tests, and accessing resources.
An implementation of the Model Context Protocol for Unity Editor, allowing AI assistants to interact with Unity projects through tools for executing menu items, selecting objects, managing packages, running tests, and accessing resources.
,/(/. *(/,
*/(((((/. *((((((*.
.*((((((((((/. *((((((((((/.
./((((((((((((((/ *((((((((((((((/,
,/(((((((((((((/*. */(((((((((((((/*.
,%%#((/((((((* ,/(((((/(#&@@(
,%%##%%##((((((/*. ,/((((/(#&@@@@@@(
,%%######%%##((/(((/*. .*/(((//(%@@@@@@@@@@@(
,%%####%#(%%#%%##((/((((((((//#&@@@@@@&@@@@@@@@(
,%%####%( /#%#%%%##(//(#@@@@@@@%, #@@@@@@@(
,%%####%( *#%###%@@@@@@( #@@@@@@@(
,%%####%( #%#%@@@@, #@@@@@@@(
,%%##%%%( #%#%@@@@, #@@@@@@@(
,%%%#* #%#%@@@@, *%@@@(
., ,/##*. #%#%@@@@, ./&@#* *`
,/#%#####%%#/, #%#%@@@@, ,/&@@@@@@@@@&.
`*#########%%%%###%@@@@@@@@@@@@@@@@@@&*´
`*%%###########%@@@@@@@@@@@@@@&*´
`*%%%######%@@@@@@@@@@&*´
`*#%%##%@@@@@&*´
`*%#%@&*´
███╗ ███╗ ██████╗██████╗ ██╗ ██╗███╗ ██╗██╗████████╗██╗ ██╗
████╗ ████║██╔════╝██╔══██╗ ██║ ██║████╗ ██║██║╚══██╔══╝╚██╗ ██╔╝
██╔████╔██║██║ ██████╔╝ ██║ ██║██╔██╗ ██║██║ ██║ ╚████╔╝
██║╚██╔╝██║██║ ██╔═══╝ ██║ ██║██║╚██╗██║██║ ██║ ╚██╔╝
██║ ╚═╝ ██║╚██████╗██║ ╚██████╔╝██║ ╚████║██║ ██║ ██║
╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═════╝ ╚═╝ ╚═══╝╚═╝ ╚═╝ ╚═╝
MCP Unity is an implementation of the Model Context Protocol for Unity Editor, allowing AI assistants to interact with your Unity projects. This package provides a bridge between Unity and a Node.js server that implements the MCP protocol, enabling AI agents like Claude, Windsurf, and Cursor to execute operations within the Unity Editor.
This MCP currently provides the following tools:
This MCP currently provides the following resources:
Installing this MCP Unity Server is a multi-step process:
https://github.com/CoderGamester/mcp-unity.git
To run MCP Unity server, you'll need to have Node.js 18 or later installed on your computer:
node --version
brew install node@18
5. Verify the installation by opening Terminal and running:
node --version
Currently not available
{
"mcpServers": {
"mcp-unity": {
"command": "node",
"args": [
"ABSOLUTE/PATH/TO/mcp-unity/Server/build/index.js"
],
"env": {
"UNITY_PORT": "8090"
}
}
}
}
When the AI client connects to the WebSocket server, it will automatically show in the green box in the window
By default, the WebSocket server runs on port 8090. You can change this port in two ways:
$env:UNITY_PORT = "8090"
- Command Prompt/Terminal
set UNITY_PORT=8090
2. Restart the Node.js server
3. Click again on "Start Server" to reconnect the Unity Editor web socket to the Node.js MCP Server
cd ABSOLUTE/PATH/TO/mcp-unity/Server
2. Install dependencies:
npm install
3. Build the server:
npm run build
4. Run the server:
node build/index.js
$env:UNITY_PORT=8090; npx @modelcontextprotocol/inspector node Server/build/index.js
- Command Prompt/Terminal
set UNITY_PORT=8090 && npx @modelcontextprotocol/inspector node Server/build/index.js
Don't forget to shutdown the server with `Ctrl + C` before closing the terminal or debugging it with the [MCP Inspector](https://github.com/modelcontextprotocol/inspector).
$env:LOGGING = "true"
$env:LOGGING_FILE = "true"
- Command Prompt/Terminal
set LOGGING=true
set LOGGING_FILE=true
If you have any questions or need support, please open an issue on this repository.
Alternative you can reach out on:
-
- Discord: gamester7178
Contributions are welcome! Please feel free to submit a Pull Request or open an Issue with your request.
Commit your changes following the Conventional Commits format.
This project is under MIT License
[
{
"description": "Executes a Unity menu item by path",
"inputSchema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"menuPath": {
"description": "The path to the menu item to execute (e.g. "GameObject/Create Empty")",
"type": "string"
}
},
"required": [
"menuPath"
],
"type": "object"
},
"name": "execute_menu_item"
},
{
"description": "Sets the selected object in the Unity editor by path or ID",
"inputSchema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"objectPath": {
"description": "The path or ID of the object to select (e.g. "Main Camera" or a Unity object ID)",
"type": "string"
}
},
"required": [
"objectPath"
],
"type": "object"
},
"name": "select_object"
},
{
"description": "Manages packages in the Unity Package Manager",
"inputSchema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"branch": {
"description": "The branch to use for GitHub packages (optional)",
"type": "string"
},
"methodSource": {
"description": "The method source to use (registry, github, or disk) to add the package",
"type": "string"
},
"packageName": {
"description": "The package name to add from Unity registry (e.g. com.unity.textmeshpro)",
"type": "string"
},
"path": {
"description": "The path to use (folder path for disk method or subfolder for GitHub)",
"type": "string"
},
"repositoryUrl": {
"description": "The GitHub repository URL (e.g. https://github.com/username/repo.git)",
"type": "string"
},
"version": {
"description": "The version to use for registry packages (optional)",
"type": "string"
}
},
"required": [
"methodSource"
],
"type": "object"
},
"name": "package_manager"
},
{
"description": "Runs Unity's Test Runner tests",
"inputSchema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"testFilter": {
"description": "Optional test filter (e.g. specific test name or namespace)",
"type": "string"
},
"testMode": {
"description": "The test mode to run (EditMode, PlayMode, or All)",
"type": "string"
}
},
"type": "object"
},
"name": "run_tests"
},
{
"description": "Sends a message to the Unity console",
"inputSchema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"message": {
"description": "The message to display in the Unity console",
"type": "string"
},
"type": {
"description": "The type of message (info, warning, error)",
"type": "string"
}
},
"required": [
"message"
],
"type": "object"
},
"name": "notify_message"
}
]