googleapis / googleapis/mcp-toolbox-sdk-python
Expose telemetry_attributes in toolbox-adk Toolset/Tool wrappers
- Dominant language
- Python
- Stars
- 191
- Forks
- 60
- Avg merge
- 5d 20m
- Merged PRs (30d)
- 13
Description
### Prerequisites
- [x] Search the [current open issues](https://github.com/googleapis/mcp-toolbox-sdk-python/issues)
### What are you trying to do that currently feels hard or impossible?
`toolbox-core` supports `TelemetryAttributes` and sends client metadata such as model, user ID, and agent ID through MCP `_meta` for extended telemetry / SQLCommenter. This was added in #632 / #634.
However, `toolbox-adk` does not currently expose a way to pass those telemetry attributes through `ToolboxToolset` or `ToolboxTool`. ADK users can load and invoke Toolbox tools, but cannot attach per-invocation telemetry metadata from ADK context, such as the current `ToolContext`, session user, agent ID, or model.
This means ADK applications cannot use the core telemetry attribute flow without bypassing the ADK wrapper.
### Suggested Solution(s)
Add a `telemetry_attributes` argument to `toolbox_adk.ToolboxToolset` and `toolbox_adk.ToolboxTool`.
Support:
- A static `TelemetryAttributes` instance.
- A sync or async zero-argument callback.
- A sync or async one-argument callback receiving ADK `ToolContext`.
This should follow the existing ADK callback pattern from #579, where one-argument callbacks receive `ToolContext`.
At invocation time, resolve telemetry attributes per call and apply them with `core_tool.add_telemetry_attributes(...)`.
Important: context-derived telemetry should not mutate the shared wrapped core tool, otherwise user/agent metadata from one invocation can leak into later invocations
### Alternatives Considered
_No response_
### Additional Details
This extends the core telemetry implementation from #634 into the ADK integration only. It should preserve existing ADK auth behavior and should include tests for:
- Passing telemetry attributes from `ToolboxToolset` into wrapped tools.
- Resolving dynamic telemetry attributes per invocation from `ToolContext`.
- Ensuring the base core tool is not mutated across calls.
- Ensuring user identity token cleanup still happens if telemetry resolution fails.
Contributor guide
Assessment
This issue has not been assessed yet.