Description
read_console with types: ["error"] (or even types: ["all"]) returns zero entries when C# compilation errors exist. Compiler diagnostics (error CS####) are written to Editor.log and appear in the Unity Console UI, but are not returned by the read_console tool.
This means AI agents have no MCP-based way to detect compilation failures after editing scripts -- arguably the single most important feedback loop for code-editing agents.
Steps to Reproduce
- Introduce a deliberate C# compilation error (e.g., call a method with wrong argument count)
- Call
refresh_unity with compile: "request", wait_for_ready: true
- Wait 15 seconds for compilation to complete
- Call
read_console with action: "get", types: ["error"], count: 50
- Result: Returns
{"success": true} with zero entries
- Call
read_console with types: ["all"] -- still zero entries
- Check
Editor.log directly -- the error CS#### lines are there
Expected Behavior
read_console should return compilation errors (e.g., error CS1501: No overload for method 'Get' takes 3 arguments) as error-type entries.
Root Cause Analysis
Looking at the ReadConsole.cs source, it uses LogEntries.StartGettingEntries / GetEntryInternal / EndGettingEntries via reflection. This reads Unity's internal console log buffer.
The issue appears to be that when compilation fails, the domain reload does not complete, so:
- The
LogEntries buffer may not contain the compiler diagnostics at all, or
- The entries exist but the MCP server (running in the editor domain) may be in a state where it can't read them properly
The InferTypeFromMessage method in ReadConsole.cs does have logic to detect "error CS" patterns, so the filtering logic is correct -- the entries simply aren't present in the LogEntries buffer.
Current Workaround
Read the Unity Editor.log file directly:
Get-Content "$env:LOCALAPPDATA\Unity\Editor\Editor.log" -Tail 300 | Select-String -Pattern "error CS\d{4}"
Suggested Fix
Consider using UnityEditor.Compilation.CompilationPipeline to capture compilation results separately. For example:
CompilationPipeline.assemblyCompilationFinished event to capture per-assembly results
- Store compilation diagnostics in a separate buffer that
read_console (or a new tool/resource) can query
- Alternatively, expose compilation status in the
editor_state resource (the compilation field is currently always null)
Environment
- Unity MCP: v9.4.7
- Unity: 6 (6000.x)
- OS: Windows 10
- Client: Cursor IDE
Description
read_consolewithtypes: ["error"](or eventypes: ["all"]) returns zero entries when C# compilation errors exist. Compiler diagnostics (error CS####) are written toEditor.logand appear in the Unity Console UI, but are not returned by theread_consoletool.This means AI agents have no MCP-based way to detect compilation failures after editing scripts -- arguably the single most important feedback loop for code-editing agents.
Steps to Reproduce
refresh_unitywithcompile: "request",wait_for_ready: trueread_consolewithaction: "get",types: ["error"],count: 50{"success": true}with zero entriesread_consolewithtypes: ["all"]-- still zero entriesEditor.logdirectly -- theerror CS####lines are thereExpected Behavior
read_consoleshould return compilation errors (e.g.,error CS1501: No overload for method 'Get' takes 3 arguments) as error-type entries.Root Cause Analysis
Looking at the
ReadConsole.cssource, it usesLogEntries.StartGettingEntries/GetEntryInternal/EndGettingEntriesvia reflection. This reads Unity's internal console log buffer.The issue appears to be that when compilation fails, the domain reload does not complete, so:
LogEntriesbuffer may not contain the compiler diagnostics at all, orThe
InferTypeFromMessagemethod inReadConsole.csdoes have logic to detect"error CS"patterns, so the filtering logic is correct -- the entries simply aren't present in theLogEntriesbuffer.Current Workaround
Read the Unity Editor.log file directly:
Suggested Fix
Consider using
UnityEditor.Compilation.CompilationPipelineto capture compilation results separately. For example:CompilationPipeline.assemblyCompilationFinishedevent to capture per-assembly resultsread_console(or a new tool/resource) can queryeditor_stateresource (thecompilationfield is currently alwaysnull)Environment