Skip to main content
Glama

Stars Forks Issues License: MIT

CI Unity 6 Python 3.10+ Ollama LM Studio MCP

Connect the AI models running on your own computer to the Unity Editor. No cloud model, no API key, no per-token bill.

Quick start · Tools · Modest PCs · Security · Troubleshooting


✨ Features

Feature

What you get

🧠

Built for local models

18 tools with flat schemas, short replies, forgiving arguments and errors that say what to do next

🔌

Ollama and LM Studio

LM Studio connects over MCP. For Ollama, a built-in terminal chat does the MCP part

🎮

Real editor control

Create, move, color and inspect objects, components, properties and prefabs

📝

Scripts with feedback

The model writes C#, waits for the compile and reads the errors

↩️

Easy undo

Each scene edit is a single Ctrl+Z

✋

You stay in charge

The chat asks before every change. Read-only mode is one checkbox in Unity

🔒

Stays on your machine

The editor listens only on 127.0.0.1 and requires a random token

NOTE

This is an early release (0.1). The whole chain has been tested on Windows with Unity 6000.6.8f1 and Ollama. CI runs the Python tests on Windows, macOS and Linux, but LM Studio and the Unity package on macOS or Linux have not been tested yet, soreports are welcome.

Related MCP server: MCP Unity Editor

🧩 How it works

flowchart LR
    M["🧠 Your model<br/>Ollama or LM Studio"] <--> H["MCP host<br/>LM Studio, or the built-in chat"]
    H <-- "MCP" --> S["unity-local-mcp<br/>Python server"]
    S <-- "127.0.0.1" --> U["🎮 Unity Editor<br/>bridge package"]

The repository holds both halves: the Unity package in unity-package/ and the Python server in src/.

🚀 Quick start

What you need

  • Unity 6

  • uv and Git (uv fetches Python for you)

  • Ollama or LM Studio 0.3.17 or newer

  • A model that supports tool calling

1. Add the package to Unity

In Unity, open Window → Package Manager → + → Install package from git URL and paste:

https://github.com/isaiahagi/unity-local-mcp.git?path=/unity-package

Then open Window → Unity Local MCP. It should say Running on 127.0.0.1:8737 (the port moves up if that one is taken).

2. Connect your model

Ollama runs models but does not connect to MCP servers by itself, so this project includes a chat that does.

ollama pull qwen3:4b-instruct
uvx --from git+https://github.com/isaiahagi/unity-local-mcp unity-local-mcp chat --model qwen3:4b-instruct

A session looks like this:

you> Create a red cube named Player at position 0,1,0 and then add a Rigidbody to it.
  .. waiting for the model
  .. replied in 24s
  -> create_object name=Player shape=cube position=0,1,0 color=red
     Allow create_object? [y]es / [N]o / [a]lways for this tool: y
     ok: {"created":"Player","position":"0,1,0", ...}
  .. waiting for the model
  .. replied in 6s
  -> add_component target=Player component=Rigidbody
     Allow add_component? [y]es / [N]o / [a]lways for this tool: y
     ok: {"added":"Rigidbody","to":"Player"}

Leave out --model to pick from your installed models that can call tools. Type /reset to clear the conversation and /exit to quit.

  1. In LM Studio, open the Program tab in the right sidebar, then Install → Edit mcp.json.

  2. Add the unity server (the Unity window has a button that copies this):

{
  "mcpServers": {
    "unity": {
      "command": "uvx",
      "args": ["--from", "git+https://github.com/isaiahagi/unity-local-mcp", "unity-local-mcp"]
    }
  }
}
  1. Load a tool-capable model, enable the unity server and ask it to change your scene.

If you prefer the terminal, start LM Studio's local server and use the built-in chat instead:

uvx --from git+https://github.com/isaiahagi/unity-local-mcp unity-local-mcp chat --provider lmstudio

3. Check the connection

uvx --from git+https://github.com/isaiahagi/unity-local-mcp unity-local-mcp doctor

It reports whether Unity, Ollama and LM Studio can be reached.

🧰 Tools

Toolset

Tool

What it does

inspect

get_editor_state

Unity version, scene, play mode, compile status, selection

get_hierarchy

Tree of GameObjects with their components

find_objects

Search by name, component or tag

get_object

Transform, components and property values

edit

create_object

Empty, primitive, camera, light or prefab, with transform and color

update_object

Rename, move, rotate, scale, reparent, enable or tag

delete_object

Delete an object and its children

add_component

Add a built-in component or your own script

remove_component

Remove a component

set_property

Set a serialized property, including object and asset references

set_color

Color an object, sprite or light

create_prefab

Save a scene object as a prefab and link it

scripts

list_assets

Search project files

read_script

Read a text file

write_script

