extract_file
Extract specific files from remote zip archives over HTTP, HTTPS, or FTP without downloading the entire archive, saving time and bandwidth.
Instructions
Extract a specific file from a remote zip archive to local storage.
Args:
url: URL of the remote zip file
filename: Name of the file to extract
local_path: Local directory to extract to (default: current directory)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| filename | Yes | ||
| local_path | No | . | |
| url | Yes |
Implementation Reference
- remotezip_server.py:22-22 (registration)The @mcp.tool() decorator registers the extract_file function as an MCP tool.@mcp.tool()
- remotezip_server.py:23-36 (handler)The extract_file handler function implements the core logic: opens the remote ZIP using RemoteZip, extracts the specified file to the local path, and returns success or error message.async def extract_file(url: str, filename: str, local_path: str = ".") -> str: """Extract a specific file from a remote zip archive to local storage. Args: url: URL of the remote zip file filename: Name of the file to extract local_path: Local directory to extract to (default: current directory) """ try: with RemoteZip(url) as zip_file: zip_file.extract(filename, local_path) return f"Extracted {filename} to {local_path}" except Exception as e: return f"Error extracting file: {str(e)}"