get_snapshot
Retrieve a specific web archive snapshot by its ID to access preserved webpage content and detailed archiving results for reference or analysis.
Instructions
Get a specific Snapshot by abid or id.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| snapshot_id | Yes | The ID or abid of the snapshot | |
| with_archiveresults | No | Whether to include archiveresults |
Implementation Reference
- archivebox_api/archivebox_mcp.py:270-328 (handler)MCP tool handler for 'get_snapshot': registers the tool with @mcp.tool decorator and implements the logic by instantiating Api client and calling its get_snapshot method to fetch and return the snapshot data as JSON.@mcp.tool( exclude_args=[ "archivebox_url", "username", "password", "token", "api_key", "verify", ], tags={"core"}, ) def get_snapshot( snapshot_id: str = Field( description="The ID or abid of the snapshot", ), with_archiveresults: bool = Field( True, description="Whether to include archiveresults" ), archivebox_url: str = Field( default=os.environ.get("ARCHIVEBOX_URL", None), description="The URL of the ArchiveBox instance", ), username: Optional[str] = Field( default=os.environ.get("ARCHIVEBOX_USERNAME", None), description="Username for authentication", ), password: Optional[str] = Field( default=os.environ.get("ARCHIVEBOX_PASSWORD", None), description="Password for authentication", ), token: Optional[str] = Field( default=os.environ.get("ARCHIVEBOX_TOKEN", None), description="Bearer token for authentication", ), api_key: Optional[str] = Field( default=os.environ.get("ARCHIVEBOX_API_KEY", None), description="API key for authentication", ), verify: Optional[bool] = Field( default=to_boolean(os.environ.get("ARCHIVEBOX_VERIFY", "True")), description="Whether to verify SSL certificates", ), ) -> dict: """ Get a specific Snapshot by abid or id. """ client = Api( url=archivebox_url, username=username, password=password, token=token, api_key=api_key, verify=verify, ) response = client.get_snapshot( snapshot_id=snapshot_id, with_archiveresults=with_archiveresults, ) return response.json()
- Helper method in Api class: performs the HTTP GET request to retrieve a specific snapshot by ID or abid, used by the MCP tool handler.@require_auth def get_snapshot( self, snapshot_id: str, with_archiveresults: bool = True ) -> requests.Response: """ Get a specific Snapshot by abid or id Args: snapshot_id: The ID or abid of the snapshot. with_archiveresults: Whether to include archiveresults (default: True). Returns: Response: The response object from the GET request. Raises: ParameterError: If the provided parameters are invalid. """ try: response = self._session.get( url=f"{self.url}/api/v1/core/snapshot/{snapshot_id}", params={"with_archiveresults": with_archiveresults}, headers=self.headers, verify=self.verify, ) except ValidationError as e: raise ParameterError(f"Invalid parameters: {e.errors()}") return response