add environment variables configuration for Blender connection host and port
This commit is contained in:
parent
9b1ac7dca2
commit
7c294217ff
12
README.md
12
README.md
@ -85,6 +85,18 @@ Otherwise installation instructions are on their website: [Install uv](https://d
|
|||||||
|
|
||||||
**⚠️ Do not proceed before installing UV**
|
**⚠️ 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
|
### Claude for Desktop Integration
|
||||||
|
|
||||||
|
|||||||
@ -18,6 +18,10 @@ logging.basicConfig(level=logging.INFO,
|
|||||||
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
|
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
|
||||||
logger = logging.getLogger("BlenderMCPServer")
|
logger = logging.getLogger("BlenderMCPServer")
|
||||||
|
|
||||||
|
# Default configuration
|
||||||
|
DEFAULT_HOST = "localhost"
|
||||||
|
DEFAULT_PORT = 9876
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class BlenderConnection:
|
class BlenderConnection:
|
||||||
host: str
|
host: str
|
||||||
@ -226,7 +230,9 @@ def get_blender_connection():
|
|||||||
|
|
||||||
# Create a new connection if needed
|
# Create a new connection if needed
|
||||||
if _blender_connection is None:
|
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():
|
if not _blender_connection.connect():
|
||||||
logger.error("Failed to connect to Blender")
|
logger.error("Failed to connect to Blender")
|
||||||
_blender_connection = None
|
_blender_connection = None
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user