Skip to content

Commit a6ca750

Browse files
authored
Merge pull request #126 from cageyv/main
add environment variables configuration for Blender connection host and port
2 parents a35a1e1 + 7c29421 commit a6ca750

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,18 @@ Otherwise installation instructions are on their website: [Install uv](https://d
9191

9292
**⚠️ Do not proceed before installing UV**
9393

94+
### Environment Variables
95+
96+
The following environment variables can be used to configure the Blender connection:
97+
98+
- `BLENDER_HOST`: Host address for Blender socket server (default: "localhost")
99+
- `BLENDER_PORT`: Port number for Blender socket server (default: 9876)
100+
101+
Example:
102+
```bash
103+
export BLENDER_HOST='host.docker.internal'
104+
export BLENDER_PORT=9876
105+
```
94106

95107
### Claude for Desktop Integration
96108

src/blender_mcp/server.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
1919
logger = logging.getLogger("BlenderMCPServer")
2020

21+
# Default configuration
22+
DEFAULT_HOST = "localhost"
23+
DEFAULT_PORT = 9876
24+
2125
@dataclass
2226
class BlenderConnection:
2327
host: str
@@ -225,7 +229,9 @@ def get_blender_connection():
225229

226230
# Create a new connection if needed
227231
if _blender_connection is None:
228-
_blender_connection = BlenderConnection(host="localhost", port=9876)
232+
host = os.getenv("BLENDER_HOST", DEFAULT_HOST)
233+
port = int(os.getenv("BLENDER_PORT", DEFAULT_PORT))
234+
_blender_connection = BlenderConnection(host=host, port=port)
229235
if not _blender_connection.connect():
230236
logger.error("Failed to connect to Blender")
231237
_blender_connection = None

0 commit comments

Comments
 (0)