Skip to content
Development
Skill

/unity-skill-create

Create a new skill (MCP tool) for the Unity Editor by writing a C# (.cs) file that Unity compiles into the project. After compilation the new tool becomes callable through MCP. The file must be a partial class decorated with [AiToolType], each tool method must be decorated with

From plugin
ivanmurzak-unity-mcp
3.8k80 skills
Install
$ npx -y skills add IvanMurzak/Unity-MCP --skill unity-skill-create --agent claude-code

How it fires

How this skill gets triggered: by you, by Claude, or both.

  • Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
  • You can call itInvoke it directly when you want it.
  • Slash command/unity-skill-create

Context preview

The summary Claude sees to decide when to auto-load this skill.

Create a new skill (MCP tool) for the Unity Editor by writing a C# (.cs) file that Unity compiles into the project. After compilation the new tool becomes callable through MCP. The file must be a partial class decorated with [AiToolType], each tool method must be decorated with

SKILL.md

unity-skill-create.SKILL.md
name: unity-skill-create
description: Create a new skill (MCP tool) for the Unity Editor by writing a C# (.cs) file that Unity compiles into the project. After compilation the new tool becomes callable through MCP. The file must be a partial class decorated with [AiToolType], each tool method must be decorated with [AiTool], the class name should match the file name, all Unity API calls must run via com.IvanMurzak.ReflectorNet.Utils.MainThread.Instance.Run(), and the method should either return a structured data model (for parseable output) or void (for side-effect-only operations). See the body of this skill for a full sample and best-practice notes.

Skill (Tool) / Create

Full sample

#nullable enable
using System;
using System.ComponentModel;
using com.IvanMurzak.McpPlugin;
using com.IvanMurzak.ReflectorNet.Utils;
using com.IvanMurzak.Unity.MCP.Editor.Utils;
using AIGD;
using UnityEditor;
using UnityEngine;

namespace com.IvanMurzak.Unity.MCP.Editor.API
{
    [AiToolType]
    public partial class Tool_Sample
    {
        [AiTool("sample-get", Title = "Sample / Get")]
        [Description("Finds a GameObject and returns its ref data.")]
        public GameObjectRef Get
        (
            [Description("Name of the GameObject to find.")]
            string name
        )
        {
            return MainThread.Instance.Run(() =>
            {
                var go = GameObject.Find(name)
                    ?? throw new ArgumentException($"GameObject '{name}' not found.", nameof(name));

                return new GameObjectRef(go);
            });
        }

        [AiTool("sample-rename", Title = "Sample / Rename")]
        [Description("Renames a GameObject.")]
        public void Rename
        (
            [Description("Current name of the GameObject.")]
            string name,
            [Description("New name to assign.")]
            string newName
        )
        {
            MainThread.Instance.Run(() =>
            {
                var go = GameObject.Find(name)
                    ?? throw new ArgumentException($"GameObject '{name}' not found.", nameof(name));

                go.name = newName;
                EditorUtility.SetDirty(go);
                AssetDatabase.Refresh(ImportAssetOptions.ForceSynchronousImport);
                EditorUtils.RepaintAllEditorWindows();
            });
        }
    }
}

Suggestions

Refresh UI after visual changes

If the skill modifies anything visually in the Unity Editor (GameObjects, components, materials, etc.), call these two lines at the end of the tool method to apply changes to the UI immediately:

AssetDatabase.Refresh(ImportAssetOptions.ForceSynchronousImport);
EditorUtils.RepaintAllEditorWindows();

Refresh AssetDatabase after asset or script changes

If the skill creates, modifies, or deletes any asset file or .cs script on disk outside of Unity API, call this inside a `MainThread.Instance.Run()` block to ensure Unity picks up the changes:

MainThread.Instance.Run(() =>
{
    AssetDatabase.Refresh(ImportAssetOptions.ForceSynchronousImport);
});

Use processing mechanic for long-running or domain-reload operations

Some operations take time to complete and may trigger a Unity domain reload (e.g. writing a .cs script, switching play mode, running tests, adding a package). In these cases the tool must NOT block and wait — instead it must: 1. Accept a `[RequestID] string? requestId` parameter. 2. Return `ResponseCallTool.Processing("...").SetRequestID(requestId)` immediately. 3. Schedule the actual work asynchronously via `MainThread.Instance.RunAsync(async () => { await Task.Yield(); ... })`. 4. When the operation finishes, send the final result by calling:

_ = UnityMcpPluginEditor.NotifyToolRequestCompleted(new RequestToolCompletedData
{
    RequestId = requestId,
    Result = ResponseCallTool.Success("Operation completed.").SetRequestID(requestId)
});

If the operation may survive a domain reload (e.g. a .cs file was saved and Unity will recompile), use `ScriptUtils.SchedulePostCompilationNotification(requestId, filePath, operationType)` instead of calling `NotifyToolRequestCompleted` directly — it persists the pending notification to `SessionState` and sends it automatically after the domain reload completes. For package install/removal or other non-compilation domain reloads use `PackageUtils.SchedulePostDomainReloadNotification(requestId, label, action, expectedResult)` the same way.

Return structured data with a typed response

Prefer returning a structured data model over a plain string so the AI can parse individual fields. Data models for MCP tools MUST be declared as TOP-LEVEL types in the `AIGD` namespace - never nested inside the tool class. Place each data model in its own `.cs` file (one type per file) and use `ResponseCallValueTool<T>` as the return type. The flat `AIGD` namespace keeps the auto-generated JSON Schema `$defs` keys short and intuitive for AI agents.

// Tool file (Tool/MyTool.cs) - references the data model from AIGD:
using AIGD;

namespace com.IvanMurzak.Unity.MCP.Editor.API
{
    [AiToolType]
    public partial class Tool_Sample
    {
        public ResponseCallValueTool<MyResult> MyTool(...)
        {
            return ResponseCallValueTool<MyResult>.Success(new MyResult
            {
                Name = go.name,
                InstanceID = go.GetInstanceID()
            }).SetRequestID(requestId);
        }
    }
}

// Data model (Tool/Data/MyResult.cs) - top-level, in AIGD namespace, NOT nested:
namespace AIGD
{
    public class MyResult
    {
        [Description("Name of the GameObject.")]
        public string? Name { get; set; }

        [Description("Unity instance ID of the GameObject.")]
        public int InstanceID { get; set; }
    }
}

For simpler cases that do not need async/processing, you may return the model directly (without `ResponseCallValueTool<T>`) and Unity-MCP w

Read more
Ships withivanmurzak-unity-mcp

Get up and running in three steps: Install plugin — download the .unitypackage installer or run openupm add com.ivanmurzak.unity.mcp Alternative: npx unity-mcp-cli install-plugin ./MyUnityProject — see CLI documentation Pick an AI agent — Claude Code, Claude

Get the whole plugin
Stats
3,845
Stars
349
Forks
Active
Maintenance
C#
Language
Apache-2.0
License
12h ago
Last commit
1y ago
Created

Repo: IvanMurzak/Unity-MCP