Closed
Description
Question
I am trying to authenticate with an MCP server that is expecting the standard {"Authorization": f"Bearer {access_token}"} header. I have written a simple httpx.Auth implementation for this purpose, but am still failing to authenticate. Is something like this not intended to work? I verified that "auth_flow" is being called.
class AuthWithToken(httpx.Auth):
def __init__(self, token: str):
self.token = token
def auth_flow(self, request):
request.headers['Authorization'] = f'Bearer {self.token}'
yield request
auth = AuthWithToken(auth_token) if auth_token else None
# Connect to a streamable HTTP server
async with streamablehttp_client(self.address, auth=auth) as (
read_stream,
write_stream,
_,
)...
Additional Context
No response