Skip to content

Commit f32fd5a

Browse files
authored
Merge branch 'main' into feat/audio-content
2 parents b125fbc + 2bce10b commit f32fd5a

File tree

6 files changed

+18
-18
lines changed

6 files changed

+18
-18
lines changed

src/mcp/server/auth/handlers/authorize.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from dataclasses import dataclass
33
from typing import Any, Literal
44

5-
from pydantic import AnyHttpUrl, AnyUrl, BaseModel, Field, RootModel, ValidationError
5+
from pydantic import AnyUrl, BaseModel, Field, RootModel, ValidationError
66
from starlette.datastructures import FormData, QueryParams
77
from starlette.requests import Request
88
from starlette.responses import RedirectResponse, Response
@@ -29,7 +29,7 @@
2929
class AuthorizationRequest(BaseModel):
3030
# See https://datatracker.ietf.org/doc/html/rfc6749#section-4.1.1
3131
client_id: str = Field(..., description="The client ID")
32-
redirect_uri: AnyHttpUrl | None = Field(
32+
redirect_uri: AnyUrl | None = Field(
3333
None, description="URL to redirect to after authorization"
3434
)
3535

@@ -68,8 +68,8 @@ def best_effort_extract_string(
6868
return None
6969

7070

71-
class AnyHttpUrlModel(RootModel[AnyHttpUrl]):
72-
root: AnyHttpUrl
71+
class AnyUrlModel(RootModel[AnyUrl]):
72+
root: AnyUrl
7373

7474

7575
@dataclass
@@ -116,7 +116,7 @@ async def error_response(
116116
if params is not None and "redirect_uri" not in params:
117117
raw_redirect_uri = None
118118
else:
119-
raw_redirect_uri = AnyHttpUrlModel.model_validate(
119+
raw_redirect_uri = AnyUrlModel.model_validate(
120120
best_effort_extract_string("redirect_uri", params)
121121
).root
122122
redirect_uri = client.validate_redirect_uri(raw_redirect_uri)

src/mcp/server/auth/handlers/token.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from dataclasses import dataclass
55
from typing import Annotated, Any, Literal
66

7-
from pydantic import AnyHttpUrl, BaseModel, Field, RootModel, ValidationError
7+
from pydantic import AnyHttpUrl, AnyUrl, BaseModel, Field, RootModel, ValidationError
88
from starlette.requests import Request
99

1010
from mcp.server.auth.errors import (
@@ -27,7 +27,7 @@ class AuthorizationCodeRequest(BaseModel):
2727
# See https://datatracker.ietf.org/doc/html/rfc6749#section-4.1.3
2828
grant_type: Literal["authorization_code"]
2929
code: str = Field(..., description="The authorization code")
30-
redirect_uri: AnyHttpUrl | None = Field(
30+
redirect_uri: AnyUrl | None = Field(
3131
None, description="Must be the same as redirect URI provided in /authorize"
3232
)
3333
client_id: str

src/mcp/server/auth/provider.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from typing import Generic, Literal, Protocol, TypeVar
33
from urllib.parse import parse_qs, urlencode, urlparse, urlunparse
44

5-
from pydantic import AnyHttpUrl, BaseModel
5+
from pydantic import AnyUrl, BaseModel
66

77
from mcp.shared.auth import (
88
OAuthClientInformationFull,
@@ -14,7 +14,7 @@ class AuthorizationParams(BaseModel):
1414
state: str | None
1515
scopes: list[str] | None
1616
code_challenge: str
17-
redirect_uri: AnyHttpUrl
17+
redirect_uri: AnyUrl
1818
redirect_uri_provided_explicitly: bool
1919

2020

@@ -24,7 +24,7 @@ class AuthorizationCode(BaseModel):
2424
expires_at: float
2525
client_id: str
2626
code_challenge: str
27-
redirect_uri: AnyHttpUrl
27+
redirect_uri: AnyUrl
2828
redirect_uri_provided_explicitly: bool
2929

3030

src/mcp/shared/auth.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from typing import Any, Literal
22

3-
from pydantic import AnyHttpUrl, BaseModel, Field
3+
from pydantic import AnyHttpUrl, AnyUrl, BaseModel, Field
44

55

66
class OAuthToken(BaseModel):
@@ -32,7 +32,7 @@ class OAuthClientMetadata(BaseModel):
3232
for the full specification.
3333
"""
3434

35-
redirect_uris: list[AnyHttpUrl] = Field(..., min_length=1)
35+
redirect_uris: list[AnyUrl] = Field(..., min_length=1)
3636
# token_endpoint_auth_method: this implementation only supports none &
3737
# client_secret_post;
3838
# ie: we do not support client_secret_basic
@@ -71,7 +71,7 @@ def validate_scope(self, requested_scope: str | None) -> list[str] | None:
7171
raise InvalidScopeError(f"Client was not registered with scope {scope}")
7272
return requested_scopes
7373

74-
def validate_redirect_uri(self, redirect_uri: AnyHttpUrl | None) -> AnyHttpUrl:
74+
def validate_redirect_uri(self, redirect_uri: AnyUrl | None) -> AnyUrl:
7575
if redirect_uri is not None:
7676
# Validate redirect_uri against client's registered redirect URIs
7777
if redirect_uri not in self.redirect_uris:

src/mcp/types.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,12 +350,12 @@ class ProgressNotificationParams(NotificationParams):
350350
total is unknown.
351351
"""
352352
total: float | None = None
353+
"""Total number of items to process (or total progress required), if known."""
354+
message: str | None = None
353355
"""
354356
Message related to progress. This should provide relevant human readable
355357
progress information.
356358
"""
357-
message: str | None = None
358-
"""Total number of items to process (or total progress required), if known."""
359359
model_config = ConfigDict(extra="allow")
360360

361361

tests/client/test_auth.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import httpx
1212
import pytest
1313
from inline_snapshot import snapshot
14-
from pydantic import AnyHttpUrl
14+
from pydantic import AnyHttpUrl, AnyUrl
1515

1616
from mcp.client.auth import OAuthClientProvider
1717
from mcp.server.auth.routes import build_metadata
@@ -52,7 +52,7 @@ def mock_storage():
5252
@pytest.fixture
5353
def client_metadata():
5454
return OAuthClientMetadata(
55-
redirect_uris=[AnyHttpUrl("http://localhost:3000/callback")],
55+
redirect_uris=[AnyUrl("http://localhost:3000/callback")],
5656
client_name="Test Client",
5757
grant_types=["authorization_code", "refresh_token"],
5858
response_types=["code"],
@@ -79,7 +79,7 @@ def oauth_client_info():
7979
return OAuthClientInformationFull(
8080
client_id="test_client_id",
8181
client_secret="test_client_secret",
82-
redirect_uris=[AnyHttpUrl("http://localhost:3000/callback")],
82+
redirect_uris=[AnyUrl("http://localhost:3000/callback")],
8383
client_name="Test Client",
8484
grant_types=["authorization_code", "refresh_token"],
8585
response_types=["code"],

0 commit comments

Comments
 (0)