Skip to main content
Glama

get_snapshot

Retrieve a specific web archive snapshot by its ID from ArchiveBox, including archived content results for analysis or restoration.

Instructions

Get a specific Snapshot by abid or id.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
snapshot_idYesThe ID or abid of the snapshot
with_archiveresultsNoWhether to include archiveresults

Implementation Reference

  • The primary MCP tool handler for 'get_snapshot'. This function is decorated with @mcp.tool, defining both the registration and the execution logic. It creates an ArchiveBox API client and calls its get_snapshot method to retrieve the snapshot data.
    @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()
  • Pydantic Field definitions for the input schema of the get_snapshot tool, including descriptions and defaults.
    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",
    ),
  • Helper method in the Api class that performs the actual HTTP GET request to the ArchiveBox API endpoint /api/v1/core/snapshot/{snapshot_id} to fetch the snapshot data.
    @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
  • Utility helper function used to convert string environment variables to boolean for the 'verify' parameter.
    def to_boolean(string: Union[str, bool] = None) -> bool:
        if isinstance(string, bool):
            return string
        if not string:
            return False
        normalized = str(string).strip().lower()
        true_values = {"t", "true", "y", "yes", "1"}
        false_values = {"f", "false", "n", "no", "0"}
        if normalized in true_values:
            return True
        elif normalized in false_values:
            return False
        else:
            raise ValueError(f"Cannot convert '{string}' to boolean")
  • The @mcp.tool decorator registers the get_snapshot function as an MCP tool, excluding certain auth args from the tool schema and tagging it as 'core'.
    @mcp.tool(
        exclude_args=[
            "archivebox_url",
            "username",
            "password",
            "token",
            "api_key",
            "verify",
        ],
        tags={"core"},

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Knuckles-Team/archivebox-api'

If you have feedback or need assistance with the MCP directory API, please join our Discord server