Windows-drives-status-simple
Retrieve status for specific Windows drives by inputting a comma-separated list of drive letters like 'C,D,F'.
Instructions
Get status for specific drives using a comma-separated drive letters as string (e.g., 'C,D,F')
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| drives_string | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- main.py:118-126 (handler)The tool handler function 'get_drives_status_simple' that executes the logic. It parses a comma-separated string of drive letters, calls the existing 'get_drive_status' for each drive, and returns a list of DriveInfo.
@mcp.tool( name="Windows-drives-status-simple", description="Get status for specific drives using a comma-separated drive letters as string (e.g., 'C,D,F')", ) def get_drives_status_simple(drives_string: str) -> list[DriveInfo]: """Get status for specific drives using a comma-separated drive letters as string (e.g., 'C,D,F')""" # Parse the comma-separated string into a list drives = [drive.strip().rstrip(':') for drive in drives_string.split(',')] return [get_drive_status(drive) for drive in drives if drive] - main.py:118-121 (registration)The @mcp.tool decorator that registers the tool with name 'Windows-drives-status-simple' and its description.
@mcp.tool( name="Windows-drives-status-simple", description="Get status for specific drives using a comma-separated drive letters as string (e.g., 'C,D,F')", ) - main.py:13-17 (schema)The DriveInfo Pydantic model used as the return type (list[DriveInfo]) for the tool.
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-116 (helper)The 'get_drive_status' helper function called by the tool to get status for a single drive.
@mcp.tool( name="Windows-drive-status", description="Get status information about the used and free space in a Windows drive", ) 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) - utils.py:11-17 (helper)The '_disk_usage_gb' utility function used by 'get_drive_status' to calculate used/free space in GB.
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