@@ -1603,7 +1603,7 @@ from urllib.parse import parse_qs, urlparse
1603
1603
from pydantic import AnyUrl
1604
1604
1605
1605
from mcp import ClientSession
1606
- from mcp.client.auth import OAuthClientProvider, TokenExchangeProvider, TokenStorage
1606
+ from mcp.client.auth import OAuthClientProvider, TokenStorage
1607
1607
from mcp.client.streamable_http import streamablehttp_client
1608
1608
from mcp.shared.auth import OAuthClientInformationFull, OAuthClientMetadata, OAuthToken
1609
1609
@@ -1658,25 +1658,6 @@ async def main():
1658
1658
callback_handler = handle_callback,
1659
1659
)
1660
1660
1661
- # For machine-to-machine scenarios, use ClientCredentialsProvider
1662
- # instead of OAuthClientProvider.
1663
-
1664
- # If you already have a user token from another provider, you can
1665
- # exchange it for an MCP token using the token_exchange grant
1666
- # implemented by TokenExchangeProvider.
1667
- token_exchange_auth = TokenExchangeProvider(
1668
- server_url = " https://api.example.com" ,
1669
- client_metadata = OAuthClientMetadata(
1670
- client_name = " My Client" ,
1671
- redirect_uris = [" http://localhost:3000/callback" ],
1672
- grant_types = [" client_credentials" , " token_exchange" ],
1673
- response_types = [" code" ],
1674
- ),
1675
- storage = CustomTokenStorage(),
1676
- subject_token_supplier = lambda : " user_token" ,
1677
- )
1678
-
1679
- # Use with streamable HTTP client
1680
1661
async with streamablehttp_client(" http://localhost:8001/mcp" , auth = oauth_auth) as (read, write, _):
1681
1662
async with ClientSession(read, write) as session:
1682
1663
await session.initialize()
0 commit comments