Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion python/packages/agentsts-adk/src/agentsts/adk/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,24 +122,30 @@ def add_to_agent(self, agent: BaseAgent):
Add the plugin to an ADK LLM agent by updating its MCP toolset
Call this once when setting up the agent; do not call it at runtime.
"""
agent_name = getattr(agent, "name", "unknown")
logger.debug(f"add_to_agent called for agent {agent_name}")

if not isinstance(agent, LlmAgent):
logger.debug(f"add_to_agent: agent {agent_name} is not LlmAgent, skipping")
return

if not agent.tools:
logger.debug(f"add_to_agent: agent {agent_name} has no tools, skipping")
return

for tool in agent.tools:
if isinstance(tool, McpToolset):
mcp_toolset = tool
mcp_toolset._header_provider = self.header_provider
logger.debug("Updated tool connection params to include access token from STS server")
logger.debug(f"add_to_agent: updated MCP tool's header provider for agent {agent_name}")

def header_provider(self, readonly_context: Optional[ReadonlyContext]) -> Dict[str, str]:
# access saved token
cache_entry = self.token_cache.get(self.cache_key(readonly_context._invocation_context))
if not cache_entry:
return {}

logger.debug("Using cached access token for tool invocation")
return {
"Authorization": f"Bearer {cache_entry.token}",
}
Expand Down
Loading