Merge pull request #126 from cageyv/main

add environment variables configuration for Blender connection host and port
This commit is contained in:
ahujasid 2025-08-21 12:43:16 -07:00 committed by GitHub
commit a6ca7509d1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 19 additions and 1 deletions

View File

@ -91,6 +91,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

View File

@ -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
@ -225,7 +229,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