1414
1515from __future__ import annotations
1616
17- import sys
18- from typing import Callable
19- from typing import Dict
20- from typing import List
21- from typing import Optional
22- from typing import TextIO
17+ import inspect
2318from typing import Union
2419
25- from google .adk .auth .auth_schemes import AuthScheme
26- from google .adk .agents .readonly_context import ReadonlyContext
27- from google .adk .auth .auth_credential import AuthCredential
28- from google .adk .tools .base_toolset import ToolPredicate
2920from google .adk .tools .mcp_tool .mcp_toolset import McpToolset
3021from google .adk .tools .mcp_tool .mcp_session_manager import SseConnectionParams
3122from google .adk .tools .mcp_tool .mcp_session_manager import StdioConnectionParams
@@ -78,17 +69,18 @@ def __init__(
7869 SseConnectionParams ,
7970 StreamableHTTPConnectionParams ,
8071 ],
81- tool_filter : Optional [Union [ToolPredicate , List [str ]]] = None ,
82- tool_name_prefix : Optional [str ] = None ,
83- errlog : TextIO = sys .stderr ,
84- auth_scheme : Optional [AuthScheme ] = None ,
85- auth_credential : Optional [AuthCredential ] = None ,
86- require_confirmation : Union [bool , Callable [..., bool ]] = False ,
87- header_provider : Optional [Callable [[ReadonlyContext ], Dict [str , str ]]] = None ,
72+ # tool_filter: Optional[Union[ToolPredicate, List[str]]] = None,
73+ # tool_name_prefix: Optional[str] = None,
74+ # errlog: TextIO = sys.stderr,
75+ # auth_scheme: Optional[AuthScheme] = None,
76+ # auth_credential: Optional[AuthCredential] = None,
77+ # require_confirmation: Union[bool, Callable[..., bool]] = False,
78+ # header_provider: Optional[Callable[[ReadonlyContext], Dict[str, str]]] = None,
79+ ** kwargs , # other kwargs for super class (i.e., McpToolset.__init__)
8880 ):
8981 """Initializes the TrustedMcpToolset.
9082
91- Args:
83+ Args: ref McpToolset.__init__
9284 connection_params: The connection parameters to the MCP server. Can be:
9385 ``StdioConnectionParams`` for using local mcp server (e.g. using ``npx`` or
9486 ``python3``); or ``SseConnectionParams`` for a local/remote SSE server; or
@@ -111,15 +103,16 @@ def __init__(
111103 header_provider: A callable that takes a ReadonlyContext and returns a
112104 dictionary of headers to be used for the MCP session.
113105 """
106+ # Filter out the kwargs that are not allowed by the super class
107+ sig = inspect .signature (McpToolset .__init__ )
108+ allowed = set (sig .parameters .keys ())
109+ allowed .discard ("self" )
110+ # Filter out args already used in this class
111+ allowed .discard ("connection_params" )
112+ filtered_kwargs = {k : v for k , v in kwargs .items () if k in allowed }
114113 super ().__init__ (
115114 connection_params = connection_params ,
116- tool_filter = tool_filter ,
117- tool_name_prefix = tool_name_prefix ,
118- errlog = errlog ,
119- auth_scheme = auth_scheme ,
120- auth_credential = auth_credential ,
121- require_confirmation = require_confirmation ,
122- header_provider = header_provider ,
115+ ** filtered_kwargs ,
123116 )
124117
125118 # Create the session manager that will handle the TrustedMCP connection
0 commit comments