googleapis / googleapis/mcp-toolbox-sdk-python

Expose telemetry_attributes in toolbox-adk Toolset/Tool wrappers

Offen
#718 1 Kommentar 0 Reaktionen 1 zugewiesene Person Beansprucht von @anubhav756 Auf GitHub ansehen
priority: p2 type: feature request
Vorherrschende Sprache
Python
Sterne
191
Forks
60
Ø Merge
5 T. 20 Min.
Gemergte PRs (30 T.)
13

Beschreibung

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

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.