-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
** Please make sure you read the contribution guide and file the issues in the rigth place. **
Contribution guide.
Describe the bug
In the documentation to build an mcp server with adk (https://google.github.io/adk-docs/tools/mcp-tools/#step-2-implement-the-server-logic) the tool_context is left empty, as there's no InvocationContext available in a non llm agent calling setting.
When authentication is required on tool invokation ToolAuthHandler.prepare_auth_credentials is calling get_auth_response from the ToolContext which results in "'NoneType' object has no attribute 'get_auth_response'"
To Reproduce
Steps to reproduce the behavior:
- register a RestApiTool which requires authentication (any scheme) in the mcp server example
- invoke the tool (e.G. using mcp inspector)
Expected behavior
Having a way to only provide a Context for authentication logic.
Desktop (please complete the following information):
- OS: Ubuntu
- Python version(python -V): 3.12.3
- ADK version(pip show google-adk): 0.3.0
Additional context
Came long this issue when using OpenAPIToolset in the given MCP server example.
Personally using OAuth2 with client credentials, but as analysed should affect any auth scheme.
So far I tried to:
- add a None check to _get_auth_response -> more parts of authentication require ToolContext to be present
- Make InvocationContext optional in ToolContext -> at least session from InvocationContext is needed to store auth result
- Make BaseAgent in InvocationContext optional and call tool with ToolContext+InvokationContext -> Might work, but I'm currently stuck in authentication process not authenticating, as it's pending with "Needs your authorization to access your data" even the process is configured for client_credentials