{"record":{"id":"48df2e532743d942","repo":"CoplayDev/unity-mcp","slug":"command-tool-name-must-specify-parameters-as-a","errorCode":null,"errorMessage":"Command '{tool_name}' must specify parameters as an object/dict","messagePattern":"Command '(.+?)' must specify parameters as an object/dict","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"Server/src/services/tools/batch_execute.py","lineNumber":116,"sourceCode":"        )\n\n    normalized_commands: list[dict[str, Any]] = []\n    for index, command in enumerate(commands):\n        if not isinstance(command, dict):\n            raise ValueError(\n                f\"Command at index {index} must be an object with 'tool' and 'params' keys\")\n\n        tool_name = command.get(\"tool\")\n        params = command.get(\"params\", {})\n\n        if not tool_name or not isinstance(tool_name, str):\n            raise ValueError(\n                f\"Command at index {index} is missing a valid 'tool' name\")\n\n        if params is None:\n            params = {}\n        if not isinstance(params, dict):\n            raise ValueError(\n                f\"Command '{tool_name}' must specify parameters as an object/dict\")\n\n        if \"unity_instance\" in params:\n            raise ValueError(\n                f\"Command '{tool_name}' at index {index} contains 'unity_instance'. \"\n                \"Per-command instance routing is not supported inside batch_execute. \"\n                \"Set unity_instance on the outer batch_execute call to route the entire batch.\"\n            )\n\n        normalized_commands.append({\n            \"tool\": tool_name,\n            \"params\": params,\n        })\n\n    payload: dict[str, Any] = {\n        \"commands\": normalized_commands,\n    }\n","sourceCodeStart":98,"sourceCodeEnd":134,"githubUrl":"https://github.com/CoplayDev/unity-mcp/blob/c21bf496bca87d54e75bad048563c3adb1782081/Server/src/services/tools/batch_execute.py#L98-L134","documentation":"In batch_execute, each command's 'params' value must be either absent (defaults to {}), None (normalized to {}), or a dict. The check `not isinstance(params, dict)` after the None-normalization rejects lists, strings, numbers, and other non-mapping types. params carries the keyword arguments forwarded to the target Unity tool, so it must be a JSON object. The tool_name is included in the message for context.","triggerScenarios":"A command passes params as a list: {\"tool\": \"x\", \"params\": [1, 2]}; params is a JSON string; params is a number; a caller serializes params as a query string instead of an object.","commonSituations":"An LLM generates params as an array of positional args instead of a kwargs object; a caller confuses params with a list of values; a serialization bug where params is double-encoded as a string.","solutions":["Pass params as a JSON object (dict) of keyword arguments: {\"tool\": \"manage_gameobject\", \"params\": {\"action\": \"create\", \"name\": \"Cube\"}}.","If the tool takes no parameters, omit params or set it to {}.","Check the tool_name in the message to locate which command has the bad params."],"exampleFix":"// before\ncommands=[{\"tool\": \"manage_gameobject\", \"params\": [\"create\", \"Cube\"]}]\n// after\ncommands=[{\"tool\": \"manage_gameobject\", \"params\": {\"action\": \"create\", \"name\": \"Cube\"}}]","handlingStrategy":"type-guard","validationCode":"# Ensure params is a dict (or absent/None) for each command\nfor i, c in enumerate(commands):\n    params = c.get(\"params\", {})\n    if params is None:\n        c[\"params\"] = {}\n    elif not isinstance(params, dict):\n        raise ValueError(f\"Command {i} ({c.get('tool')}) params must be a dict, got {type(params).__name__}\")","typeGuard":"def all_params_are_dicts(commands: list) -> bool:\n    for c in commands:\n        if not isinstance(c, dict):\n            continue\n        p = c.get(\"params\", {})\n        if p is not None and not isinstance(p, dict):\n            return False\n    return True","tryCatchPattern":null,"preventionTips":["Pass params as a JSON object of keyword arguments, never as a list or string.","Omit params or use {} for tools that take no arguments.","Validate params types in your command builder before batching."],"tags":["validation","batch-execute","input-shape","params","mcp-tool"],"backgroundTag":null,"analyzedSha":"c21bf496bca87d54e75bad048563c3adb1782081","analyzedAt":"2026-08-13T17:36:56.095Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}