Skip to content

Conversation

@AlexStansfield
Copy link

@AlexStansfield AlexStansfield commented May 25, 2025

User description

This change allows connection to blender on a remote machine in the cases where your MCP server is not running on the same machine as blender.

This changes adds:

  • a "All interfaces" option in the blender addon, with it selected the server is exposed on 0.0.0.0 instead of localhost
  • an environmental variable BLENDER_SERVER_HOST in the MCP server where you can set the host name of the machine running blender.

PR Type

Enhancement, Documentation


Description

  • Added support for remote Blender connections via server host configuration

    • New "All interfaces" option in Blender add-on UI
    • Server can bind to 0.0.0.0 for remote access
    • MCP server can use BLENDER_SERVER_HOST environment variable
  • Updated documentation for remote access setup


Changes walkthrough 📝

Relevant files
Enhancement
addon.py
Add UI and logic for remote server binding option               

addon.py

  • Added "All interfaces" checkbox to Blender add-on UI for server
    binding
  • Server now binds to 0.0.0.0 if option is selected, otherwise localhost
  • Registered and unregistered new property for interface selection
  • +13/-1   
    server.py
    Support configurable Blender host via environment variable

    src/blender_mcp/server.py

  • Added support for BLENDER_SERVER_HOST environment variable to set
    Blender host
  • Default host remains localhost if variable is unset
  • Connection logic uses configurable host value
  • +4/-1     
    Documentation
    README.md
    Document remote Blender access configuration                         

    README.md

  • Documented remote Blender access setup
  • Added instructions for using BLENDER_SERVER_HOST and UI option
  • +6/-0     

    Need help?
  • Type /help how to ... in the comments thread for any questions about Qodo Merge usage.
  • Check out the documentation for more information.
  • Summary by CodeRabbit

    • New Features
      • Added an option in the user interface to allow the Blender MCP server to bind to all network interfaces, enabling remote connections.
    • Documentation
      • Updated the README with instructions for connecting to a remote Blender MCP server, including environment variable setup and addon configuration guidance.

    @coderabbitai
    Copy link

    coderabbitai bot commented May 25, 2025

    Walkthrough

    A new configuration option was added to allow the Blender MCP server to bind to all network interfaces, controlled by a checkbox in the UI. The server host can now be set via an environment variable for remote access. Documentation was updated to explain remote connection setup.

    Changes

    File(s) Change Summary
    README.md Added instructions for connecting to a remote Blender MCP server using an environment variable.
    addon.py Added a boolean property to toggle binding to all interfaces, updated UI and server startup logic.
    src/blender_mcp/server.py Made server host configurable via environment variable; updated connection logic accordingly.

    Sequence Diagram(s)

    sequenceDiagram
        participant User
        participant BlenderAddon
        participant BlenderMCPServer
        participant RemoteClient
    
        User->>BlenderAddon: Enable "All interfaces" option
        User->>BlenderAddon: Start server
        BlenderAddon->>BlenderMCPServer: Start(host='0.0.0.0' or 'localhost')
        RemoteClient->>BlenderMCPServer: Connect using BLENDER_SERVER_HOST
    
    Loading

    Poem

    A bunny flips a Blender switch,
    Now servers reach beyond the niche!
    "All interfaces," checked with care,
    Remote hosts join from anywhere.
    With docs refreshed and code anew,
    The network hops—connections grew!
    🐇✨

    ✨ Finishing Touches
    • 📝 Generate Docstrings

    Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

    ❤️ Share
    🪧 Tips

    Chat

    There are 3 ways to chat with CodeRabbit:

    • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
      • I pushed a fix in commit <commit_id>, please review it.
      • Explain this complex logic.
      • Open a follow-up GitHub issue for this discussion.
    • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
      • @coderabbitai explain this code block.
      • @coderabbitai modularize this function.
    • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
      • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
      • @coderabbitai read src/utils.ts and explain its main purpose.
      • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
      • @coderabbitai help me debug CodeRabbit configuration file.

    Support

    Need help? Create a ticket on our support page for assistance with any issues or questions.

    Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

    CodeRabbit Commands (Invoked using PR comments)

    • @coderabbitai pause to pause the reviews on a PR.
    • @coderabbitai resume to resume the paused reviews.
    • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
    • @coderabbitai full review to do a full review from scratch and review all the files again.
    • @coderabbitai summary to regenerate the summary of the PR.
    • @coderabbitai generate docstrings to generate docstrings for this PR.
    • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
    • @coderabbitai resolve resolve all the CodeRabbit review comments.
    • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
    • @coderabbitai help to get help.

    Other keywords and placeholders

    • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
    • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
    • Add @coderabbitai anywhere in the PR title to generate the title automatically.

    CodeRabbit Configuration File (.coderabbit.yaml)

    • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
    • Please see the configuration documentation for more information.
    • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

    Documentation and Community

    • Visit our Documentation for detailed information on how to use CodeRabbit.
    • Join our Discord Community to get help, request features, and share feedback.
    • Follow us on X/Twitter for updates and announcements.

    @qodo-merge-pro
    Copy link

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
    🧪 No relevant tests
    🔒 Security concerns

    Network exposure:
    The option to bind the server to all interfaces (0.0.0.0) exposes the Blender instance to the network. This could potentially allow unauthorized access if no authentication mechanism is in place. Consider adding a warning in the UI about the security implications or implementing authentication for remote connections.

    ⚡ Recommended focus areas for review

    Port Configuration

    The blender_port is hardcoded to 9876 but the addon allows configuring the port. This could cause connection issues if the port in the addon doesn't match this hardcoded value.

    blender_host = os.getenv("BLENDER_SERVER_HOST", "localhost")
    blender_port = 9876
    Server Reinstantiation

    The server instance is created but there's no check if it already exists with different host settings. This might cause issues when switching between local and remote modes without restarting.

    if not bpy.data.worlds:
        bpy.data.worlds.new("World")

    @qodo-merge-pro
    Copy link

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Impact
    Security
    Add security warning

    Add a warning message when enabling all interfaces as this creates a potential
    security risk by exposing Blender to external connections. Users should be
    informed about the security implications.

    addon.py [1424-1426]

     host = 'localhost'
     if scene.blendermcp_host_all_interfaces:
         host = '0.0.0.0'
    +    self.report({'WARNING'}, "Serving on all interfaces may expose Blender to external connections. Ensure your network is secure.")
    • Apply / Chat
    Suggestion importance[1-10]: 7

    __

    Why: Adding a warning when enabling "all interfaces" is a valuable usability and security improvement, alerting users to potential risks. The suggestion is accurate and fits the code context, but it is not a critical bug fix or security patch, so a score of 7 is appropriate.

    Medium
    General
    Make port configurable

    Allow the port to be configurable via environment variable similar to the host.
    This provides consistent configuration options and flexibility for different
    deployment scenarios.

    src/blender_mcp/server.py [20-21]

     blender_host = os.getenv("BLENDER_SERVER_HOST", "localhost")
    -blender_port = 9876
    +blender_port = int(os.getenv("BLENDER_SERVER_PORT", "9876"))
    • Apply / Chat
    Suggestion importance[1-10]: 6

    __

    Why: Allowing the port to be set via an environment variable increases flexibility and consistency, especially for deployments. This is a minor but useful enhancement, and the code change is correct and contextually appropriate.

    Low
    • More

    Copy link

    @coderabbitai coderabbitai bot left a comment

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    Actionable comments posted: 0

    🔭 Outside diff range comments (1)
    addon.py (1)

    424-430: 🛠️ Refactor suggestion

    Consider security implications of binding to all interfaces.

    The logic correctly sets the host based on the checkbox state. However, binding to all interfaces (0.0.0.0) has security implications.

    While the implementation is correct, consider adding a warning or documentation about the security implications of binding to all interfaces. When the server binds to 0.0.0.0, it becomes accessible from any network interface, potentially exposing the Blender instance to unauthorized access from the network.

    Consider adding a tooltip warning to the checkbox:

        bpy.types.Scene.blendermcp_host_all_interfaces = bpy.props.BoolProperty(
            name="All interfaces",
    -        description="Serve on all interfaces to allow remote connection",
    +        description="Serve on all interfaces to allow remote connection (WARNING: This exposes Blender to network access)",
            default=False
        )
    🧹 Nitpick comments (1)
    README.md (1)

    128-133: Fix grammar and improve clarity.

    The documentation clearly explains the remote connection setup, but there's a grammatical issue that should be addressed.

    Apply this diff to improve the grammar:

    -If connecting to blender on a remote machine pass the host name to the blender mcp server using the environmental variable BLENDER_SERVER_HOST.
    +If connecting to Blender on a remote machine, pass the host name to the Blender MCP server using the environment variable BLENDER_SERVER_HOST.

    This change:

    1. Adds a missing comma after "remote machine"
    2. Capitalizes "Blender" consistently
    3. Uses "environment variable" instead of "environmental variable" (more precise terminology)
    🧰 Tools
    🪛 LanguageTool

    [uncategorized] ~130-~130: A comma might be missing here.
    Context: ...s If connecting to blender on a remote machine pass the host name to the blender mcp s...

    (AI_EN_LECTOR_MISSING_PUNCTUATION_COMMA)

    📜 Review details

    Configuration used: CodeRabbit UI
    Review profile: CHILL
    Plan: Pro

    📥 Commits

    Reviewing files that changed from the base of the PR and between 972096e and b3b6fae.

    📒 Files selected for processing (3)
    • README.md (1 hunks)
    • addon.py (4 hunks)
    • src/blender_mcp/server.py (2 hunks)
    🧰 Additional context used
    🪛 LanguageTool
    README.md

    [uncategorized] ~130-~130: A comma might be missing here.
    Context: ...s If connecting to blender on a remote machine pass the host name to the blender mcp s...

    (AI_EN_LECTOR_MISSING_PUNCTUATION_COMMA)

    🔇 Additional comments (5)
    src/blender_mcp/server.py (2)

    20-21: LGTM! Clean environment variable configuration.

    The implementation correctly uses an environment variable to make the Blender host configurable while providing a sensible default of "localhost". This enables remote connections as intended.


    231-231: LGTM! Proper usage of configurable host.

    The BlenderConnection instantiation correctly uses the module-level variables, making the connection configurable via the environment variable.

    addon.py (3)

    389-389: LGTM! UI addition follows Blender conventions.

    The checkbox addition to the UI panel is well-integrated and follows Blender's property display patterns.


    466-470: LGTM! Property registration follows best practices.

    The new boolean property is properly registered with appropriate name, description, and default value.

    🧰 Tools
    🪛 Ruff (0.11.9)

    466-466: Do not use bare except

    (E722)


    1525-1525: LGTM! Proper cleanup in unregister function.

    The property is correctly cleaned up in the unregister function, following Blender addon best practices.

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

    Projects

    None yet

    Development

    Successfully merging this pull request may close these issues.

    1 participant