Create or replace a C# file under Assets/

editor

get_console_logs

Console messages and compile errors

set_play_mode

Play, stop, pause

save_scene

Save the scene

Objects are addressed by path, such as Enemies/Orc[1], which small models handle better than numeric IDs.

🐢 Running on a modest PC

You don't need a GPU, but you do need some patience. These are single measurements from an 8-core desktop CPU with 16 GB of RAM and no dedicated graphics card, with Unity open, running qwen3:4b-instruct (about 3 GB in memory) at --num-ctx 4096:

Request

Time

First reply with every tool enabled (17 at the time), including loading the model

55 s (40 s of it reading the prompt, mostly tool definitions)

"Create a red cube named Player and add a Rigidbody", model already loaded

38 s

"Which objects are in the scene?" with read-only tools, including loading the model

22 s

To make it faster:

  • Use a small instruct model. Thinking models write a lot of text before they act. Choose an instruct variant, or try --no-think.

  • Offer fewer tools. --toolsets inspect,edit shrinks the first prompt from about 1,860 to 1,370 tokens.

  • Use a smaller context with --num-ctx 4096. The chat trims old results to fit.

  • Keep the model loaded. Ollama unloads idle models. Set the OLLAMA_KEEP_ALIVE environment variable (for example 30m) before starting Ollama.

  • Ask for one thing at a time, naming the objects you mean.

  • Watch it work. Replies appear as they are generated.

  • Allow more time with --timeout 1200 if the first words take longer than ten minutes.

⚙️ Options

Option

Applies to

Meaning

--toolsets inspect,edit,scripts,editor

serve, chat

Expose only these groups

--read-only

serve, chat

Expose only tools that change nothing

--project NAME

serve, chat, doctor

Choose an editor when several are open

--provider ollama|lmstudio

chat

Model server (default ollama)

--model NAME

chat

Model to use

--url URL

chat

Model server on another address

--api-key TOKEN

chat

LM Studio API token, or set LM_API_TOKEN

--num-ctx N

chat

Context length (default 8192). For LM Studio, match the app's setting

--think / --no-think

chat

Ollama thinking mode

--max-steps N

chat

Model steps allowed per request (default 12)

--timeout SECONDS

chat

Longest silence from the model server (default 600)

--no-stream

chat

Wait for whole replies instead of showing text as it arrives

--prompt TEXT

chat

Run one request and exit

--yes

chat

Approve every change without asking

The server also reads UNITY_MCP_TOOLSETS, UNITY_MCP_READ_ONLY and UNITY_MCP_PROJECT. In LM Studio, add options to args, for example "--toolsets", "inspect,edit".

🔒 Security

WARNING

A script that a model writes runs with your user account's permissions once Unity compiles it. Read it before you approve it, and keep your project under version control.

  • The editor accepts connections from 127.0.0.1 only. Every request needs a random token, stored in ~/.unity-local-mcp/instances/ while Unity is open. Programs running as your user can read it.

  • Models can write only .cs scripts and .prefab files, under Assets/. A replaced file is first copied to Library/UnityLocalMcp/Backups/. Reading is limited to text files under Assets/ and Packages/.

  • Window → Unity Local MCP has switches for Read-only and Allow writing scripts. Unity enforces them whatever the client asks.

  • The built-in chat asks before each change unless you pass --yes or answer always. In LM Studio, tool permissions are controlled by LM Studio.

  • Undo covers scene edits. It does not cover files or prefab links: new scripts, prefabs and the color materials in Assets/UnityLocalMcp/Materials/ stay in your project.

🩺 Troubleshooting

Problem

Try this

No running Unity Editor found

Open the project and check Window → Unity Local MCP says Running. Then run doctor

Unity is busy or not answering

Close any open Unity dialog, and wait for imports or compiling to finish

The Unity window is missing

Fix compile errors in the Console, and check the package appears in Package Manager

Cannot reach Ollama

Start the Ollama app or run ollama serve

cannot call tools

Pick another model. doctor lists which of your Ollama models can

The model describes steps but changes nothing

Name the objects you mean, or try a larger model

The model forgets what you asked

Raise --num-ctx, or /reset between tasks

LM Studio cannot start the server

Replace uvx with its full path (where uvx on Windows, which uvx elsewhere)

Changes made while Unity is in Play mode are lost when it stops, as with manual edits.

🧪 Development

git clone https://github.com/isaiahagi/unity-local-mcp.git
cd unity-local-mcp
uv sync
uv run pytest

The tests use stand-ins for Unity and the model servers, so neither needs to be running.

To work on the Unity package, use Package Manager → + → Install package from disk and pick unity-package/package.json. To point LM Studio at your clone, use "command": "uv" with "args": ["--directory", "/path/to/unity-local-mcp", "run", "unity-local-mcp"].

