Bug Description
The run_tests tool's test filtering (test_names, group_names, category_names, assembly_names) silently fails — all tests run instead of the filtered subset. This affects any MCP client sending parameters in snake_case (which matches the tool's schema).
Root Causes
1. Snake_case parameter names not recognized
The MCP tool schema defines parameters in snake_case (test_names, group_names, etc.), but GetFilterOptions() in RunTests.cs only reads camelCase keys:
// Line ~149: only checks camelCase
var testNames = ParseStringArray("testNames");
Since MCP clients send test_names (matching the schema), the lookup returns null and no filter is applied.
Fix: Add snake_case fallback to each ParseStringArray call:
var testNames = ParseStringArray("testNames", "test_names");
2. Double-serialized arrays not handled
The MCP bridge serializes array parameters as a stringified JSON array inside an outer array. For example, test_names: ["MyTest"] arrives as:
{"test_names": ["[\"MyTest\"]"]}
The ParseStringArray method's Array branch doesn't detect this pattern, so it tries to extract "[\"MyTest\"]" as a test name string, which never matches any test.
Fix: Add detection for single-element arrays where the element is a stringified JSON array:
if (array.Count == 1 && array[0].Type == JTokenType.String)
{
var inner = array[0].ToString().Trim();
if (inner.StartsWith("[") && inner.EndsWith("]"))
{
try { array = JArray.Parse(inner); }
catch { /* use original array */ }
}
}
3. Same snake_case issue in GetTestJob.cs
GetTestJob.HandleCommand() reads includeDetails and includeFailedTests but the schema uses include_details and include_failed_tests.
Affected Files
Editor/Tools/RunTests.cs — GetFilterOptions() and HandleCommand()
Editor/Tools/GetTestJob.cs — HandleCommand()
Environment
- Unity 6.2 (6000.3)
- unity-mcp v9.4.0
- Claude Code MCP client
Bug Description
The
run_teststool's test filtering (test_names,group_names,category_names,assembly_names) silently fails — all tests run instead of the filtered subset. This affects any MCP client sending parameters in snake_case (which matches the tool's schema).Root Causes
1. Snake_case parameter names not recognized
The MCP tool schema defines parameters in snake_case (
test_names,group_names, etc.), butGetFilterOptions()inRunTests.csonly reads camelCase keys:Since MCP clients send
test_names(matching the schema), the lookup returns null and no filter is applied.Fix: Add snake_case fallback to each
ParseStringArraycall:2. Double-serialized arrays not handled
The MCP bridge serializes array parameters as a stringified JSON array inside an outer array. For example,
test_names: ["MyTest"]arrives as:{"test_names": ["[\"MyTest\"]"]}The
ParseStringArraymethod's Array branch doesn't detect this pattern, so it tries to extract"[\"MyTest\"]"as a test name string, which never matches any test.Fix: Add detection for single-element arrays where the element is a stringified JSON array:
3. Same snake_case issue in GetTestJob.cs
GetTestJob.HandleCommand()readsincludeDetailsandincludeFailedTestsbut the schema usesinclude_detailsandinclude_failed_tests.Affected Files
Editor/Tools/RunTests.cs—GetFilterOptions()andHandleCommand()Editor/Tools/GetTestJob.cs—HandleCommand()Environment