Skip to content

Commit 1202029

Browse files
committed
Format
1 parent fa1bfcf commit 1202029

File tree

7 files changed

+9
-14
lines changed

7 files changed

+9
-14
lines changed

src/mcp/server/auth/errors.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
ErrorCode = Literal["invalid_request", "invalid_client"]
1212

13+
1314
class ErrorResponse(BaseModel):
1415
error: ErrorCode
1516
error_description: str

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ async def error_response(
250250
auth_params,
251251
),
252252
status_code=302,
253-
headers={"Cache-Control": "no-store"}
253+
headers={"Cache-Control": "no-store"},
254254
)
255255

256256
except Exception as validation_error:
@@ -263,7 +263,6 @@ async def error_response(
263263
)
264264

265265

266-
267266
def create_error_redirect(
268267
redirect_uri: AnyUrl, error: Exception | ErrorResponse
269268
) -> str:

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class ErrorResponse(BaseModel):
3434
class RegistrationHandler:
3535
clients_store: OAuthRegisteredClientsStore
3636
client_secret_expiry_seconds: int | None
37+
3738
async def handle(self, request: Request) -> Response:
3839
# Implements dynamic client registration as defined in https://datatracker.ietf.org/doc/html/rfc7591#section-3.1
3940
try:

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ async def handle(self, request: Request):
8383
error_description=stringify_pydantic_error(validation_error),
8484
)
8585
)
86-
86+
8787
try:
8888
client_info = await self.client_authenticator(token_request)
8989
except InvalidClientError as e:

src/mcp/server/auth/middleware/bearer_auth.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ async def authenticate(self, conn: HTTPConnection):
5959
return AuthCredentials(auth_info.scopes), AuthenticatedUser(auth_info)
6060

6161

62-
6362
class RequireAuthMiddleware:
6463
"""
6564
Middleware that requires a valid Bearer token in the Authorization header.

src/mcp/server/auth/middleware/client_auth.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,4 @@ async def __call__(self, request: ClientAuthRequest) -> OAuthClientInformationFu
6767
):
6868
raise InvalidClientError("Client secret has expired")
6969

70-
return client
70+
return client

tests/server/fastmcp/auth/test_auth_integration.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,7 @@ def __init__(self):
5252
async def get_client(self, client_id: str) -> Optional[OAuthClientInformationFull]:
5353
return self.clients.get(client_id)
5454

55-
async def register_client(
56-
self, client_info: OAuthClientInformationFull
57-
):
55+
async def register_client(self, client_info: OAuthClientInformationFull):
5856
self.clients[client_info.client_id] = client_info
5957

6058

@@ -750,12 +748,9 @@ async def test_client_registration_invalid_uri(
750748
error_data = response.json()
751749
assert "error" in error_data
752750
assert error_data["error"] == "invalid_client_metadata"
753-
assert (
754-
error_data["error_description"]
755-
== (
756-
"redirect_uris.0: Input should be a valid URL, "
757-
"relative URL without a base"
758-
)
751+
assert error_data["error_description"] == (
752+
"redirect_uris.0: Input should be a valid URL, "
753+
"relative URL without a base"
759754
)
760755

761756
@pytest.mark.anyio

0 commit comments

Comments
 (0)