Skip to main content
Glama

get_api_token

Generate API tokens for authenticated access to ArchiveBox's web archiving features, enabling programmatic control over URL archiving and snapshot management.

Instructions

Generate an API token for a given username & password.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The primary MCP tool handler for 'get_api_token'. Decorated with @mcp.tool(), defines input schema via Pydantic Field descriptions, creates an ArchiveBox Api client instance, calls the client's get_api_token method to perform the actual API request, and returns the JSON response.
    @mcp.tool(
        exclude_args=[
            "archivebox_url",
            "username",
            "password",
            "token",
            "api_key",
            "verify",
        ],
        tags={"authentication"},
    )
    def get_api_token(
        username: Optional[str] = Field(
            description="The username for authentication",
        ),
        password: Optional[str] = Field(
            description="The password for authentication",
        ),
        archivebox_url: str = Field(
            default=os.environ.get("ARCHIVEBOX_URL", None),
            description="The URL of the ArchiveBox instance (e.g., https://yourinstance.archivebox.com)",
        ),
        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:
        """
        Generate an API token for a given username & password.
        """
        client = Api(
            url=archivebox_url,
            username=username,
            password=password,
            token=token,
            api_key=api_key,
            verify=verify,
        )
        response = client.get_api_token(username=username, password=password)
        return response.json()
  • Supporting helper method in the Api class that executes the HTTP POST request to the ArchiveBox server's /api/v1/auth/get_api_token endpoint with the provided username and password to obtain the API token.
    def get_api_token(
        self, username: Optional[str] = None, password: Optional[str] = None
    ) -> requests.Response:
        """
        Generate an API token for a given username & password
    
        Args:
            username: The username for authentication.
            password: The password for authentication.
    
        Returns:
            Response: The response object from the POST request.
    
        Raises:
            ParameterError: If the provided parameters are invalid.
        """
        try:
            data = {}
            if username is not None:
                data["username"] = username
            if password is not None:
                data["password"] = password
            response = self._session.post(
                url=f"{self.url}/api/v1/auth/get_api_token",
                json=data,
                headers={"Content-Type": "application/json"},
                verify=self.verify,
            )
        except ValidationError as e:
            raise ParameterError(f"Invalid parameters: {e.errors()}")
        return response
  • Utility helper function used to convert the 'verify' parameter string from environment variable to boolean.
    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")
  • Initialization of the FastMCP server instance where tools like get_api_token are registered via decorators.
    mcp = FastMCP("ArchiveBox")
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden. It states 'generate' which implies a creation/mutation operation, but doesn't disclose behavioral traits like whether this requires specific permissions, if tokens are persistent, rate limits, or what the output contains. The description is minimal and lacks critical context for a token generation tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that directly states the tool's purpose without any wasted words. It is appropriately sized and front-loaded, making it easy to understand at a glance.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given that there is an output schema (which should cover return values), no parameters, and no annotations, the description is minimally complete. However, for a tool that generates API tokens—a potentially sensitive operation—it lacks details on authentication, security implications, or usage context, which are important for an agent to use it correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 0 parameters with 100% coverage, so no parameters need documentation. The description adds value by implying that username and password are involved in the process, though it doesn't specify them as formal parameters. Baseline is 4 for zero parameters, as the description provides some semantic context beyond the empty schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb 'generate' and the resource 'API token', specifying it's for a given username and password. However, it doesn't differentiate from sibling tools like 'check_api_token' or 'get_any', which could also involve API tokens or retrieval operations.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives such as 'check_api_token' for verification or 'get_any' for other retrieval. It mentions the context of username and password but doesn't specify prerequisites, authentication needs, or exclusions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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