Windows-drive-status
Retrieve used and free space details for a Windows drive, including total, used, and free capacity.
Instructions
Get status information about the used and free space in a Windows drive
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| drive | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Drive name | |
| used_spaceGB | Yes | Used space in GB | |
| free_spaceGB | Yes | Free space in GB |
Implementation Reference
- main.py:100-116 (handler)The handler function `get_drive_status` that implements the 'Windows-drive-status' tool. It normalizes the drive letter, checks existence, and returns used/free space in GB using utils._disk_usage_gb.
def get_drive_status(drive: str) -> DriveInfo: """Get status information about the used and free space in a Windows drive.""" import os try: # Normalize drive letter and construct root path drive_letter = drive.strip().upper().rstrip(':\\/') if len(drive_letter) != 1 or not drive_letter.isalpha(): return DriveInfo(name=drive, used_spaceGB=0.0, free_spaceGB=0.0) root = f"{drive_letter}:\\" if not os.path.exists(root): return DriveInfo(name=drive_letter, used_spaceGB=0.0, free_spaceGB=0.0) used_gb, free_gb = utils._disk_usage_gb(root) return DriveInfo(name=drive_letter, used_spaceGB=used_gb, free_spaceGB=free_gb) except Exception: return DriveInfo(name=drive, used_spaceGB=0.0, free_spaceGB=0.0) - main.py:13-17 (schema)The `DriveInfo` Pydantic model used as the return type for the handler, defining name, used_spaceGB, and free_spaceGB fields.
class DriveInfo(BaseModel): """Model for drive information.""" name: str = Field(description="Drive name") used_spaceGB: float = Field(description="Used space in GB") free_spaceGB: float = Field(description="Free space in GB") - main.py:96-98 (registration)The `@mcp.tool` decorator that registers the 'Windows-drive-status' tool with FastMCP, including its name and description.
@mcp.tool( name="Windows-drive-status", description="Get status information about the used and free space in a Windows drive", - utils.py:11-17 (helper)The helper utility `_disk_usage_gb` called by the handler to compute used and free disk space in GB using shutil.disk_usage.
def _disk_usage_gb(root: str) -> tuple[float, float]: """Return used and free space in GB for a given root like 'C:\\'.""" import shutil total, used, free = shutil.disk_usage(root) gb = 1024 ** 3 return used / gb, free / gb