INNER CODE UNIT · Python

_authorization_code_result

knowsuchagency/mcp2cli · src/mcp2cli/__init__.py:418

def _authorization_code_result(code: str, state: str | None, iss: str | None = None):
    """Wrap a callback result in whatever ``callback_handler`` must return.

    v1 expects a plain ``(code, state)`` tuple; v2 expects an
    ``AuthorizationCodeResult`` model. ``iss`` is the RFC 9207
    authorization-response issuer: when the authorization server advertises it
    in its metadata, the SDK validates the redirect's ``iss`` and fails the
    flow if the value never reaches it.
    """
    try:
        from mcp.shared.auth import AuthorizationCodeResult
    except ImportError:
        return (code, state)
    return AuthorizationCodeResult(code=code, state=state, iss=iss)


def _ensure_utf8_output() -> None:
    """Make non-ASCII output safe on consoles that cannot encode it.

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…