def __init__(
      self,
      *,
      connection_params: Union[
          StdioServerParameters,
          StdioConnectionParams,
          SseConnectionParams,
          StreamableHTTPConnectionParams,
      ],
      tool_filter: Optional[Union[ToolPredicate, List[str]]] = None,
      errlog: TextIO = sys.stderr,
  ):
    """Initializes the MCPToolset.

    Args:
      connection_params: The connection parameters to the MCP server. Can be:
        `StdioConnectionParams` for using local mcp server (e.g. using `npx` or
        `python3`); or `SseConnectionParams` for a local/remote SSE server; or
        `StreamableHTTPConnectionParams` for local/remote Streamable http
        server. Note, `StdioServerParameters` is also supported for using local
        mcp server (e.g. using `npx` or `python3` ), but it does not support
        timeout, and we recommend to use `StdioConnectionParams` instead when
        timeout is needed.
      tool_filter: Optional filter to select specific tools. Can be either: - A
        list of tool names to include - A ToolPredicate function for custom
        filtering logic
      errlog: TextIO stream for error logging.
    """
    super().__init__(tool_filter=tool_filter)

    if not connection_params:
      raise ValueError("Missing connection params in MCPToolset.")

    self._connection_params = connection_params
    self._errlog = errlog

    # Create the session manager that will handle the MCP connection
    self._mcp_session_manager = MCPSessionManager(
        connection_params=self._connection_params,
        errlog=self._errlog,
    )

    self._session = None
Initializes the MCPToolset.

    Args:
      connection_params: The connection parameters to the MCP server. Can be:
        `StdioConnectionParams` for using local mcp server (e.g. using `npx` or
        `python3`); or `SseConnectionParams` for a local/remote SSE server; or
        `StreamableHTTPConnectionParams` for local/remote Streamable http
        server. Note, `StdioServerParameters` is also supported for using local
        mcp server (e.g. using `npx` or `python3` ), but it does not support
        timeout, and we recommend to use `StdioConnectionParams` instead when
        timeout is needed.
      tool_filter: Optional filter to select specific tools. Can be either: - A
        list of tool names to include - A ToolPredicate function for custom
        filtering logic
      errlog: TextIO stream for error logging.
    
src/google/adk/tools/mcp_tool/mcp_toolset.py