googleapis / googleapis/mcp-toolbox-sdk-python

Expose telemetry_attributes in toolbox-adk Toolset/Tool wrappers

Aperta
#718 1 commento 0 reazioni 1 assegnatario Rivendicata da @anubhav756 Vedi su GitHub
priority: p2 type: feature request
Lingua principale
Python
Stelle
191
Fork
60
Merge medio
5g 20m
PR unite (30g)
13

Descrizione

### 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.

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.