Skip to content

Commit eeaf45c

Browse files
authored
Add files via upload
1 parent 276f313 commit eeaf45c

4 files changed

Lines changed: 307 additions & 112 deletions

File tree

CHANGELOG.md

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
# Changelog
2+
3+
All notable changes to vSphere-MCP-Pro will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [0.2.0] - 2025-12-23
9+
10+
### Added
11+
12+
- **`VsphereApiError` exception class** - Custom exception with rich error context including:
13+
- HTTP status code
14+
- vCenter error type extraction (supports both `/api` and `/rest` response formats)
15+
- Human-readable error messages from vCenter
16+
- Convenience properties: `is_not_found`, `is_unauthorized`, `is_forbidden`, `is_conflict`
17+
18+
- **`VsphereClientPool` class** - Thread-safe connection pooling:
19+
- Maintains one authenticated session per vCenter host
20+
- Automatic session reuse to prevent vCenter session exhaustion
21+
- `atexit` hook for graceful cleanup on process termination
22+
- `get()`, `remove()`, `close_all()` methods
23+
- `size` and `hosts` properties for observability
24+
25+
- **`VsphereClient.logout()` method** - Properly terminates vCenter sessions via DELETE to session endpoint
26+
27+
- **`VsphereClient.close()` method** - Calls `logout()` then closes the underlying `requests.Session`
28+
29+
- **`VsphereClient.host` property** - Clean accessor for the configured hostname
30+
31+
- **`VsphereClient.is_authenticated` property** - Check if session token is present
32+
33+
- **Response validation** - All API methods now validate responses via `_check_response()`:
34+
- Raises `VsphereApiError` on non-2xx responses
35+
- Supports `allow_statuses` for operations like DELETE that return 204
36+
- Descriptive error messages include operation context
37+
38+
- **Helper methods in `VsphereClient`**:
39+
- `_safe_json()` - Safely parse JSON responses without raising
40+
- `_check_response()` - Validate HTTP response and raise on error
41+
- `_extract_value()` - Handle `/api` vs `/rest` response format differences
42+
43+
### Changed
44+
45+
- **Fixed decorator pattern in `server.py`** - Converted `inject` from broken function to proper decorator factory:
46+
```python
47+
# Before (broken - caused TypeError)
48+
@inject
49+
def list_vms(...): ...
50+
51+
# After (working)
52+
@inject("list_vms")
53+
def list_vms(...): ...
54+
```
55+
56+
- **Destructive operations now properly flagged** - Added `destructive=True` to:
57+
- `delete_vm`
58+
- `delete_vm_snapshot`
59+
- `modify_vm_resources`
60+
61+
- **Session management refactored** - Replaced per-request client creation with `VsphereClientPool`:
62+
- Single pool instance created in `build_server()`
63+
- Pool injected into all tools via `_pool` parameter
64+
- Significantly reduces vCenter session consumption
65+
66+
- **Improved error messages** - API errors now include full context:
67+
```
68+
VsphereApiError: Failed to get VM 'vm-999': HTTP 404 on /api/vcenter/vm/vm-999 [NOT_FOUND]: The VM was not found.
69+
```
70+
71+
### Fixed
72+
73+
- **Dockerfile path error** - Changed `COPY src /app/src` to `COPY vsphere_mcp_pro /app/vsphere_mcp_pro`
74+
75+
- **Session leak** - Previous implementation created new session per API call without logout; now properly pooled and cleaned up
76+
77+
- **Silent API failures** - Methods previously returned error JSON as if successful; now raise `VsphereApiError`
78+
79+
### Deprecated
80+
81+
- None
82+
83+
### Removed
84+
85+
- `client_for()` helper function in `server.py` - Replaced by `VsphereClientPool.get()`
86+
87+
### Security
88+
89+
- Sessions are now properly terminated on shutdown via `atexit` hook
90+
- Reduced attack surface by limiting active vCenter sessions
91+
92+
## [0.1.0] - Initial Release
93+
94+
### Added
95+
96+
- Initial MCP server implementation for VMware vCenter 8.0+
97+
- VM lifecycle management (power on/off/reset, delete)
98+
- Snapshot operations (list, create, delete)
99+
- Inventory discovery (VMs, hosts, datastores, networks, datacenters)
100+
- Resource modification (CPU, memory)
101+
- Token-based RBAC authorization
102+
- Token bucket rate limiting
103+
- JSONL audit logging
104+
- SSL verification with optional CA bundle
105+
- Allowed-host enforcement
106+
- Support for both `/api` and `/rest` vCenter endpoints

Dockerfile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@ WORKDIR /app
77
ENV PYTHONDONTWRITEBYTECODE=1 PYTHONUNBUFFERED=1
88

99
COPY pyproject.toml /app/
10-
RUN pip install --no-cache-dir --upgrade pip && pip install --no-cache-dir .
10+
RUN pip install --no-cache-dir --upgrade pip && \
11+
pip install --no-cache-dir .
1112

12-
COPY src /app/src
13-
COPY .env.example /app/.env.example
13+
COPY vsphere_mcp_pro /app/vsphere_mcp_pro
14+
COPY env.example /app/env.example
1415

1516
USER appuser
1617

0 commit comments

Comments
 (0)