diff --git a/README.md b/README.md index 022a29d..598d1e8 100644 --- a/README.md +++ b/README.md @@ -85,6 +85,18 @@ Otherwise installation instructions are on their website: [Install uv](https://d **⚠️ Do not proceed before installing UV** +### Environment Variables + +The following environment variables can be used to configure the Blender connection: + +- `BLENDER_HOST`: Host address for Blender socket server (default: "localhost") +- `BLENDER_PORT`: Port number for Blender socket server (default: 9876) + +Example: +```bash +export BLENDER_HOST='host.docker.internal' +export BLENDER_PORT=9876 +``` ### Claude for Desktop Integration diff --git a/src/blender_mcp/server.py b/src/blender_mcp/server.py index 141f439..d67106b 100644 --- a/src/blender_mcp/server.py +++ b/src/blender_mcp/server.py @@ -18,6 +18,10 @@ logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s') logger = logging.getLogger("BlenderMCPServer") +# Default configuration +DEFAULT_HOST = "localhost" +DEFAULT_PORT = 9876 + @dataclass class BlenderConnection: host: str @@ -226,7 +230,9 @@ def get_blender_connection(): # Create a new connection if needed if _blender_connection is None: - _blender_connection = BlenderConnection(host="localhost", port=9876) + host = os.getenv("BLENDER_HOST", DEFAULT_HOST) + port = int(os.getenv("BLENDER_PORT", DEFAULT_PORT)) + _blender_connection = BlenderConnection(host=host, port=port) if not _blender_connection.connect(): logger.error("Failed to connect to Blender") _blender_connection = None