CoplayDev/unity-mcp · error · FileNotFoundError

Icon not found: {icon_path}

Error message

Icon not found: {icon_path}

What it means

Raised by generate_mcpb when the supplied icon_path does not exist on disk. The MCPB bundle embeds the icon, so a missing icon file aborts before the temporary build directory is populated.

Source

Thrown at tools/generate_mcpb.py:57


def generate_mcpb(
    version: str,
    output_path: Path,
    icon_path: Path,
) -> Path:
    """Generate MCPB bundle file.

    Args:
        version: Semantic version string (e.g., "9.0.8")
        output_path: Output path for the .mcpb file
        icon_path: Path to the icon file

    Returns:
        Path to the generated .mcpb file
    """
    if not icon_path.exists():
        raise FileNotFoundError(f"Icon not found: {icon_path}")

    with tempfile.TemporaryDirectory() as tmpdir:
        build_dir = Path(tmpdir) / "mcpb-build"
        build_dir.mkdir()

        # Copy icon
        icon_filename = icon_path.name
        shutil.copy2(icon_path, build_dir / icon_filename)

        # Create manifest with version
        manifest = create_manifest(version, icon_filename)
        manifest_path = build_dir / "manifest.json"
        manifest_path.write_text(
            json.dumps(manifest, indent=2, ensure_ascii=False) + "\n",
            encoding="utf-8",
        )

        # Copy LICENSE and README if they exist

View on GitHub (pinned to c21bf496bc)

Solutions

  1. Use the default icon by ensuring docs/images/coplay-logo.png exists, or omit --icon if the CLI defaults to it.
  2. Pass an absolute --icon path to a file you have verified exists.
  3. Restore the icon from git if it was removed: git checkout HEAD -- docs/images/coplay-logo.png.

Example fix

# before
python tools/generate_mcpb.py 9.0.8 --icon ./logo.png  # wrong CWD
# after
python tools/generate_mcpb.py 9.0.8 --icon /abs/path/to/logo.png
Defensive patterns

Strategy: validation

Validate before calling

icon = pathlib.Path(args.icon or DEFAULT_ICON)
if not icon.exists():
    raise SystemExit(f'icon missing: {icon}')

Type guard

def icon_present(p: pathlib.Path) -> bool:
    return p.exists()

Try / catch

try:
    generate_mcpb(version, output_path, icon_path)
except FileNotFoundError as e:
    print(e); sys.exit(1)

Prevention

When it happens

Trigger: generate_mcpb(version, output_path, icon_path) called and icon_path.exists() is false. Default icon is REPO_ROOT/docs/images/coplay-logo.png; a custom --icon path was wrong.

Common situations: Default icon deleted in a rebrand branch; a custom --icon argument points to a relative path from the wrong CWD; icon was moved during docs reorganization.

Related errors


AI-assisted analysis of CoplayDev/unity-mcp@c21bf496bc (2026-08-13). Data as JSON: /api/errors/8c75ae32dc62e3dc. Report an issue: GitHub.