### One-command setup for macOS/Linux Source: https://github.com/ahujasid/mcp-for-blender/blob/main/README.md Installs uv if needed, finds MCP clients, and installs the Blender addon. Existing config is preserved with a .bak backup. ```bash curl -LsSf https://www.mcp-for-blender.com/install.sh | sh ``` -------------------------------- ### Manual setup: install uv on macOS, Linux, and Windows Source: https://github.com/ahujasid/mcp-for-blender/blob/main/README.md Official uv installers. Do not use pip install uv. ```bash # macOS brew install uv # Linux curl -LsSf https://astral.sh/uv/install.sh | sh # Windows winget install --id=astral-sh.uv -e # or, with uv's installer powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex" ``` -------------------------------- ### Usage example for guides module Source: https://github.com/ahujasid/mcp-for-blender Shows how to load a guide body, list all topics with summaries, and iterate over all guides as structured objects. ```python from blender_mcp.guides import get, index, all_guides # Load a guide body body = get("rigging") # List all topics with their summaries print(index()) # All guides as structured objects for topic, guide in all_guides().items(): print(topic, "—", guide.title) ``` -------------------------------- ### One-command setup for Windows PowerShell Source: https://github.com/ahujasid/mcp-for-blender/blob/main/README.md Installs uv if needed, finds MCP clients, and installs the Blender addon. Existing config is preserved with a .bak backup. ```powershell irm https://www.mcp-for-blender.com/install.ps1 | iex ``` -------------------------------- ### Programmatic server start example Source: https://github.com/ahujasid/mcp-for-blender Equivalent to running `uvx mcp-for-blender`. Blocks and serves MCP over stdio. ```python # Programmatic server start (equivalent to `uvx mcp-for-blender`) from blender_mcp.server import main main() # blocks; serves MCP over stdio ``` -------------------------------- ### Usage example for run_setup and related functions Source: https://github.com/ahujasid/mcp-for-blender Shows how to use run_setup interactively (as run by `uvx mcp-for-blender setup`), non-interactively with assume_yes and skip_addon, and programmatically with detect_clients, client_state, configure_client, and find_uvx. Interactive selection accepts ""/all/y/yes (all), n/no/none, or space/comma-separated numbers. ```python from blender_mcp.setup_cli import run_setup, detect_clients, client_state, configure_client, find_uvx # Full interactive setup (what `uvx mcp-for-blender setup` runs) code = run_setup() # Non-interactive: configure every client, skip the addon code = run_setup(assume_yes=True, skip_addon=True) # Programmatic per-client configuration uvx = find_uvx() for client in detect_clients(): state = client_state(client) if state.status in ("new", "outdated"): result = configure_client(client, uvx, state) print(result.message) ``` -------------------------------- ### AddonOutcome dataclass Source: https://github.com/ahujasid/mcp-for-blender Tracks addon installation and enabling results, with captured output lines. ```python @dataclass class AddonOutcome: installed: bool = False enabled: bool = False lines: list[str] = field(default_factory=list) ``` -------------------------------- ### detect_clients(platform=None, env=None, which=shutil.which) Source: https://github.com/ahujasid/mcp-for-blender Detects clients installed on this machine, in the order they're offered. Returns a list of Client objects for detected clients. ```APIDOC ## detect_clients(platform=None, env=None, which=shutil.which) ### Description Detects clients installed on this machine, in the order they're offered. ### Method Function call ### Parameters - **platform** (str | None) - Optional - Platform to detect clients for. - **env** - Optional - Environment to use. - **which** (callable) - Optional - Function to locate executables (defaults to shutil.which). ### Returns - **list[Client]** - List of detected clients in order: Claude Desktop, Claude Code, Codex, Cursor, VS Code, Devin Desktop (Windsurf), OpenCode, Antigravity. ``` -------------------------------- ### main() Source: https://github.com/ahujasid/mcp-for-blender Console-script entry point that runs the MCP server or delegates to addon install CLI subcommands. It parses CLI arguments, sets up logging, and starts the MCP server over stdio. ```APIDOC ## main() ### Description Console-script entry point that runs the MCP server or delegates to addon install CLI subcommands. It parses CLI arguments, sets up logging, and starts the MCP server over stdio. ### Behavior 1. If `sys.argv[1]` is one of `install-addon`, `addon-paths`, `setup`, `update`, `-h`, `--help`, it delegates to `addon_manager.run_cli` and exits with its code. 2. Otherwise parses `--host`/`--port` into the module globals `CLI_HOST`/`CLI_PORT`. 3. If stdin is a TTY, logs a hint that the server is waiting for an MCP client. 4. Installs the context logger (`context_log.install(mcp, SERVER_INSTRUCTIONS)`) and calls `mcp.run()` (stdio transport). ### Usage Example ```python # Programmatic server start (equivalent to `uvx mcp-for-blender`) from blender_mcp.server import main main() # blocks; serves MCP over stdio ``` ``` -------------------------------- ### Usage example: install and measure_result Source: https://github.com/ahujasid/mcp-for-blender Shows how to call install() and measure_result() directly. The install call is normally made by server.main() when BLENDER_MCP_CONTEXT_LOG=1. The measure_result example prints {'text_chars': 5, 'est_tokens': 1}. ```python from blender_mcp.context_log import install, measure_result, context_log_path from blender_mcp.server import mcp # Called by server.main() when BLENDER_MCP_CONTEXT_LOG=1 install(mcp, "server instructions text") # Measure a result directly from mcp.types import CallToolResult, TextContent result = CallToolResult(content=[TextContent(type="text", text="hello")]) print(measure_result(result)) # {'text_chars': 5, 'est_tokens': 1} ``` -------------------------------- ### Install Blender addon Source: https://github.com/ahujasid/mcp-for-blender/blob/main/README.md Installs the Blender addon via uvx. Then enable it in Blender preferences. ```bash uvx mcp-for-blender install-addon ``` -------------------------------- ### get(topic) Source: https://github.com/ahujasid/mcp-for-blender Returns the guide body for the given topic, matched case-insensitively after stripping. If the topic is unknown, returns a message listing available guides. ```APIDOC ## get(topic) ### Description Returns the guide body for the given topic, matched case-insensitively after stripping. If the topic is unknown, returns a message listing available guides. ### Method get(topic) ### Parameters #### Path Parameters - **topic** (str) - Required - Guide topic (matched case-insensitively after stripping) ### Returns - **str** - The guide `body`, or for an unknown topic: `"No guide called {topic!r}. Available guides:\n{index()}"`. ``` -------------------------------- ### Install Blender addon with uvx Source: https://github.com/ahujasid/mcp-for-blender/blob/main/integrations/claude/mcp-for-blender/README.md Run this command in a terminal to install the Blender addon for MCP for Blender. Requires uv to be installed first. ```bash uvx mcp-for-blender==2.3.1 install-addon ``` -------------------------------- ### Install uv on Linux Source: https://github.com/ahujasid/mcp-for-blender/blob/main/README.md Installs uv on Linux via the official installer. It lands in ~/.local/bin; open a new shell so it's on your PATH. ```bash curl -LsSf https://astral.sh/uv/install.sh | sh ``` -------------------------------- ### start() method signature Source: https://github.com/ahujasid/mcp-for-blender Binds the socket with SO_REUSEADDR and listen(5), starts the accept thread, registers edit-capture handlers and a persistent bpy.app.timers callback. Refuses to start in background mode and is a no-op when already running. ```python def start(self): ``` -------------------------------- ### run_setup(dry_run=False, assume_yes=False, skip_addon=False) Source: https://github.com/ahujasid/mcp-for-blender Runs the interactive setup for MCP for Blender. It can be used non-interactively with the assume_yes and skip_addon flags, and returns an exit code indicating success or failure. ```APIDOC ## `run_setup(dry_run=False, assume_yes=False, skip_addon=False)` ### Description Runs the setup process for MCP for Blender. It can be used interactively or non-interactively, and returns an exit code indicating success or failure. ### Parameters - `dry_run` (bool) - Optional - Show what would change without changing anything - `assume_yes` (bool) - Optional - Configure every client found without asking - `skip_addon` (bool) - Optional - Configure clients only; leave Blender alone ### Returns `int` — exit code (`1` if any client failed or the addon wasn't installed). Interactive selection accepts `""`/`all`/`y`/`yes` (all), `n`/`no`/`none`, or space/comma-separated numbers. ### Usage Example ```python from blender_mcp.setup_cli import run_setup, detect_clients, client_state, configure_client, find_uvx # Full interactive setup (what `uvx mcp-for-blender setup` runs) code = run_setup() # Non-interactive: configure every client, skip the addon code = run_setup(assume_yes=True, skip_addon=True) # Programmatic per-client configuration uvx = find_uvx() for client in detect_clients(): state = client_state(client) if state.status in ("new", "outdated"): result = configure_client(client, uvx, state) print(result.message) ``` ``` -------------------------------- ### Install uv on Windows via official installer Source: https://github.com/ahujasid/mcp-for-blender/blob/main/README.md Alternative Windows installation using uv's official installer script. ```powershell powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex" ``` -------------------------------- ### Install Claude Code plugin Source: https://github.com/ahujasid/mcp-for-blender/blob/main/integrations/claude/mcp-for-blender/README.md Run this command in Claude Code to install the MCP for Blender plugin. This is step 4 of the setup process. ```claude-code /plugin install mcp-for-blender --marketplace ahujasid/mcp-for-blender ``` -------------------------------- ### find_uvx(which=shutil.which) Source: https://github.com/ahujasid/mcp-for-blender Finds the absolute path to uvx, including uv's default install folders not yet on PATH. Returns the absolute path or None if not found. ```APIDOC ## find_uvx(which=shutil.which) ### Description Finds the absolute path to uvx, including uv's default install folders not yet on PATH. ### Method Function call ### Parameters - **which** (callable) - Optional - Function to locate executables (defaults to shutil.which). ### Returns - **str | None** - Absolute path to uvx (resolved via os.path.abspath), or None. ``` -------------------------------- ### Install uv on Windows via winget Source: https://github.com/ahujasid/mcp-for-blender/blob/main/README.md Installs uv on Windows using winget. Open a new terminal afterward so it's on your PATH. ```powershell winget install --id=astral-sh.uv -e ``` -------------------------------- ### codex_plugin_installed(env=None) Source: https://github.com/ahujasid/mcp-for-blender Checks if the Codex plugin is installed. ```APIDOC ## codex_plugin_installed(env=None) ### Description Checks if the Codex plugin is installed. ### Method Function call ### Parameters - **env** - Optional - Environment to use. ### Returns - **bool** - True if the plugin is installed, False otherwise. ``` -------------------------------- ### get(topic) function signature Source: https://github.com/ahujasid/mcp-for-blender Returns the guide body for the given topic, matched case-insensitively after stripping. For unknown topics, returns an error message listing available guides via index(). ```python def get(topic: str) -> str: ``` -------------------------------- ### run_setup function signature Source: https://github.com/ahujasid/mcp-for-blender Signature of the run_setup function. Parameters: dry_run (bool, default False) shows changes without applying; assume_yes (bool, default False) configures every client without asking; skip_addon (bool, default False) configures clients only, leaving Blender alone. Returns an int exit code (1 if any client failed or addon not installed). ```python def run_setup(dry_run: bool = False, assume_yes: bool = False, skip_addon: bool = False) -> int: ``` -------------------------------- ### server_entry(style, uvx) Source: https://github.com/ahujasid/mcp-for-blender Returns the server entry for a given style: VS Code, OpenCode, or plain. The entry is a dictionary with command and args. ```APIDOC ## server_entry(style, uvx) ### Description Returns the server entry for a given style: VS Code, OpenCode, or plain. ### Method Function call ### Parameters - **style** (str) - Required - The style of the client (e.g., 'vscode', 'opencode', 'plain'). - **uvx** (str) - Required - The path to uvx. ### Returns - **dict** - The server entry dictionary. For VS Code: {"type": "stdio", "command": uvx, "args": [PACKAGE]}; for OpenCode: {"type": "local", "command": [uvx, PACKAGE], "enabled": True}; otherwise: {"command": uvx, "args": [PACKAGE]}. ``` -------------------------------- ### mcp-for-blender setup [--dry-run] [--yes|-y] [--skip-addon] Source: https://github.com/ahujasid/mcp-for-blender Configures MCP clients and installs/enables the addon. Flags: --dry-run shows what would change, --yes/-y configures every client without asking, --skip-addon configures clients only. ```APIDOC ## mcp-for-blender setup [--dry-run] [--yes|-y] [--skip-addon] ### Description Configures MCP clients and installs/enables the addon. Flags: --dry-run shows what would change, --yes/-y configures every client without asking, --skip-addon configures clients only. ### Usage ``` mcp-for-blender setup [--dry-run] [--yes|-y] [--skip-addon] ``` ``` -------------------------------- ### json_client_state(client) Source: https://github.com/ahujasid/mcp-for-blender Probes the state of a client based on its JSON configuration. ```APIDOC ## json_client_state(client) ### Description Probes the state of a client based on its JSON configuration. ### Method Function call ### Parameters - **client** - Required - The client object. ### Returns - **ClientState** - The state of the client. ``` -------------------------------- ### Install uv on macOS Source: https://github.com/ahujasid/mcp-for-blender/blob/main/README.md Installs the uv package manager via Homebrew on macOS. ```bash brew install uv ``` -------------------------------- ### Usage example for BlenderConnection Source: https://github.com/ahujasid/mcp-for-blender Example of constructing a BlenderConnection, connecting, sending commands, handling errors, and disconnecting. Demonstrates get_scene_info and execute_code commands. ```python from blender_mcp.server import BlenderConnection conn = BlenderConnection(host="localhost", port=9876) if not conn.connect(): raise SystemExit("Blender addon not reachable") result = conn.send_command("get_scene_info") print(result["name"], result["object_count"]) try: conn.send_command("execute_code", {"code": "import bpy; print(bpy.app.version_string)"}) except Exception as e: print("Blender reported an error:", e) finally: conn.disconnect() ``` -------------------------------- ### all_guides() function signature Source: https://github.com/ahujasid/mcp-for-blender Returns a dictionary of all guides keyed by topic, sorted by file name, cached for process lifetime. Reads *.md files from the package's guides directory. ```python @lru_cache(maxsize=1) def all_guides() -> dict[str, Guide]: ``` -------------------------------- ### all_guides() Source: https://github.com/ahujasid/mcp-for-blender Returns a dictionary of all available guides, keyed by topic, sorted by file name. Cached for the process lifetime. ```APIDOC ## all_guides() ### Description Returns a dictionary of all available guides, keyed by topic, sorted by file name. Cached for the process lifetime. ### Method all_guides() ### Returns - **dict[str, Guide]** - All `*.md` files under the package's `guides` directory, keyed by topic, sorted by file name. ### Notes - Cached for the process lifetime. - Shipped topics: `animation`, `bpy`, `level-design`, `materials`, `retopology`, `rigging`, `scene`. ``` -------------------------------- ### ClientResult dataclass Source: https://github.com/ahujasid/mcp-for-blender Result of configuring a client, including success flag, message, and optional backup path. ```python @dataclass class ClientResult: client: Client ok: bool message: str backup: Path | None = None ``` -------------------------------- ### claude_code_state(env=None) Source: https://github.com/ahujasid/mcp-for-blender Probes the state of Claude Code client. ```APIDOC ## claude_code_state(env=None) ### Description Probes the state of Claude Code client. ### Method Function call ### Parameters - **env** - Optional - Environment to use. ### Returns - **ClientState** - The state of the client. ``` -------------------------------- ### ClientState dataclass Source: https://github.com/ahujasid/mcp-for-blender Holds the status of a client entry (e.g., new, configured, outdated, unreadable) with optional entry key and detail. ```python @dataclass class ClientState: status: str entry_key: str | None = None detail: str = "" ``` -------------------------------- ### index() Source: https://github.com/ahujasid/mcp-for-blender Returns a string with one line per guide in the format `- {topic}: {summary}`. ```APIDOC ## index() ### Description Returns a string with one line per guide in the format `- {topic}: {summary}`. ### Method index() ### Returns - **str** - One line per guide: `- {topic}: {summary}`. ``` -------------------------------- ### codex_state(env=None) Source: https://github.com/ahujasid/mcp-for-blender Probes the state of Codex client, first checking codex_plugin_installed. ```APIDOC ## codex_state(env=None) ### Description Probes the state of Codex client, first checking codex_plugin_installed. ### Method Function call ### Parameters - **env** - Optional - Environment to use. ### Returns - **ClientState** - The state of the client. ``` -------------------------------- ### mcp-for-blender addon-paths Source: https://github.com/ahujasid/mcp-for-blender Lists discovered Blender addons directories and existing installs. ```APIDOC ## mcp-for-blender addon-paths ### Description Lists discovered Blender addons directories and existing installs. ### Usage ``` mcp-for-blender addon-paths ``` ``` -------------------------------- ### Usage example for trajectory recording Source: https://github.com/ahujasid/mcp-for-blender Shows how to obtain the recorder, note client and goal, snapshot world state before and after agent mutations, record a step with parameters and feedback, and flush the recorder. ```python from blender_mcp.trajectory import get_trajectory_recorder, compute_state_delta recorder = get_trajectory_recorder() recorder.note_client("claude-code", "1.0") recorder.note_goal("make a wooden chair") before = recorder.snapshot_world_state() # ... agent mutates the scene ... after = recorder.snapshot_world_state() recorder.record_step( tool_name="execute_blender_code", goal_text="make a wooden chair", params={"code_len": 42}, raw_code="import bpy; ...", state_before=before, state_after=after, success=True, duration_ms=1234.5, ) recorder.record_feedback(feedback="accept", step_index=0) recorder.flush(2.0) ``` -------------------------------- ### get_scene_info usage examples Source: https://github.com/ahujasid/mcp-for-blender Two example calls to `get_scene_info`. The first is a basic call with a user prompt. The second queries objects named "chair" with specific fields and a limit of 50. ```python # Basic call summary = await get_scene_info(ctx, user_prompt="what's in the scene?") ``` ```python # Non-trivial: topology health of everything named "chair" summary = await get_scene_info( ctx, query="chair", fields=["location", "size", "topology", "weights"], limit=50, ) ``` -------------------------------- ### Install without uv using pipx Source: https://github.com/ahujasid/mcp-for-blender/blob/main/README.md Installs mcp-for-blender via pipx on locked-down machines, then ensures the command is on your PATH. Restart your shell/client afterward. ```bash pipx install mcp-for-blender pipx ensurepath # then restart your shell / client ``` -------------------------------- ### servers_state(servers) Source: https://github.com/ahujasid/mcp-for-blender Determines whether a client's server map already runs this package. Returns CONFIGURED, OUTDATED, or NEW based on the server entries. ```APIDOC ## servers_state(servers) ### Description Determines whether a client's server map already runs this package. ### Method Function call ### Parameters - **servers** (dict) - Required - The server map of a client. ### Returns - **ClientState** - CONFIGURED if any entry runs mcp-for-blender; OUTDATED (with the old key) if any runs blender-mcp; else NEW. ``` -------------------------------- ### Basic call and thumbnail call examples Source: https://github.com/ahujasid/mcp-for-blender Two usage examples: a basic polyhaven HDRI search and a sketchfab search with thumbnails. The first returns a listing string; the second returns a CallToolResult with ImageContent when previews > 0. ```python # Basic call listing = await search_assets( ctx, source="polyhaven", query="overcast afternoon", asset_type="hdris", user_prompt="light the scene with an overcast HDRI", ) ``` ```python # With thumbnails attached result = await search_assets( ctx, source="sketchfab", query="wooden chair", previews=3, user_prompt="find a wooden chair", ) ``` -------------------------------- ### Codex plugin: Clone repo and add marketplace Source: https://github.com/ahujasid/mcp-for-blender/blob/main/README.md Install the Codex plugin by cloning the blender-mcp repo and adding it as a marketplace. Then restart Codex and install MCP for Blender from the plugins directory. ```bash git clone https://github.com/ahujasid/blender-mcp.git codex plugin marketplace add ./blender-mcp/integrations/codex ``` -------------------------------- ### run_cli(argv=None) Source: https://github.com/ahujasid/mcp-for-blender CLI entry for install-addon / addon-paths / setup / update. Returns process exit code. ```APIDOC ## run_cli(argv=None) ### Description CLI entry for install-addon / addon-paths / setup / update. Returns process exit code. ### Parameters - **argv** (list[str] | None) - Optional - `sys.argv[1:]`. ### Returns - **int** - Process exit code: `0` success, `1` failure, `-1` when no subcommand was given (the caller should start the MCP server). ### Subcommands - `install-addon [--addons-dir DIR]` — install the bundled addon. - `addon-paths` — list discovered Blender addons directories and existing installs. - `setup [--dry-run] [--yes|-y] [--skip-addon]` — delegates to `setup_cli.run_setup`. - `update [--dry-run]` — delegates to `update_cli.run_update`. - `--host` / `--port` — declared for `--help` only; the server entry parses them itself. ``` -------------------------------- ### Guide dataclass definition Source: https://github.com/ahujasid/mcp-for-blender Frozen dataclass representing a guide with topic, title, summary, and body fields. Topic is the markdown file name without .md, title and summary come from front-matter, body is the guide markdown with front matter stripped. ```python @dataclass(frozen=True) class Guide: topic: str title: str summary: str body: str ``` -------------------------------- ### Usage example for premium_hint_once and premium_generation_guidance Source: https://github.com/ahujasid/mcp-for-blender Shows how to call both functions inside a generation tool and in get_addon_status to append the hint and describe the user's Premium generators. ```python from blender_mcp.premium_hint import premium_hint_once, premium_generation_guidance # Inside a generation tool, after choosing a provider note = premium_hint_once(ctx, {"mode": None}) reply = f"Generated and imported 'Chest' with tripo." + note # In get_addon_status: describe the user's Premium generators guidance = premium_generation_guidance(["meshy", "tripo"]) ``` -------------------------------- ### install(mcp, instructions) Source: https://github.com/ahujasid/mcp-for-blender Wraps the registered tools/list and tools/call handlers with size logging. No-op unless context logging is enabled. Replaces the ListToolsRequest and CallToolRequest handlers on the MCP server with logging wrappers. ```APIDOC ## install(mcp, instructions) ### Description Wraps the registered tools/list and tools/call handlers with size logging. No-op unless context logging is enabled. Replaces the ListToolsRequest and CallToolRequest handlers on the MCP server with logging wrappers. ### Method Function ### Signature ```python def install(mcp, instructions: str) -> None: ``` ### Parameters - **mcp** (FastMCP) - Required - The MCP server instance - **instructions** (str) - Required - Server instructions text (its size is logged) ### Returns - **None** - No return value ``` -------------------------------- ### Client dataclass Source: https://github.com/ahujasid/mcp-for-blender Represents an MCP client configuration. The 'kind' field distinguishes JSON-edited configs from CLI-based ones (claude-code/codex). ```python @dataclass class Client: key: str name: str # json: we edit `config_path` ourselves; claude-code / codex: their CLI does kind: str config_path: Path | None = None # mcpServers | vscode | opencode style: str = "mcpServers" restart_hint: str = "" cli_path: str | None = None ``` -------------------------------- ### viewport_pick usage example Source: https://github.com/ahujasid/mcp-for-blender Example of calling `viewport_pick` with `seq=3`, `x=0.5`, `y=0.25` and accessing the returned structured content to print the object's name and link URI. ```python result = viewport_pick(seq=3, x=0.5, y=0.25) obj = result.structuredContent["object"] if obj: print(obj["name"], obj["link"]["uri"]) ``` -------------------------------- ### submit(send, provider, name, prompt, image, quality, bbox_condition, supports_quality) Source: https://github.com/ahujasid/mcp-for-blender Starts a generation. Returns a Job, or a finished message for providers that generate synchronously (Hunyuan3D LOCAL_API). ```APIDOC ## submit(send, provider, name, prompt, image, quality, bbox_condition, supports_quality) ### Description Starts a generation. Returns a Job, or a finished message for providers that generate synchronously (Hunyuan3D LOCAL_API). ### Parameters - **send** (`Send`) - Required - `Callable[[str, dict], Any]` — the addon command sender - **provider** (`str`) - Required - One of `PROVIDERS` - **name** (`str`) - Required - Object name - **prompt** (`str | None`) - Required - Text prompt - **image** (`str | None`) - Required - Image path/URL - **quality** (`str | None`) - Required - `"standard"`/`"high"` - **bbox_condition** (`list | None`) - Required - hyper3d proportions - **supports_quality** (`bool`) - Required - Whether the addon protocol supports the quality arg (protocol ≥ 11) ### Returns `Job` or `str` (a finished message for synchronous Hunyuan3D LOCAL_API). ### Throws `GenerationError` for: missing provider ids, Meshy prompt over `MESHY_PROMPT_MAX`, missing image file (`_rodin_images`), invalid bbox, or provider error payloads (via `_relay`). ``` -------------------------------- ### index() function signature Source: https://github.com/ahujasid/mcp-for-blender Returns a string with one line per guide in the format '- {topic}: {summary}'. ```python def index() -> str: ``` -------------------------------- ### Install, check status, and handshake with the addon Source: https://github.com/ahujasid/mcp-for-blender Shows the main functions from blender_mcp.addon_manager: install_addon() installs the bundled addon into the newest Blender addons folder and returns a result with a message. check_addon_status_on_startup() reports what's on disk without writing anything, and its needs_action flag indicates whether action is required. handshake_addon() connects to a live addon via the Blender connection and returns protocol_version and up_to_date. ```python from blender_mcp.addon_manager import install_addon, handshake_addon, check_addon_status_on_startup from blender_mcp.server import get_blender_connection # Install the bundled addon into the newest Blender addons folder result = install_addon() print(result.message) # "Installed MCP for Blender addon to ..." # Check what's on disk without writing anything report = check_addon_status_on_startup() if report.needs_action: print(report.message) # Handshake with a live addon handshake = handshake_addon(get_blender_connection()) print(handshake.protocol_version, handshake.up_to_date) ``` -------------------------------- ### Usage example for run_update and fetch_latest_version Source: https://github.com/ahujasid/mcp-for-blender Shows what `uvx mcp-for-blender update` runs and how to check for a newer release without changing anything. ```python from blender_mcp.update_cli import run_update, fetch_latest_version, version_key, current_version # What `uvx mcp-for-blender update` runs code = run_update() # Check for a newer release without changing anything latest, error = fetch_latest_version() if latest and version_key(current_version() or "") < version_key(latest): print(f"update available: {latest}") ``` -------------------------------- ### mcp-for-blender update [--dry-run] Source: https://github.com/ahujasid/mcp-for-blender Updates the server and installed addons to the latest release. Optionally use --dry-run to preview changes. ```APIDOC ## mcp-for-blender update [--dry-run] ### Description Updates the server and installed addons to the latest release. Optionally use --dry-run to preview changes. ### Usage ``` mcp-for-blender update [--dry-run] ``` ``` -------------------------------- ### install(mcp, instructions) function signature Source: https://github.com/ahujasid/mcp-for-blender Wraps the registered tools/list and tools/call handlers with size logging. No-op unless context_log_enabled() is true. ```python def install(mcp, instructions: str) -> None: """Wrap the registered tools/list and tools/call handlers with size logging. Wraps whatever is registered at call time, so per-client tool filtering stays in place and the log sees exactly what the client receives. """ ``` -------------------------------- ### look usage examples Source: https://github.com/ahujasid/mcp-for-blender Shows a basic viewport capture and a non-trivial angles mode call with rendered shading. The result content includes an ImageContent and a caption. ```python # Basic call: the user's viewport result = await look(ctx, user_prompt="show me the scene") # Non-trivial: four-sided auto-framed sheet, rendered shading, small result = await look( ctx, mode="angles", target=["Chair"], views=["front", "right", "top", "three_quarter"], shading="rendered", max_size=512, ) # result.content[0] is an ImageContent; result.content[1] is the caption ``` -------------------------------- ### disable_telemetry usage example Source: https://github.com/ahujasid/mcp-for-blender Example call to `disable_telemetry` with a user prompt. Asserts the result starts with "Data collection is now OFF". ```python result = disable_telemetry(ctx, user_prompt="stop collecting my data") assert result.startswith("Data collection is now OFF") ``` -------------------------------- ### get_sketchfab_model_preview Source: https://github.com/ahujasid/mcp-for-blender Gets a preview for a Sketchfab model. Available when the Sketchfab checkbox is enabled. ```APIDOC ## get_sketchfab_model_preview ### Description Gets a preview for a Sketchfab model. Available when the Sketchfab checkbox is enabled. ``` -------------------------------- ### Usage example with decorators and direct event recording Source: https://github.com/ahujasid/mcp-for-blender Shows how to use telemetry_tool, trajectory_tool, classify_tool_result, record_tool_usage, and get_telemetry().record_event together. ```python from blender_mcp.telemetry_decorator import telemetry_tool, trajectory_tool, classify_tool_result from blender_mcp.telemetry import get_telemetry, EventType, record_tool_usage @telemetry_tool("my_tool") def my_tool(x: int) -> str: return "ok" if x else "error: x must be truthy" @trajectory_tool("my_mutating_tool", capture_code=True) def my_mutating_tool(code: str, user_prompt: str = "") -> str: return f"executed {code}" # Direct event recording record_tool_usage("my_tool", success=True, duration_ms=12.5) get_telemetry().record_event( event_type=EventType.CONNECTION, tool_name="ping", metadata={"ok": True}, ) ``` -------------------------------- ### get_polyhaven_asset_preview Source: https://github.com/ahujasid/mcp-for-blender Gets a preview for a Poly Haven asset. Available when the Poly Haven checkbox is enabled. ```APIDOC ## get_polyhaven_asset_preview ### Description Gets a preview for a Poly Haven asset. Available when the Poly Haven checkbox is enabled. ``` -------------------------------- ### read_json_config(path) Source: https://github.com/ahujasid/mcp-for-blender Reads a JSON config file, returning the parsed config and whether JSONC comments had to be stripped. Throws ConfigError for invalid JSON or non-object root. ```APIDOC ## read_json_config(path) ### Description Reads a JSON config file, returning the parsed config and whether JSONC comments had to be stripped. ### Method Function call ### Parameters - **path** (Path) - Required - Path to the config file. ### Returns - **tuple[dict, bool]** - The parsed config and whether JSONC comments had to be stripped. ### Throws - **ConfigError** - For invalid JSON or a non-object root. ``` -------------------------------- ### get_addon_info() method signature Source: https://github.com/ahujasid/mcp-for-blender Returns version and capability information for the MCP server handshake and install tooling. ```python def get_addon_info(self): """Version/capability handshake for the MCP server (and install tooling).""" ``` -------------------------------- ### generate_3d usage examples Source: https://github.com/ahujasid/mcp-for-blender Shows a basic call with a prompt and a resume call using a job handle from a previous reply. The resume call avoids paying again for a pending generation. ```python # Basic call reply = await generate_3d( ctx, prompt="weathered wooden treasure chest", user_prompt="make a treasure chest", ) # Resume a long generation with the job handle from a previous reply reply = await generate_3d( ctx, job="meshy:t2p:abc123", name="Chest", user_prompt="make a treasure chest", ) ``` -------------------------------- ### execute_blender_code usage examples Source: https://github.com/ahujasid/mcp-for-blender Shows a basic call adding a cube and error handling for division by zero. The addon's traceback is returned as text, and safe mode may reject code via validate_code. ```python # Basic call reply = await execute_blender_code( ctx, code='import bpy; bpy.ops.mesh.primitive_cube_add(size=2)', user_prompt="add a cube", ) # Error handling: the addon's traceback is returned as text reply = await execute_blender_code(ctx, code="1/0") assert reply.startswith("Error executing code: ZeroDivisionError") ``` -------------------------------- ### Shrinkwrap modifier setup Source: https://github.com/ahujasid/mcp-for-blender/blob/main/src/blender_mcp/guides/retopology.md Adds a Shrinkwrap modifier targeting the high mesh to recover the silhouette after remeshing. ```python modifiers.new("Shrinkwrap", "SHRINKWRAP") ``` -------------------------------- ### get_addon_info() return value Source: https://github.com/ahujasid/mcp-for-blender Example JSON response containing addon name, version, protocol version, capabilities list, Blender version, and premium generators. ```json { "name": "MCP for Blender", "addon_version": [2, 2, 2], "protocol_version": 14, "capabilities": ["get_scene_info", "get_world_state_snapshot", "get_addon_info", "get_object_info", "list_scene_items", "get_viewport_screenshot", "pick_viewport_object", "execute_code", "describe_node_type", "bpy_api_lookup", "drain_human_activity", "get_telemetry_consent", "set_telemetry_consent"], "blender_version": "4.2.0", "premium_generators": ["meshy", "tripo"] } ``` -------------------------------- ### Raw socket client example for get_addon_info Source: https://github.com/ahujasid/mcp-for-blender Connects to the addon's server on localhost:9876, sends a get_addon_info request, and reads until a complete JSON object arrives. Prints the protocol_version from the reply (expected 14). ```python import json, socket sock = socket.create_connection(("localhost", 9876), timeout=180) sock.sendall(json.dumps({ "type": "get_addon_info", "params": {}, }).encode("utf-8")) # Read until one complete JSON object arrives buf = b"" while True: buf += sock.recv(8192) try: reply = json.loads(buf.decode("utf-8")) break except json.JSONDecodeError: continue print(reply["result"]["protocol_version"]) # 14 sock.close() ``` -------------------------------- ### Voxel remesh command Source: https://github.com/ahujasid/mcp-for-blender/blob/main/src/blender_mcp/guides/retopology.md Creates a watertight, even mesh but loses UVs and sharp edges. Requires an active object; size ~1/200 of the largest dimension is a sane start. ```python obj.data.remesh_voxel_size = 0.01; bpy.ops.object.voxel_remesh() ``` -------------------------------- ### Decimate modifier setup Source: https://github.com/ahujasid/mcp-for-blender/blob/main/src/blender_mcp/guides/retopology.md Adds a Decimate modifier with a ratio of 0.1 to reduce triangle count while keeping shape and UVs. Planar mode (decimate_type="DISSOLVE") is better for hard-surface meshes. ```python m = obj.modifiers.new("Decimate", "DECIMATE"); m.ratio = 0.1 ``` -------------------------------- ### Using blender_mcp.openai_apps: picker, reply, and viewport store Source: https://github.com/ahujasid/mcp-for-blender Shows how to use PickerOption, pick_asset, picked_reply, viewport_store, and supports_apps from blender_mcp.openai_apps. The picker is used inside an async tool; viewport_store tracks command state and snapshots. ```python from blender_mcp.openai_apps import ( PickerOption, pick_asset, picked_reply, viewport_store, supports_apps, ) # Show a picker (inside an async tool) options = [PickerOption(id="a1", title="Chair", thumbnail="https://.../a1.png")] picked = await pick_asset(ctx, "Pick a model for: chair", "Model", options) if picked and picked.action == "accept": reply = picked_reply("Poly Haven", picked, {"a1": "block text"}, "full listing") else: reply = "full listing" # Viewport store bookkeeping viewport_store.command_started() try: ... # send a scene-changing command finally: viewport_store.command_finished("execute_code") state, png = viewport_store.snapshot() print(state["stale"], state["seq"]) ``` -------------------------------- ### LOOK Source: https://github.com/ahujasid/mcp-for-blender Runs inside Blender with ARGS = {"mode", "target", "views", "distance", "shading", "frames", "frame_count", "view", "image", "max_size", "filepath"}. Renders the 3D viewport offscreen (GPU) with chosen camera matrices and shading, tiles the results into one PNG, writes it to ARGS["filepath"], and restores every setting it touched. ```APIDOC ## `LOOK` ### Description Runs inside Blender with `ARGS` = `{"mode", "target", "views", "distance", "shading", "frames", "frame_count", "view", "image", "max_size", "filepath"}`. Renders the 3D viewport offscreen (GPU) with chosen camera matrices and shading, tiles the results into one PNG, writes it to `ARGS["filepath"]`, and restores every setting it touched. ### Parameters - `mode` (string) - Required - Rendering mode, e.g., "angles" or "image". - `target` (string) - Required - Target object name. - `views` (list) - Required - List of view names (e.g., "front", "right", "top", "three_quarter"). - `distance` (number) - Required - Camera distance. - `shading` (string) - Required - Shading mode. - `frames` (list) - Required - Frame range. - `frame_count` (integer) - Required - Number of frames. - `view` (string) - Required - View name. - `image` (string) - Required - Image name. - `max_size` (integer) - Required - Maximum size. - `filepath` (string) - Required - Output file path. ### Returns - `dict` - Info about the render. ### Response Example ```json { "mode": "angles", "targets": 1, "center": [0.0, 0.0, 0.0], "size": [2.0, 2.0, 2.0], "views": ["front", "right", "top", "three_quarter"], "width": 512, "height": 512 } ``` ### Error Responses - `{"error": "No 3D viewport is open in Blender"}` - `{"error": "No object named ..."}` - `{"error": "The scene has no camera. Add one or use mode='angles'."}` - `{"error": "Rendered shading can't be captured with {engine}. ..."}` - `{"error": "No image named ... in the file and no file at ..."}` ``` -------------------------------- ### current_version() Source: https://github.com/ahujasid/mcp-for-blender Returns the installed mcp-for-blender distribution version, or None if not installed. ```APIDOC ## current_version() ### Description Returns the installed mcp-for-blender distribution version, or None if not installed. ### Signature ```python def current_version() -> str | None: ``` ### Returns - **str | None** - The installed version string, or None if not installed. ``` -------------------------------- ### current_version function signature Source: https://github.com/ahujasid/mcp-for-blender Returns the installed mcp-for-blender distribution version, or None if not installed. ```python def current_version() -> str | None: ``` -------------------------------- ### mcp-for-blender install-addon [--addons-dir DIR] Source: https://github.com/ahujasid/mcp-for-blender Copies the bundled addon into Blender's addons folder. Optionally specify a custom addons directory. ```APIDOC ## mcp-for-blender install-addon [--addons-dir DIR] ### Description Copies the bundled addon into Blender's addons folder. Optionally specify a custom addons directory. ### Usage ``` mcp-for-blender install-addon [--addons-dir DIR] ``` ``` -------------------------------- ### mcp-for-blender -h / --help Source: https://github.com/ahujasid/mcp-for-blender Displays help information for the CLI. ```APIDOC ## mcp-for-blender -h / --help ### Description Displays help information for the CLI. ### Usage ``` mcp-for-blender -h ``` ``` -------------------------------- ### uv_tool_installed(uv) Source: https://github.com/ahujasid/mcp-for-blender Checks whether mcp-for-blender was installed via `uv tool install`. Returns True if so, which means uvx prefers that copy. ```APIDOC ## uv_tool_installed(uv) ### Description Checks whether mcp-for-blender was installed via `uv tool install`. Returns True if so, which means uvx prefers that copy. ### Signature ```python def uv_tool_installed(uv: str) -> bool: ``` ### Parameters - **uv** (str) - Required - Path to the uv executable. ### Returns - **bool** - True if the tool is installed via uv tool install, False otherwise. ``` -------------------------------- ### Create FastMCP instance for MCP for Blender Source: https://github.com/ahujasid/mcp-for-blender Initializes the FastMCP server with the name 'MCP for Blender', a lifespan handler, and custom instructions. The instance registers 14 tools and 4 resources, and wraps list_tools() to hide app-only tools from unsupported clients. ```python mcp = FastMCP( "MCP for Blender", lifespan=server_lifespan, instructions=SERVER_INSTRUCTIONS, ) ``` -------------------------------- ### viewport_latest Source: https://github.com/ahujasid/mcp-for-blender Tool to get the latest viewport state. ```APIDOC ## Tool: viewport_latest ### Description Gets the latest viewport state. ### Method MCP Tool ### Endpoint `viewport_latest` ``` -------------------------------- ### record_startup(blender_version=None) Source: https://github.com/ahujasid/mcp-for-blender Records a STARTUP event. Optionally pass the Blender version. ```APIDOC ## record_startup(blender_version=None) ### Description Records a STARTUP event. Optionally pass the Blender version. ### Method Function ### Signature ```python def record_startup(blender_version: str | None = None): ``` ### Parameters - **blender_version** (str | None) - Optional - Blender version to record ``` -------------------------------- ### Socket RPC: get_polyhaven_categories Source: https://github.com/ahujasid/mcp-for-blender Gets Poly Haven categories. ```APIDOC ## Socket RPC Command: get_polyhaven_categories ### Description Gets Poly Haven categories. ### Request ```json {"type": "get_polyhaven_categories", "params": {}} ``` ### Response ```json {"status": "success", "result": { ... }} ``` ``` -------------------------------- ### Socket RPC: get_sketchfab_model_preview Source: https://github.com/ahujasid/mcp-for-blender Gets a preview of a Sketchfab model. ```APIDOC ## Socket RPC Command: get_sketchfab_model_preview ### Description Gets a preview of a Sketchfab model. ### Request ```json {"type": "get_sketchfab_model_preview", "params": { ... }} ``` ### Response ```json {"status": "success", "result": { ... }} ``` ```