You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
I have multiple MCP servers hosted behind the same authorization server, and my client environment provides a get_oauth_token() API to get a short-lived access token. When writing custom agents or programs that connect to the MCP servers, I can use the APIs currently in main and manually specify headers to connect to each MCP server:
token=get_oauth_token()
# Repeat this for each server URLasyncwithstreamablehttp_client(url=f"{basic_server_url}/mcp/", headers={'Authorization': f'Bearer {token}'}) as (
read_stream,
write_stream,
_,
):
asyncwithClientSession(
read_stream,
write_stream,
) assession:
awaitsession.initialize()
yieldsession
However, this of course isn't stable over time when I'm trying to authenticate using short-lived oauth access tokens (I'll get token expiry errors after 30 min etc).
Describe the solution you'd like
It seems we have a nice solution to implementing custom authentication behavior in MCP clients in the TypeScript SDK, where I can pass a custom OauthClientProvider when instantiating my client (e.g. here). Would it make sense to consider the same for the Python SDK? Happy to help with a contribution here :)
Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
Additional context
Add any other context or screenshots about the feature request here.
The text was updated successfully, but these errors were encountered:
smurching
changed the title
Support custom OauthProviders in the client (similar to TypeScript SDK)
Support custom OAuthClientProviders (similar to TypeScript SDK) to enable custom authentication logic in client code
May 7, 2025
Is your feature request related to a problem? Please describe.
I have multiple MCP servers hosted behind the same authorization server, and my client environment provides a
get_oauth_token()
API to get a short-lived access token. When writing custom agents or programs that connect to the MCP servers, I can use the APIs currently inmain
and manually specify headers to connect to each MCP server:However, this of course isn't stable over time when I'm trying to authenticate using short-lived oauth access tokens (I'll get token expiry errors after 30 min etc).
Describe the solution you'd like
It seems we have a nice solution to implementing custom authentication behavior in MCP clients in the TypeScript SDK, where I can pass a custom OauthClientProvider when instantiating my client (e.g. here). Would it make sense to consider the same for the Python SDK? Happy to help with a contribution here :)
Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
Additional context
Add any other context or screenshots about the feature request here.
The text was updated successfully, but these errors were encountered: