# How the BlenderConnection Class Manages Connection Lifecycle and Reconnection in blender-mcp

> Discover how the BlenderConnection class in blender-mcp manages connection lifecycle and automatic reconnection using a dual-layer validation strategy for robust error handling.

- Repository: [ahujasid/blender-mcp](https://github.com/ahujasid/blender-mcp)
- Tags: internals
- Published: 2026-04-13

---

**The `BlenderConnection` class in `ahujasid/blender-mcp` implements a robust TCP socket client that handles automatic reconnection through a dual-layer validation strategy involving local socket clearing on errors and global connection health checks before every command execution.**

The `BlenderConnection` class serves as the low-level socket client that bridges the MCP server and Blender addon in the `ahujasid/blender-mcp` repository. Defined in [`src/blender_mcp/server.py`](https://github.com/ahujasid/blender-mcp/blob/main/src/blender_mcp/server.py), this class orchestrates the entire connection lifecycle—from initial TCP handshake to graceful