UnauthenticatedError (core/api_client.py)

mcp-agent · src/mcp_agent/cli/core/api_client.py · python · Apache-2.0
auth

Async HTTP client for MCP Agent Cloud API with error handling and authentication support.

# Source: https://github.com/lastmile-ai/mcp-agent | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
# Provided via justclaw.it.com; keep this notice with the code.
"""API client implementation for the MCP Agent Cloud API."""

import json
from typing import Any, Dict, Optional

import httpx


class UnauthenticatedError(Exception):
    """Raised when the API client is unauthenticated (e.g., redirected to login)."""

    pass


def _raise_for_unauthenticated(response: httpx.Response):
    """Check if the response indicates an unauthenticated request.
    Raises:
        UnauthenticatedError: If the response status code is 401 or 403.
    """
    if response.status_code == 401 or (
        response.status_code == 307
        and "/api/auth/signin" i

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key