Skip to content

Commit d0610d1

Browse files
authored
Merge pull request #21 from sacha-development-stuff/codex/fix-failing-test-for-client-registration
Allow additional grant types during client registration
2 parents 1cf50f0 + 16f742a commit d0610d1

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,20 +69,20 @@ async def handle(self, request: Request) -> Response:
6969
status_code=400,
7070
)
7171
grant_types_set: set[str] = set(client_metadata.grant_types)
72-
valid_sets = [
72+
required_sets = [
7373
{"authorization_code", "refresh_token"},
7474
{"client_credentials"},
7575
{"token_exchange"},
7676
{"client_credentials", "token_exchange"},
7777
]
7878

79-
if grant_types_set not in valid_sets:
79+
if not any(required_set.issubset(grant_types_set) for required_set in required_sets):
8080
return PydanticJSONResponse(
8181
content=RegistrationErrorResponse(
8282
error="invalid_client_metadata",
8383
error_description=(
84-
"grant_types must be authorization_code and refresh_token "
85-
"or client_credentials or token exchange or client_credentials and token_exchange"
84+
"grant_types must include authorization_code and refresh_token, "
85+
"client_credentials, token_exchange, or client_credentials and token_exchange"
8686
),
8787
),
8888
status_code=400,

src/mcp/shared/auth.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,15 @@ class OAuthClientMetadata(BaseModel):
4747
# client_secret_post;
4848
# ie: we do not support client_secret_basic
4949
token_endpoint_auth_method: Literal["none", "client_secret_post"] = "client_secret_post"
50-
# grant_types: this implementation supports authorization_code, refresh_token, client_credentials, & token_exchange
50+
# grant_types: this implementation supports authorization_code, refresh_token, client_credentials, token_exchange,
51+
# and allows additional grant types provided by the client (e.g. device code)
5152
grant_types: list[
5253
Literal[
5354
"authorization_code",
5455
"refresh_token",
5556
"client_credentials",
5657
"token_exchange",
58+
"urn:ietf:params:oauth:grant-type:device_code",
5759
]
5860
] = [
5961
"authorization_code",

0 commit comments

Comments
 (0)