Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/google/adk/tools/mcp_tool/mcp_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import base64
import inspect
import logging
import os
from typing import Any
from typing import Callable
from typing import Dict
Expand Down Expand Up @@ -169,6 +170,16 @@ def __init__(
Raises:
ValueError: If mcp_tool or mcp_session_manager is None.
"""

# --- BEGIN BOUND TOKEN PATCH ---
# Set GOOGLE_API_PREVENT_AGENT_TOKEN_SHARING_FOR_GCP_SERVICES to false
# to disable bound token sharing. Tracking on
# https://github.com/google/adk-python/issues/5361
os.environ["GOOGLE_API_PREVENT_AGENT_TOKEN_SHARING_FOR_GCP_SERVICES"] = (
"false"
)
# --- END BOUND TOKEN PATCH ---

super().__init__(
name=mcp_tool.name,
description=mcp_tool.description if mcp_tool.description else "",
Expand All @@ -178,6 +189,7 @@ def __init__(
if auth_scheme
else None,
)

self._mcp_tool = mcp_tool
self._mcp_session_manager = mcp_session_manager
self._require_confirmation = require_confirmation
Expand Down
10 changes: 10 additions & 0 deletions src/google/adk/tools/mcp_tool/mcp_toolset.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import asyncio
import base64
import logging
import os
import sys
from typing import Any
from typing import Awaitable
Expand Down Expand Up @@ -158,6 +159,15 @@ def __init__(
sampling_capabilities: Optional capabilities for sampling.
"""

# --- BEGIN BOUND TOKEN PATCH ---
# Set GOOGLE_API_PREVENT_AGENT_TOKEN_SHARING_FOR_GCP_SERVICES to false
# to disable bound token sharing. Tracking on
# https://github.com/google/adk-python/issues/5361
os.environ["GOOGLE_API_PREVENT_AGENT_TOKEN_SHARING_FOR_GCP_SERVICES"] = (
"false"
)
# --- END BOUND TOKEN PATCH ---

super().__init__(tool_filter=tool_filter, tool_name_prefix=tool_name_prefix)

self._sampling_callback = sampling_callback
Expand Down
Loading