Merge pull request #126 from cageyv/main
add environment variables configuration for Blender connection host and port
This commit is contained in:
commit
a6ca7509d1
12
README.md
12
README.md
@ -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
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user