{"record":{"id":"2d90d15e1ae4ed8b","repo":"PrefectHQ/fastmcp","slug":"multiauth-requires-at-least-a-server-or-one-verifi","errorCode":null,"errorMessage":"MultiAuth requires at least a server or one verifier","messagePattern":"MultiAuth requires at least a server or one verifier","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"fastmcp_slim/fastmcp/server/auth/auth.py","lineNumber":698,"sourceCode":"        \"\"\"Initialize the multi-auth provider.\n\n        Args:\n            server: Optional auth provider (e.g., OAuthProxy) that owns routes\n                and OAuth metadata. Also participates in token verification as\n                the first verifier tried.\n            verifiers: One or more token verifiers to try after the server.\n            base_url: Override the base URL. Defaults to the server's base_url.\n            resource_base_url: Override the protected resource base URL. Defaults\n                to the server's resource_base_url when available.\n            required_scopes: Override required scopes. Defaults to the server's.\n        \"\"\"\n        if verifiers is None:\n            verifiers = []\n        elif isinstance(verifiers, TokenVerifier):\n            verifiers = [verifiers]\n\n        if server is None and not verifiers:\n            raise ValueError(\"MultiAuth requires at least a server or one verifier\")\n\n        effective_base_url = base_url or (server.base_url if server else None)\n        effective_resource_base_url = resource_base_url or (\n            server.resource_base_url if server else None\n        )\n        effective_scopes = (\n            required_scopes\n            if required_scopes is not None\n            else (server.required_scopes if server else None)\n        )\n\n        super().__init__(\n            base_url=effective_base_url,\n            resource_base_url=effective_resource_base_url,\n            required_scopes=effective_scopes,\n        )\n        self.server = server\n        self.verifiers = list(verifiers)","sourceCodeStart":680,"sourceCodeEnd":716,"githubUrl":"https://github.com/PrefectHQ/fastmcp/blob/1f021142978e0861cd910c8df4e8074bc7cf3978/fastmcp_slim/fastmcp/server/auth/auth.py#L680-L716","documentation":"A ValueError raised in MultiAuth.__init__ when constructed with neither a FastMCP server instance nor any token verifiers. MultiAuth composes authentication from a server's provider and/or a list of TokenVerifiers; with both empty there is nothing to authenticate with, so construction is rejected immediately.","triggerScenarios":"MultiAuth() with no arguments; MultiAuth(server=None, verifiers=None); MultiAuth(server=None, verifiers=[]) — all reach the 'if server is None and not verifiers' branch and raise.","commonSituations":"Programmatic config where the server or verifier list is built conditionally and ends up empty (e.g. env-var-driven setup that skipped verifier creation); assuming a list of None entries counts; copy-pasting a MultiAuth snippet without filling in the verifiers.","solutions":["Pass at least one TokenVerifier: MultiAuth(verifiers=[JWTVerifier(...)]).","Or pass a FastMCP server whose auth provider should be composed: MultiAuth(server=mcp).","Log/assert the verifier list length before constructing MultiAuth to catch empty-config cases."],"exampleFix":"// before\nauth = MultiAuth(server=None, verifiers=verifiers or [])\n// after\nif not verifiers:\n    raise ValueError('No verifiers configured for MultiAuth')\nauth = MultiAuth(verifiers=verifiers)","handlingStrategy":"validation","validationCode":"verifiers = [v for v in verifiers or [] if v is not None]\nif server is None and not verifiers:\n    raise ValueError('Configure at least one TokenVerifier or a FastMCP server before MultiAuth')\nauth = MultiAuth(server=server, verifiers=verifiers)","typeGuard":null,"tryCatchPattern":"try:\n    auth = MultiAuth(server=server, verifiers=verifiers)\nexcept ValueError as e:\n    logger.error('MultiAuth misconfiguration: %s', e)\n    raise SystemExit(1) from e","preventionTips":["Assert the verifier list is non-empty after building it (assert len(verifiers) > 0).","Filter out None entries before passing the list — they don't satisfy the 'at least one' requirement.","Fail fast at startup when env-var-driven auth config resolves to neither a server nor verifiers."],"tags":["python","configuration","multiauth","auth"],"backgroundTag":"missing-required-argument","analyzedSha":"1f021142978e0861cd910c8df4e8074bc7cf3978","analyzedAt":"2026-08-29T14:31:16.082Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}