Switch RFC7523OAuthClientProvider warning to MCPDeprecationWarning (#2996)
This commit is contained in:
parent
5b2713d40c
commit
cc596195bb
3 changed files with 6 additions and 3 deletions
|
|
@ -19,6 +19,7 @@ from pydantic import BaseModel, Field
|
|||
|
||||
from mcp.client.auth import OAuthClientProvider, OAuthFlowError, OAuthTokenError, TokenStorage
|
||||
from mcp.shared.auth import AuthorizationCodeResult, OAuthClientInformationFull, OAuthClientMetadata
|
||||
from mcp.shared.exceptions import MCPDeprecationWarning
|
||||
|
||||
|
||||
class ClientCredentialsOAuthProvider(OAuthClientProvider):
|
||||
|
|
@ -412,7 +413,7 @@ class RFC7523OAuthClientProvider(OAuthClientProvider):
|
|||
warnings.warn(
|
||||
"RFC7523OAuthClientProvider is deprecated. Use ClientCredentialsOAuthProvider "
|
||||
"or PrivateKeyJWTOAuthProvider instead.",
|
||||
DeprecationWarning,
|
||||
MCPDeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
super().__init__(server_url, client_metadata, storage, redirect_handler, callback_handler, timeout)
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ from mcp.shared.auth import (
|
|||
OAuthMetadata,
|
||||
OAuthToken,
|
||||
)
|
||||
from mcp.shared.exceptions import MCPDeprecationWarning
|
||||
|
||||
|
||||
class MockTokenStorage:
|
||||
|
|
@ -68,7 +69,7 @@ def rfc7523_oauth_provider(client_metadata: OAuthClientMetadata, mock_storage: M
|
|||
return AuthorizationCodeResult(code="test_auth_code", state="test_state")
|
||||
|
||||
with warnings.catch_warnings():
|
||||
warnings.simplefilter("ignore", DeprecationWarning)
|
||||
warnings.simplefilter("ignore", MCPDeprecationWarning)
|
||||
return RFC7523OAuthClientProvider(
|
||||
server_url="https://api.example.com/v1/mcp",
|
||||
client_metadata=client_metadata,
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ from mcp.client.auth.extensions.client_credentials import (
|
|||
static_assertion_provider,
|
||||
)
|
||||
from mcp.shared.auth import OAuthClientInformationFull, OAuthClientMetadata, OAuthToken
|
||||
from mcp.shared.exceptions import MCPDeprecationWarning
|
||||
|
||||
# See test_index.py for why this is a per-module mark and not a conftest hook.
|
||||
pytestmark = [pytest.mark.anyio, pytest.mark.filterwarnings("error::mcp.MCPDeprecationWarning")]
|
||||
|
|
@ -105,7 +106,7 @@ async def test_the_one_more_provider_is_private_key_jwt() -> None:
|
|||
|
||||
async def test_the_page_does_not_count_the_deprecated_provider() -> None:
|
||||
"""Why the `!!! info` says *one* more provider: `RFC7523OAuthClientProvider` warns on construction."""
|
||||
with pytest.warns(DeprecationWarning, match="RFC7523OAuthClientProvider is deprecated"):
|
||||
with pytest.warns(MCPDeprecationWarning, match="RFC7523OAuthClientProvider is deprecated"):
|
||||
RFC7523OAuthClientProvider(
|
||||
server_url="http://localhost:8001/mcp",
|
||||
client_metadata=tutorial001.oauth.context.client_metadata,
|
||||
|
|
|
|||
Loading…
Reference in a new issue