🗺️ Roadmap

  • Test LM Studio, and the Unity package on macOS and Linux

  • Scene screenshots for vision models

  • Edit materials

  • Publish to PyPI

🤝 Contributing

Issues and pull requests are welcome. For a bug, include your Unity version, model, and the output of doctor.

⭐ Star history

If this saves you time, a star helps other people find it.

📄 License

MIT

Not affiliated with or endorsed by Unity Technologies, Ollama or LM Studio. Product names belong to their owners.

Available Tools

18 tools
add_componentC

Add a component, e.g. Rigidbody, AudioSource or your own script class name.

Inputs: target (required), component (required).

create_objectB

Create a GameObject. position, rotation and scale are relative to the parent.

Inputs: name (required), color, scale, shape, +4 more.

create_prefabC
Destructive

Save a scene object as a prefab file and link the object to it.

Inputs: path (required), target (required), overwrite.

delete_objectB
Destructive

Delete an object and its children (undo with Ctrl+Z in Unity).

Inputs: target (required).

find_objectsB
Read-only

Search scene objects by part of a name, component type and/or tag.

Inputs: tag, name, limit, component.

get_console_logsB
Read-only

Recent Console messages and compile errors. Waits for compiling to finish.

Inputs: level, limit.

get_editor_stateA
Read-only

Unity version, open scene, play mode, compile status and selected objects.

Inputs: no named parameters.

get_hierarchyB
Read-only

Tree of GameObjects in the open scene. Set parent to see only its children.

Inputs: depth, limit, parent.

get_objectB
Read-only

One object's transform and components. Set component to list its property names and values.

Inputs: target (required), component.

list_assetsC
Read-only

Search project files by name and type.

Inputs: type, limit, query, folder.

read_scriptC
Read-only

Read a text file such as Assets/Scripts/Player.cs.

Inputs: path (required), max_lines, start_line.

remove_componentC
Destructive

Remove a component from an object.

Inputs: target (required), component (required).

save_sceneC

Save the open scene.

Inputs: path.

set_colorC

Change the color of an object, sprite or light.

Inputs: color (required), target (required).

set_play_modeC

Start, stop or pause Play mode.

Inputs: action (required).

set_propertyC

Set one component property, e.g. component=Rigidbody property=mass value=5.

Inputs: value (required), target (required), property (required), component (required).

update_objectA

Rename, move, rotate, scale, reparent, enable/disable or tag an object. Only set what changes.

Inputs: target (required), tag, scale, active, +4 more.

write_scriptA
Destructive

Create a C# file under Assets/. Send the whole file. Set overwrite=true to replace one.

Inputs: path (required), contents (required), overwrite.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3.2/5.0

    Scored across 18 tools

    Disambiguation4/5

    Most tools target a clearly distinct resource+action: hierarchy inspection (get_hierarchy, find_objects, get_object), mutation (create_object, update_object, delete_object), components (add_component, remove_component, set_property), and editor control (get_editor_state, set_play_mode, save_scene). The only soft overlaps are set_color versus set_property (color is a special case of a property) and update_object versus set_property for transform-like changes, but the descriptions steer an agent reasonably well.

    Naming Consistency5/5

    Every tool follows a strict snake_case verb_noun pattern (delete_object, list_assets, get_editor_state, add_component, set_property, write_script, set_play_mode, save_scene). Verb choice is also semantically consistent (get_ for single-item reads, list_/find_ for searches, set_ for single-value mutations).

    Tool Count4/5

    18 tools is at the upper end but each maps to a real Unity editor capability across scene hierarchy, components, properties, prefabs, scripts, console, and play mode. A few could theoretically be folded together (set_color into set_property), but nothing feels like filler.

    Completeness4/5

    Core lifecycle is well covered: inspect state/hierarchy, create/update/delete objects, add/remove components, edit properties, author scripts, read logs, drive play mode, and save the scene. Gaps are the prefab lifecycle (create_prefab exists but no instantiate/apply/revert) and asset management beyond listing (no create folder, delete, move, or import), which agents can partially work around but not fully.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables AI assistants to interact with Unity Editor, managing scenes, game objects, animations, materials, scripts, and more via natural language commands.
      2
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables supported AI clients to connect to and automate the Unity Editor, covering scene and GameObject manipulation, asset and material operations, script creation and validation, testing, builds, screenshots, and editor-state inspection. It supports HTTP and stdio transports and ships client configuration helpers for Unity 2021.3+ on Windows, Linux, and macOS.
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables an AI agent to compile code and read errors, build and modify scenes, inspect objects, take screenshots, and run tests directly inside the Unity Editor through a single C# package with no separate Python or Node process.
      1
      MIT