Skip to content

Commit 4c0c6db

Browse files
google-genai-botcopybara-github
authored andcommitted
fix: Disable bound token for mcp_tool
PiperOrigin-RevId: 901509317
1 parent d6594a1 commit 4c0c6db

2 files changed

Lines changed: 21 additions & 0 deletions

File tree

src/google/adk/tools/mcp_tool/mcp_tool.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import base64
1919
import inspect
2020
import logging
21+
import os
2122
from typing import Any
2223
from typing import Callable
2324
from typing import Dict
@@ -169,6 +170,16 @@ def __init__(
169170
Raises:
170171
ValueError: If mcp_tool or mcp_session_manager is None.
171172
"""
173+
174+
# --- BEGIN BOUND TOKEN PATCH ---
175+
# Set GOOGLE_API_PREVENT_AGENT_TOKEN_SHARING_FOR_GCP_SERVICES to false
176+
# to disable bound token sharing. Tracking on
177+
# https://github.com/google/adk-python/issues/5361
178+
os.environ["GOOGLE_API_PREVENT_AGENT_TOKEN_SHARING_FOR_GCP_SERVICES"] = (
179+
"false"
180+
)
181+
# --- END BOUND TOKEN PATCH ---
182+
172183
super().__init__(
173184
name=mcp_tool.name,
174185
description=mcp_tool.description if mcp_tool.description else "",

src/google/adk/tools/mcp_tool/mcp_toolset.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import asyncio
1818
import base64
1919
import logging
20+
import os
2021
import sys
2122
from typing import Any
2223
from typing import Awaitable
@@ -158,6 +159,15 @@ def __init__(
158159
sampling_capabilities: Optional capabilities for sampling.
159160
"""
160161

162+
# --- BEGIN BOUND TOKEN PATCH ---
163+
# Set GOOGLE_API_PREVENT_AGENT_TOKEN_SHARING_FOR_GCP_SERVICES to false
164+
# to disable bound token sharing. Tracking on
165+
# https://github.com/google/adk-python/issues/5361
166+
os.environ["GOOGLE_API_PREVENT_AGENT_TOKEN_SHARING_FOR_GCP_SERVICES"] = (
167+
"false"
168+
)
169+
# --- END BOUND TOKEN PATCH ---
170+
161171
super().__init__(tool_filter=tool_filter, tool_name_prefix=tool_name_prefix)
162172

163173
self._sampling_callback = sampling_callback

0 commit comments

Comments
 (0)