Copilot stopped accepting symbols in json schema of MCP tools:
[] - arrays
<> - generic classes
+ - nested classes
Related
Upstream cause:
Same-class issues on Unity-MCP:
Related PRs:
ReflectorNet (where the fix likely lives):
⚠️ Warning — custom format is risky
Making a custom format for type names is dangerous because the C# type system has many edge-case shapes. Under-specification causes silent collisions (PR #629 was rejected partly for this reason). Any custom format must be:
- Injective — no two distinct types collapse to the same short name
- Round-trip clean —
GetType(format(t)) == t for every t
C# syntactic shapes any custom format must cover
- Primitive value types (
System.Int32, System.Boolean, System.Double, System.Char)
- Reference types (
System.String, user classes)
- Enum types
- Struct types (user-defined value types)
- Single-dimensional arrays —
T[]
- Multi-dimensional arrays —
T[,], T[,,], T[,,,] (arbitrary rank)
- Jagged arrays —
T[][], T[][][], and mixed T[,][]
- Closed generic types —
List<int>, Dictionary<string, int>
- Open generic type definitions —
List<>, Dictionary<,>
- Nested types —
Outer+Inner
- Nested generic types —
Outer<T>+Inner, Outer<T>+Inner<U>
- Deeply nested generics —
List<Dictionary<string, List<int>>>
- Nullable value types —
System.Nullable<T> / int?
- Tuples —
System.ValueTuple<T1, T2, …>
- Generic type parameters —
T, U (for reflection over unbound generics)
- Assembly-qualified names —
Namespace.Type, Assembly, Version=..., Culture=..., PublicKeyToken=...
- Global-namespace types (no namespace prefix)
- Module types —
<Module> and CLR-internal names
- Types whose FullName contains identifier characters that could collide with the sanitizer's separators (underscores, dots, Unicode letters)
- Pointer types —
int* (unsafe)
- ByRef types —
ref int, out T, in T
- Types from generic type definitions with constraints —
List<T> where T : struct
- Covariant / contravariant generic args —
IEnumerable<out T>, IComparer<in T>
- Types in assemblies with unusual naming — including dotted / dashed / Unicode assembly names
Solution (proposed)
During JSON Schema creation and during parsing type from name in SerializedMember and maybe in TypeUtils classes, handle the problematic symbols by replacing them with something else.
Proposed replacements:
(Alternative vocabularies under consideration — see #676 for related simplification work; both issues touch the same code and should ship together.)
Copilot stopped accepting symbols in json schema of MCP tools:
[]- arrays<>- generic classes+- nested classesRelated
Upstream cause:
uri-referencevalidator in GPT-family clientsSame-class issues on Unity-MCP:
[]appearance (whereGetTypeIdwas introduced)$refrequest (wontfix)inputSchema'#/$defs/...ObjectRef[]' is not a 'uri-reference''#/$defs/System.String[]' is not a 'uri-reference'Related PRs:
JsonSchemaSanitizerrejected on correctness groundsstring[]→List<string>workaroundReflectorNet (where the fix likely lives):
GetTypeIdMaking a custom format for type names is dangerous because the C# type system has many edge-case shapes. Under-specification causes silent collisions (PR #629 was rejected partly for this reason). Any custom format must be:
GetType(format(t)) == tfor everytC# syntactic shapes any custom format must cover
System.Int32,System.Boolean,System.Double,System.Char)System.String, user classes)T[]T[,],T[,,],T[,,,](arbitrary rank)T[][],T[][][], and mixedT[,][]List<int>,Dictionary<string, int>List<>,Dictionary<,>Outer+InnerOuter<T>+Inner,Outer<T>+Inner<U>List<Dictionary<string, List<int>>>System.Nullable<T>/int?System.ValueTuple<T1, T2, …>T,U(for reflection over unbound generics)Namespace.Type, Assembly, Version=..., Culture=..., PublicKeyToken=...<Module>and CLR-internal namesint*(unsafe)ref int,out T,in TList<T> where T : structIEnumerable<out T>,IComparer<in T>Solution (proposed)
During JSON Schema creation and during parsing type from name in
SerializedMemberand maybe inTypeUtilsclasses, handle the problematic symbols by replacing them with something else.Proposed replacements:
+→..[]→__arr(Alternative vocabularies under consideration — see #676 for related simplification work; both issues touch the same code and should ship together.)