Skip to content

Commit 4e19a3c

Browse files
authored
fix(toolbox-core): Add strict flag support to sync client (#230)
* chore: Add unit test cases * chore: Delint * feat: Warn on insecure tool invocation with authentication This change introduces a warning that is displayed immediately before a tool invocation if: 1. The invocation includes an authentication header. 2. The connection is being made over non-secure HTTP. > [!IMPORTANT] The purpose of this warning is to alert the user to the security risk of sending credentials over an unencrypted channel and to encourage the use of HTTPS. * fix!: Warn about https only during tool initialization * fix(toolbox-core): Add strict flag validation to sync client. * chore: delint
1 parent 75b79c9 commit 4e19a3c

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

packages/toolbox-core/src/toolbox_core/sync_client.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ def load_toolset(
113113
name: str,
114114
auth_token_getters: dict[str, Callable[[], str]] = {},
115115
bound_params: Mapping[str, Union[Callable[[], Any], Any]] = {},
116+
strict: bool = False,
116117
) -> list[ToolboxSyncTool]:
117118
"""
118119
Synchronously fetches a toolset and loads all tools defined within it.
@@ -123,12 +124,22 @@ def load_toolset(
123124
callables that return the corresponding authentication token.
124125
bound_params: A mapping of parameter names to bind to specific values or
125126
callables that are called to produce values as needed.
127+
strict: If True, raises an error if *any* loaded tool instance fails
128+
to utilize at least one provided parameter or auth token (if any
129+
provided). If False (default), raises an error only if a
130+
user-provided parameter or auth token cannot be applied to *any*
131+
loaded tool across the set.
126132
127133
Returns:
128134
list[ToolboxSyncTool]: A list of callables, one for each tool defined
129135
in the toolset.
136+
137+
Raises:
138+
ValueError: If validation fails based on the `strict` flag.
130139
"""
131-
coro = self.__async_client.load_toolset(name, auth_token_getters, bound_params)
140+
coro = self.__async_client.load_toolset(
141+
name, auth_token_getters, bound_params, strict
142+
)
132143

133144
if not self.__loop or not self.__thread:
134145
raise ValueError("Background loop or thread cannot be None.")

0 commit comments

Comments
 (0)