Why it matters
scaffold_script is the flagship tool, but several templates produce code that does not compile, and it accepts any name string.
Evidence (mcp-server/server.py)
- No identifier validation:
scaffold_script('monobehaviour', 'My Player', 'Game.Core') emits public class My Player : MonoBehaviour and the path Assets/Scripts/Runtime/My Player.cs.
custom-inspector and property-drawer emit typeof(TARGET_TYPE), a literal placeholder with no parameter to fill it.
state-machine declares public interface IState in the same file as the class, so scaffolding two state machines in one namespace causes CS0101 (duplicate type).
interface does not enforce or suggest the I prefix required by rules/naming-conventions.mdc.
test is placed in Assets/Tests/EditMode with no note that it needs a test asmdef, so it will not compile in a default project.
- README "Features" and the MCP tools table claim scaffolding of "ECS systems" / "ECS templates"; there is no ECS type.
Suggested approach
- Validate
name and namespace against C# identifier rules and reserved keywords; return an error with a suggested fix.
- Add an optional
target_type parameter for inspector and drawer templates.
- Move
IState out of the state-machine template or emit it only on request.
- Add
isystem / ijobentity / baker templates, or remove the ECS claims from README.
- Return companion asmdef JSON for editor and test scaffolds.
- Unit tests that render every template and compile it (see the snippet compile-check issue).
Done when
Every template type, for any valid input, produces code that compiles in a fresh Unity 6 project, and invalid names are rejected with a helpful message.
Why it matters
scaffold_scriptis the flagship tool, but several templates produce code that does not compile, and it accepts anynamestring.Evidence (
mcp-server/server.py)scaffold_script('monobehaviour', 'My Player', 'Game.Core')emitspublic class My Player : MonoBehaviourand the pathAssets/Scripts/Runtime/My Player.cs.custom-inspectorandproperty-draweremittypeof(TARGET_TYPE), a literal placeholder with no parameter to fill it.state-machinedeclarespublic interface IStatein the same file as the class, so scaffolding two state machines in one namespace causes CS0101 (duplicate type).interfacedoes not enforce or suggest theIprefix required byrules/naming-conventions.mdc.testis placed inAssets/Tests/EditModewith no note that it needs a test asmdef, so it will not compile in a default project.Suggested approach
nameandnamespaceagainst C# identifier rules and reserved keywords; return an error with a suggested fix.target_typeparameter for inspector and drawer templates.IStateout of the state-machine template or emit it only on request.isystem/ijobentity/bakertemplates, or remove the ECS claims from README.Done when
Every template type, for any valid input, produces code that compiles in a fresh Unity 6 project, and invalid names are rejected with a helpful message.