Skip to content

Claude having issues editing scripts #183

Closed

Description

@samueltpark

Recently while having Claude edit scripts I've been running into this issue sequence:

  1. Claude tries editing a script
  2. An error message pops up in Unity console (See example image below)
  3. Something goes wrong so Claude automatically tries editing the script again
  4. Still doesnt work so Claude tries recreating the entire script
  5. Fails again and the script gets deleted and Claude says that the script got corrupted

Claude can still successfully:

  • Read scripts
  • Create new scripts
  • Provide you the code changes it was trying to implement for a human to manually update a script with

Console Error Example Image:

Image

Claude of course blames the MCP. What do you guys think? Is this a limitation of the MCP or is there some sort of "MCP Update" that I need?

If additional information/testing is needed let me know.

Activity

  1. Scriptwonder commented on Aug 1, 2025

    @Scriptwonder
    Collaborator

    What are the error messages on the claude side? Can you show us the error response message from the claude side? (if you open the tool window you will see some json messages).

  2. samueltpark commented on Aug 1, 2025

    @samueltpark
    Author

    If you could point me in the direction of the Tool window. I'm using the desktop app and I'm not seeing a Tool window.

    I do see "Response" messages after each failed script edit attempt. I'll try to keep this comment to just the "responses". I can post the actual attempts at editing the scripts if necessary:

    1. Error executing tool manage_script: 4 validation errors for manage_scriptArguments path Field required [type=missing, input_value={'action': 'update', 'nam...e();\n }\n }'}, input_type=dict] For further information visit https://errors.pydantic.dev/2.10/v/missing contents

    Note: The 4 error validation error messages are very similar to each other. One mentions contents, another namespace and another script_type. I can provide all four in full if needed.

    1. {"success": false, "message": "Content is required for the 'update' action."}

    2. Starts like: {"success": true, "message": "Script 'PlayerController.cs' read successfully.", "data": {"path": "Assets/Scripts/PlayerController.cs", "contents": "using UnityEngine;\r\nusing UnityEngine.InputSystem;\r\n\r\npublic class PlayerController : MonoBehaviour\r\n{\r\n public UnitStats stats;\r\n public float moveSpeed;\r\n
      Ends like: {\r\n if (context.performed && turnManager != null)\r\n {\r\n turnManager.EndTurn();\r\n }\r\n }\r\n}", "encodedContents": null, "contentsEncoded": false}}

    Note: Response 3 is really long. I can provide the full thing if necessary.

    1. {"success": false, "message": "Python error managing script: Failed to communicate with Unity: Invalid JSON format"}

    That's the sequence of responses from the first attempt at editing a script.

    Then Claude tries to rewrite the entire method it was trying to edit in the first place. Fails then tries to rewrite the entire script, which also fails. Can provide the responses from the method/entire script rewrite too if necessary.

  3. dsarno commented on Aug 11, 2025

    @dsarno
    Collaborator

    @samueltpark. Can you try again using the just-released 2.0.0 version of the MCP, which has major improvements to setup and mcp bridge/server configuration and stability. You should reinstall the package in Unity because there's a new package name and address.

    1. Open your Unity project.
    2. Go to Window > Package Manager.
    2. Click + -> Add package from git URL....
    Enter:
    https://github.com/CoplayDev/unity-mcp.git?path=/UnityMcpBridge
    
  4. samueltpark commented on Aug 12, 2025

    @samueltpark
    Author

    @dsarno Thanks for the update. Running into similar issues when trying to edit scripts.

    • Feels like it has to do with script size.
    • Creating small scripts works.
    • Reading any size script works.

    I get this log in the Unity console when trying to edit a 400 line script:

    Image
  5. dsarno commented on Aug 12, 2025

    @dsarno
    Collaborator

    @samueltpark thanks for the update. Can you paste in the mcp response message you get during this error? Is it similar to those in comments above?

    Thanks!

    Note to self this seems same as #136

  6. samueltpark commented on Aug 12, 2025

    @samueltpark
    Author

    @dsarno Its purely for convenience and speed. MCP Claude can examine parts of your Unity project beyond just scripts so I've noticed it comes up with code that works well for your specific project rather than code that would generally work for most hypothetical projects. So fewer iterations to get your desired result.

    Its something that nobody would want you guys to toil over with little benefit. It would just be more convenient.

    Edit: Ill get to the MCP error messages as soon as I can.

  7. dsarno commented on Aug 12, 2025

    @dsarno
    Collaborator

    @samueltpark thanks for your thoughtful response. I think I'm a little immersed in the world of Cursor, Windsurf and Claude Code, which can be more focused on script editing so don't need to rely on mcp for that. But for Claude Desktop I can see the utility. Let us take a crack at a simple system to allow parsing of longer files and see if that helps. Thanks!

  8. laurogripa commented on Aug 14, 2025

    @laurogripa

    @dsarno @samueltpark I'm getting the same error with Claude Desktop when the changes are too big. I just tell Claude to separate the changes in smaller chunks and it works normally, but it is a bit cumbersome. I'm using v2.0.1.

  9. added
    duplicate
    on Aug 14, 2025
  10. dsarno commented on Aug 30, 2025

    @dsarno
    Collaborator

    Should be fixed in 3.1.0. Please let us know if you see an improved experience.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicate

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions