Skip to content

Commit 627eebd

Browse files
committed
work
1 parent 94850e7 commit 627eebd

File tree

7 files changed

+15
-15
lines changed

7 files changed

+15
-15
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -865,7 +865,7 @@ async def main():
865865
client_metadata=OAuthClientMetadata(
866866
client_name="My Client",
867867
redirect_uris=["http://localhost:3000/callback"],
868-
grant_types=["urn:ietf:params:oauth:grant-type:token-exchange"],
868+
grant_types=["token-exchange"],
869869
response_types=["code"],
870870
),
871871
storage=CustomTokenStorage(),

src/mcp/client/auth.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,7 @@ def __init__(
689689
client_metadata: OAuthClientMetadata,
690690
storage: TokenStorage,
691691
subject_token_supplier: Callable[[], Awaitable[str]],
692-
subject_token_type: str = "urn:ietf:params:oauth:token-type:access_token",
692+
subject_token_type: str = "access_token",
693693
actor_token_supplier: Callable[[], Awaitable[str]] | None = None,
694694
actor_token_type: str | None = None,
695695
audience: str | None = None,
@@ -722,7 +722,7 @@ async def _request_token(self) -> None:
722722
)
723723

724724
token_data = {
725-
"grant_type": "urn:ietf:params:oauth:grant-type:token-exchange",
725+
"grant_type": "token-exchange",
726726
"client_id": client_info.client_id,
727727
"subject_token": subject_token,
728728
"subject_token_type": self.subject_token_type,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ async def handle(self, request: Request) -> Response:
7878
valid_sets = [
7979
{"authorization_code", "refresh_token"},
8080
{"client_credentials"},
81-
{"urn:ietf:params:oauth:grant-type:token-exchange"},
81+
{"token-exchange"},
8282
]
8383

8484
if grant_types_set not in valid_sets:

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class ClientCredentialsRequest(BaseModel):
5858
class TokenExchangeRequest(BaseModel):
5959
"""RFC 8693 token exchange request."""
6060

61-
grant_type: Literal["urn:ietf:params:oauth:grant-type:token-exchange"]
61+
grant_type: Literal["token-exchange"]
6262
subject_token: str = Field(..., description="Token to exchange")
6363
subject_token_type: str = Field(..., description="Type of the subject token")
6464
actor_token: str | None = Field(None, description="Optional actor token")

src/mcp/server/auth/routes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ def build_metadata(
168168
"authorization_code",
169169
"refresh_token",
170170
"client_credentials",
171-
"urn:ietf:params:oauth:grant-type:token-exchange",
171+
"token-exchange",
172172
],
173173
token_endpoint_auth_methods_supported=["client_secret_post"],
174174
token_endpoint_auth_signing_alg_values_supported=None,

src/mcp/shared/auth.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class OAuthClientMetadata(BaseModel):
4646
"authorization_code",
4747
"refresh_token",
4848
"client_credentials",
49-
"urn:ietf:params:oauth:grant-type:token-exchange",
49+
"token-exchange",
5050
]
5151
] = [
5252
"authorization_code",
@@ -127,7 +127,7 @@ class OAuthMetadata(BaseModel):
127127
"authorization_code",
128128
"refresh_token",
129129
"client_credentials",
130-
"urn:ietf:params:oauth:grant-type:token-exchange",
130+
"token-exchange",
131131
]
132132
]
133133
| None

tests/server/fastmcp/auth/test_auth_integration.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1362,14 +1362,14 @@ async def test_metadata_includes_token_exchange(
13621362
assert response.status_code == 200
13631363
metadata = response.json()
13641364
assert (
1365-
"urn:ietf:params:oauth:grant-type:token-exchange"
1365+
"token-exchange"
13661366
in metadata["grant_types_supported"]
13671367
)
13681368

13691369
@pytest.mark.anyio
13701370
@pytest.mark.parametrize(
13711371
"registered_client",
1372-
[{"grant_types": ["urn:ietf:params:oauth:grant-type:token-exchange"]}],
1372+
[{"grant_types": ["token-exchange"]}],
13731373
indirect=True,
13741374
)
13751375
async def test_token_exchange_success(
@@ -1378,11 +1378,11 @@ async def test_token_exchange_success(
13781378
response = await test_client.post(
13791379
"/token",
13801380
data={
1381-
"grant_type": "urn:ietf:params:oauth:grant-type:token-exchange",
1381+
"grant_type": "token-exchange",
13821382
"client_id": registered_client["client_id"],
13831383
"client_secret": registered_client["client_secret"],
13841384
"subject_token": "good_token",
1385-
"subject_token_type": "urn:ietf:params:oauth:token-type:access_token",
1385+
"subject_token_type": "access_token",
13861386
},
13871387
)
13881388
assert response.status_code == 200
@@ -1392,7 +1392,7 @@ async def test_token_exchange_success(
13921392
@pytest.mark.anyio
13931393
@pytest.mark.parametrize(
13941394
"registered_client",
1395-
[{"grant_types": ["urn:ietf:params:oauth:grant-type:token-exchange"]}],
1395+
[{"grant_types": ["token-exchange"]}],
13961396
indirect=True,
13971397
)
13981398
async def test_token_exchange_invalid_subject(
@@ -1401,11 +1401,11 @@ async def test_token_exchange_invalid_subject(
14011401
response = await test_client.post(
14021402
"/token",
14031403
data={
1404-
"grant_type": "urn:ietf:params:oauth:grant-type:token-exchange",
1404+
"grant_type": "token-exchange",
14051405
"client_id": registered_client["client_id"],
14061406
"client_secret": registered_client["client_secret"],
14071407
"subject_token": "bad_token",
1408-
"subject_token_type": "urn:ietf:params:oauth:token-type:access_token",
1408+
"subject_token_type": "access_token",
14091409
},
14101410
)
14111411
assert response.status_code == 400

0 commit comments

Comments
 (0)