execute_csharp
Execute C# code dynamically in the Unity Editor context. The code has access to UnityEngine, UnityEditor, and project assemblies.
Category: Code
Parameters
Section titled “Parameters”| 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. |
Example call
Section titled “Example call”The arguments below are the required ones; add the optional ones you need.
{ "name": "execute_csharp", "arguments": { "code": "…" }}In SuperSave mode
Section titled “In SuperSave mode”When Unity runs with NANORA_MCP_SUPERSAVE=1, call it through the execute meta tool: {"tool": "execute_csharp", "args": { … }}. See SuperSave mode.
Source
Section titled “Source”Generated from Assets/NanoraUnityMCP/Editor/Tools/ExecuteCSharpTool.cs (version 1.2.1). The client receives the same schema from tools/list.