Skip to content

execute_csharp

Execute C# code dynamically in the Unity Editor context. The code has access to UnityEngine, UnityEditor, and project assemblies.

Category: Code

Name Type Required Default Description
code string yes C# statements or a full script. Include statement semicolons and use ‘return value;’ to return results. Compiler and runtime failures are returned as errors without retrying the script.
timeout_ms integer 5000 Maximum execution time in milliseconds
include_usings array [] Additional using statements to include
force_roslyn boolean false Force Roslyn compilation mode, disable fallback to reflection. Use for multi-statement code with var declarations.

The arguments below are the required ones; add the optional ones you need.

{
"name": "execute_csharp",
"arguments": {
"code": "…"
}
}

When Unity runs with NANORA_MCP_SUPERSAVE=1, call it through the execute meta tool: {"tool": "execute_csharp", "args": { … }}. See SuperSave mode.

Generated from Assets/NanoraUnityMCP/Editor/Tools/ExecuteCSharpTool.cs (version 1.2.1). The client receives the same schema from tools/list.