{"record":{"id":"526c4f330047d04d","repo":"langchain-ai/deepagents","slug":"server-server-name-uses-transport-r-transpor","errorCode":null,"errorMessage":"Server '{server_name}' uses {transport!r} transport; OAuth login is only valid for http/sse.","messagePattern":"Server '(.+?)' uses (.+?) transport; OAuth login is only valid for http/sse\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"libs/code/deepagents_code/mcp_auth.py","lineNumber":2192,"sourceCode":"    \"\"\"  # noqa: DOC502 - `RuntimeError` surfaces via the device flow / handshake\n    from langchain_mcp_adapters.sessions import (\n        SSEConnection,\n        StreamableHttpConnection,\n    )\n\n    from deepagents_code.mcp_tools import MCPConfigError, _resolve_server_type\n\n    # OAuth login is discovery-based (RFC 9728), so it works for any remote\n    # http/sse server — whether the config opted in with `auth: oauth` or the\n    # server was auto-detected as needing auth via a 401 challenge. Only the\n    # transport needs gating; stdio servers can't speak OAuth.\n    transport = _resolve_server_type(server_config)\n    if transport not in {\"http\", \"sse\"}:\n        msg = (\n            f\"Server '{server_name}' uses {transport!r} transport; \"\n            \"OAuth login is only valid for http/sse.\"\n        )\n        raise ValueError(msg)\n    try:\n        resolved_config = resolve_mcp_server_env(server_name, server_config)\n    except (RuntimeError, TypeError) as exc:\n        # Re-raise as MCPConfigError (a ValueError) so callers' existing\n        # config-error handling catches it, and `format_login_failure`\n        # preserves the actionable, field-scoped message instead of\n        # collapsing it to a bare \"RuntimeError\"/\"TypeError\".\n        raise MCPConfigError(str(exc)) from exc\n\n    from deepagents_code.mcp_providers import resolve_provider\n\n    storage = FileTokenStorage(server_name, server_url=resolved_config[\"url\"])\n    policy = resolve_provider(resolved_config[\"url\"])\n    result = await policy.run_login(\n        server_name=server_name,\n        server_url=resolved_config[\"url\"],\n        storage=storage,\n        ui=ui,","sourceCodeStart":2174,"sourceCodeEnd":2210,"githubUrl":"https://github.com/langchain-ai/deepagents/blob/a1af029e6e73cb17c36bff823d227747b28e91e1/libs/code/deepagents_code/mcp_auth.py#L2174-L2210","documentation":"`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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Confirm the server name passed to `login` refers to a remote server with a `url` and http/sse transport in your MCP config","If the server should be remote, fix the config entry to set transport `http` or `sse` with a valid URL","Skip OAuth login for stdio servers — they authenticate via their own launch environment, not OAuth","Check `_resolve_server_type`'s inferred type if your config omits an explicit `type` field"],"exampleFix":"// before: login against a stdio server\n$ dcode mcp login my-local-tool  # my-local-tool: {\"command\": \"npx\", ...}\nValueError: Server 'my-local-tool' uses 'stdio' transport...\n// after\n$ dcode mcp login my-remote-tool  # {\"type\": \"http\", \"url\": \"https://...\"}","handlingStrategy":"validation","validationCode":"from deepagents_code.mcp_auth import _resolve_server_type\n\ndef can_oauth_login(server_name: str, server_config: dict) -> bool:\n    return _resolve_server_type(server_config) in {\"http\", \"sse\"}\n\n# before calling login:\nif not can_oauth_login(name, config):\n    print(f\"{name} is not an http/sse server; OAuth login is not applicable\")","typeGuard":null,"tryCatchPattern":"try:\n    login(server_name)\nexcept ValueError as exc:\n    if \"OAuth login is only valid for http/sse\" in str(exc):\n        print(f\"{server_name} is a local server; skip OAuth login.\")\n    else:\n        raise","preventionTips":["Only run `dcode mcp login` for servers with a remote url and http/sse type in your MCP config","Add an explicit `type` field to remote server entries so the resolver does not fall back to stdio","Keep a mental (or scripted) separation between local stdio servers and remote OAuth servers"],"tags":["oauth","configuration","transport","stdio","mcp"],"backgroundTag":"unsupported-transport-for-oauth","analyzedSha":"a1af029e6e73cb17c36bff823d227747b28e91e1","analyzedAt":"2026-08-29T11:43:24.718Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}