Skip to content

Commit 186f821

Browse files
committed
Fix
1 parent 9721a01 commit 186f821

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/mcp/server/auth/routes.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from collections.abc import Awaitable, Callable
2-
from typing import Any, cast
2+
from typing import Any
33

44
from pydantic import AnyHttpUrl
55
from starlette.middleware.cors import CORSMiddleware
@@ -32,8 +32,11 @@ def validate_issuer_url(url: AnyHttpUrl):
3232
"""
3333

3434
# RFC 8414 requires HTTPS, but we allow localhost HTTP for testing
35-
host = cast(str, url.host)
36-
if url.scheme != "https" and host != "localhost" and not host.startswith("127.0.0.1"):
35+
if (
36+
url.scheme != "https"
37+
and url.host != "localhost"
38+
and (url.host is not None and not url.host.startswith("127.0.0.1"))
39+
):
3740
raise ValueError("Issuer URL must be HTTPS")
3841

3942
# No fragments or query parameters allowed

0 commit comments

Comments
 (0)