Skip to content

Commit 91d18b4

Browse files
committed
Keep the missing-issuer warning text static
The warning is already attributed to the caller's constructor line, so it does not need the provider name or server URL; _checked_issuer keeps its single argument.
1 parent 8031fe6 commit 91d18b4

2 files changed

Lines changed: 8 additions & 11 deletions

File tree

src/mcp/client/auth/extensions/client_credentials.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,11 @@
2323
from mcp.shared.auth import OAuthClientInformationFull, OAuthClientMetadata
2424

2525

26-
def _checked_issuer(issuer: str | None, provider: str, server_url: str) -> str | None:
26+
def _checked_issuer(issuer: str | None) -> str | None:
2727
if issuer is None:
2828
warnings.warn(
29-
f"{provider} created without `issuer`: the client credentials will be sent to whichever "
30-
f"authorization server {server_url} advertises. Pass issuer=<the issuer URL your authorization "
31-
"server's metadata reports> so that token requests are only ever built for that server.",
29+
"No `issuer` given: client credentials will be sent to whichever authorization server the MCP "
30+
"server advertises. Pass issuer=<your authorization server's issuer URL> to send them only there.",
3231
stacklevel=3,
3332
)
3433
return None
@@ -117,7 +116,7 @@ def __init__(
117116
scope=scope,
118117
)
119118
super().__init__(server_url, client_metadata, storage, None, None)
120-
self._issuer = _checked_issuer(issuer, type(self).__name__, server_url)
119+
self._issuer = _checked_issuer(issuer)
121120
# Store client_info to be set during _initialize - no dynamic registration needed
122121
self._fixed_client_info = OAuthClientInformationFull(
123122
redirect_uris=None,
@@ -348,7 +347,7 @@ def __init__(
348347
)
349348
super().__init__(server_url, client_metadata, storage, None, None)
350349
self._assertion_provider = assertion_provider
351-
self._issuer = _checked_issuer(issuer, type(self).__name__, server_url)
350+
self._issuer = _checked_issuer(issuer)
352351
# Store client_info to be set during _initialize - no dynamic registration needed
353352
self._fixed_client_info = OAuthClientInformationFull(
354353
redirect_uris=None,

tests/client/auth/extensions/test_client_credentials.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -467,11 +467,9 @@ async def assertion_provider(audience: str) -> str:
467467

468468
[warning] = recorded
469469
assert warning.filename == __file__
470-
provider = "ClientCredentialsOAuthProvider" if kind == "secret" else "PrivateKeyJWTOAuthProvider"
471470
assert str(warning.message) == (
472-
f"{provider} created without `issuer`: the client credentials will be sent to whichever "
473-
"authorization server https://api.example.com/v1/mcp advertises. Pass issuer=<the issuer URL your "
474-
"authorization server's metadata reports> so that token requests are only ever built for that server."
471+
"No `issuer` given: client credentials will be sent to whichever authorization server the MCP "
472+
"server advertises. Pass issuer=<your authorization server's issuer URL> to send them only there."
475473
)
476474

477475

@@ -486,7 +484,7 @@ async def test_without_issuer_the_exchange_follows_whichever_server_was_discover
486484
async def assertion_provider(audience: str) -> str:
487485
return "jwt"
488486

489-
with pytest.warns(UserWarning, match="created without `issuer`"):
487+
with pytest.warns(UserWarning, match="No `issuer` given"):
490488
if kind == "secret":
491489
provider: OAuthClientProvider = ClientCredentialsOAuthProvider(
492490
server_url=_SERVER_URL, storage=mock_storage, client_id="c", client_secret="s"

0 commit comments

Comments
 (0)