langchain-ai/deepagents · error · ValueError

Server '{server_name}' uses {transport!r} transport; OAuth l

Error message

Server '{server_name}' uses {transport!r} transport; OAuth login is only valid for http/sse.

What it means

`login` raises this ValueError when asked to perform OAuth device-flow login against an MCP server whose resolved transport is not `http` or `sse` (typically `stdio`). OAuth login only makes sense for remote HTTP servers; local stdio processes cannot perform a browser handshake.

Source

Thrown at libs/code/deepagents_code/mcp_auth.py:2192

    """  # noqa: DOC502 - `RuntimeError` surfaces via the device flow / handshake
    from langchain_mcp_adapters.sessions import (
        SSEConnection,
        StreamableHttpConnection,
    )

    from deepagents_code.mcp_tools import MCPConfigError, _resolve_server_type

    # OAuth login is discovery-based (RFC 9728), so it works for any remote
    # http/sse server — whether the config opted in with `auth: oauth` or the
    # server was auto-detected as needing auth via a 401 challenge. Only the
    # transport needs gating; stdio servers can't speak OAuth.
    transport = _resolve_server_type(server_config)
    if transport not in {"http", "sse"}:
        msg = (
            f"Server '{server_name}' uses {transport!r} transport; "
            "OAuth login is only valid for http/sse."
        )
        raise ValueError(msg)
    try:
        resolved_config = resolve_mcp_server_env(server_name, server_config)
    except (RuntimeError, TypeError) as exc:
        # Re-raise as MCPConfigError (a ValueError) so callers' existing
        # config-error handling catches it, and `format_login_failure`
        # preserves the actionable, field-scoped message instead of
        # collapsing it to a bare "RuntimeError"/"TypeError".
        raise MCPConfigError(str(exc)) from exc

    from deepagents_code.mcp_providers import resolve_provider

    storage = FileTokenStorage(server_name, server_url=resolved_config["url"])
    policy = resolve_provider(resolved_config["url"])
    result = await policy.run_login(
        server_name=server_name,
        server_url=resolved_config["url"],
        storage=storage,
        ui=ui,

View on GitHub (pinned to a1af029e6e)

Solutions

  1. Confirm the server name passed to `login` refers to a remote server with a `url` and http/sse transport in your MCP config
  2. If the server should be remote, fix the config entry to set transport `http` or `sse` with a valid URL
  3. Skip OAuth login for stdio servers — they authenticate via their own launch environment, not OAuth
  4. Check `_resolve_server_type`'s inferred type if your config omits an explicit `type` field

Example fix

// before: login against a stdio server
$ dcode mcp login my-local-tool  # my-local-tool: {"command": "npx", ...}
ValueError: Server 'my-local-tool' uses 'stdio' transport...
// after
$ dcode mcp login my-remote-tool  # {"type": "http", "url": "https://..."}
Defensive patterns

Strategy: validation

Validate before calling

from deepagents_code.mcp_auth import _resolve_server_type

def can_oauth_login(server_name: str, server_config: dict) -> bool:
    return _resolve_server_type(server_config) in {"http", "sse"}

# before calling login:
if not can_oauth_login(name, config):
    print(f"{name} is not an http/sse server; OAuth login is not applicable")

Try / catch

try:
    login(server_name)
except ValueError as exc:
    if "OAuth login is only valid for http/sse" in str(exc):
        print(f"{server_name} is a local server; skip OAuth login.")
    else:
        raise

Prevention

When it happens

Trigger: Running `run_mcp_login` (or the `dcode mcp login` CLI) with a server name whose config resolves to a `stdio` (or other non-http/sse) transport in the MCP config file.

Common situations: Passing a locally-launched stdio server name to the login command by mistake; config file entry missing a `type`/`url` field so the resolver defaults to stdio; copying a server entry meant for local subprocess use into the login command.

Related errors


AI-assisted analysis of langchain-ai/deepagents@a1af029e6e (2026-08-29). Data as JSON: /api/errors/526c4f330047d04d. Report an issue: GitHub.