fix: Initialize self._auth_config inside BaseAuthenticatedTool

So that we can access self._auth_config in McpTool for getting auth headers

Co-authored-by: Kathy Wu <wukathy@google.com>
PiperOrigin-RevId: 856451693
This commit is contained in:
Kathy Wu
2026-01-14 19:18:44 -08:00
committed by Copybara-Service
parent cce430da79
commit d4da1bb733
2 changed files with 3 additions and 0 deletions
@@ -66,6 +66,7 @@ class BaseAuthenticatedTool(BaseTool):
name=name,
description=description,
)
self._auth_config = auth_config
if auth_config and auth_config.auth_scheme:
self._credentials_manager = CredentialManager(auth_config=auth_config)
@@ -90,6 +90,7 @@ class TestBaseAuthenticatedTool:
assert tool.description == "Test description"
assert tool._credentials_manager is not None
assert tool._response_for_auth_required == unauthenticated_response
assert tool._auth_config == auth_config
def test_init_with_no_auth_config(self):
"""Test initialization without auth_config."""
@@ -99,6 +100,7 @@ class TestBaseAuthenticatedTool:
assert tool.description == "Test authenticated tool"
assert tool._credentials_manager is None
assert tool._response_for_auth_required is None
assert tool._auth_config is None
def test_init_with_empty_auth_scheme(self):
"""Test initialization with auth_config but no auth_scheme."""