Skip to content

[BUG] - MCP tools fail with JSON parsing error - parameters sent without proper JSON formatting #1016

Description

@AlonDan

Intro
Just to be clear I'm not a programmer, this is a BUG I ran into when I worked within Zoo-Code trying to use Godot-MCP with Godot 4.7 and since it works fine with Open Code (no bugs), I realize it's a Zoo-Code related issue, I used Gemini to help me create the issue, I hope it helps 👇


EDIT - Root cause found and fixed:
Instead of deleting the issue, I decided to update in case anyone else will run into similar case:

The bug I encountered was NOT in Zoo Code's JSON formatting. The JSON sent was valid (e.g. {"scene_path":"scenes/test.tscn","root_node_type":"ColorRect"}).

The real bug was in godot-mcp's JavaScript code (build/index.js):

The executeOperation() function used exec() with shell string concatenation, wrapping the JSON in single quotes:
const cmd = [..., '${escapedParams}'].join(' ');

On Windows, single quotes are NOT treated as string delimiters by CMD/PowerShell. This caused the JSON to be split incorrectly before reaching Godot, resulting in the error:
[ERROR] Failed to parse JSON parameters: '{scene_path:scenes/test.tscn,...}'

The fix: Replace exec() with spawn() and pass parameters as an array (no shell escaping needed):
const { spawn } = await import('child_process');
const child = spawn(this.godotPath, args, { stdio: ['pipe', 'pipe', 'pipe'] });

Status: Fixed locally. The godot-mcp server should be updated to use spawn() instead of exec() for all Godot commands on Windows.


Describe the bug

When using MCP tools that require parameters (such as create_scene, get_uid, update_project_uids), the tools fail with a JSON parsing error. The root cause is that Zoo Code sends JSON parameters without double quotes on the keys, which is invalid JSON format.

Expected JSON format:

{"scene_path": "scenes/test.tscn", "root_node_type": "Node2D"}

What Zoo Code actually sends:

{scene_path:scenes/test.tscn,root_node_type:Node2D}

This causes Godot-MCP Server to fail with:

[ERROR] Failed to parse JSON parameters: '{scene_path:scenes/test.tscn,...}'
[ERROR] JSON Error: Unexpected character at line 0

To Reproduce

Steps to reproduce the behavior:

  1. Install Godot 4.7 and Godot-MCP server via npm
  2. Create a new Godot project
  3. Use the create_scene MCP tool with parameters (e.g., scene_path, root_node_type)
  4. Observe the JSON parsing error in the output

Expected behavior

MCP tools should send properly formatted JSON with double quotes on all keys and values, as per JSON specification (RFC 8259).

Screenshots

N/A (text-based error)

Video

N/A (user does not have video recording of the bug)

What version of zoo are you running

3.72.0

Additional context

  • Godot version: 4.7.stable.official
  • Godot-MCP version: 3.1.0
  • Operating System: Windows 11 Pro
  • Hardware: Intel Core Ultra 9 285K | RTX 5090 | 96 GB RAM
  • The Godot-MCP Server correctly expects valid JSON (see godot_operations.gd line 43: json.parse(params_json))
  • The bug is in the client-side (Zoo Code) that formats JSON incorrectly before sending to the MCP server
  • Affected tools: create_scene, get_uid, update_project_uids
  • Working tools (no parameters needed): get_godot_version, get_project_info, run_project, get_debug_output, stop_project, list_projects

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions