Skip to content
Draft
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
7 changes: 6 additions & 1 deletion stackone_adk/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ class StackOnePlugin(BasePlugin):
timeout: Per-request timeout in seconds for HTTP calls (account
discovery and tool execution). Defaults to 180s — increase further
for very slow connectors (e.g. some Workday endpoints).
feedback: Whether to expose the global ``submit_feedback`` tool, which the
StackOne MCP server provides on every account. Enabled by default in both
modes; set to ``False`` to omit it.
"""

def __init__(
Expand All @@ -114,6 +117,7 @@ def __init__(
search: SearchConfig | None = None,
execute: ExecuteToolsConfig | None = None,
timeout: float = DEFAULT_TIMEOUT,
feedback: bool = True,
) -> None:
super().__init__(name=plugin_name)

Expand Down Expand Up @@ -162,14 +166,15 @@ def __init__(
"(the LLM's search query handles that)."
)
# Use SDK's internal builder until a public API is exposed.
meta_tools = self._toolset._build_tools(account_ids=account_ids)
meta_tools = self._toolset._build_tools(account_ids=account_ids, feedback=feedback)
for tool in meta_tools:
self._tools.append(StackOneAdkTool(tool))
else:
stackone_tools = self._toolset.fetch_tools(
account_ids=account_ids,
providers=providers,
actions=actions,
feedback=feedback,
)
for tool in stackone_tools:
try:
Expand Down
35 changes: 32 additions & 3 deletions tests/test_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def test_default_init_auto_discovers(self, mock_toolset_cls, mock_discover):

mock_discover.assert_called_once()
mock_toolset.fetch_tools.assert_called_once_with(
account_ids=["acct-auto"], providers=None, actions=None
account_ids=["acct-auto"], providers=None, actions=None, feedback=True
)
assert len(plugin.get_tools()) == 2
assert plugin.name == "stackone_plugin"
Expand Down Expand Up @@ -156,6 +156,7 @@ def test_skips_discovery_when_account_ids_provided(self, mock_toolset_cls, mock_
account_ids=["acct-1", "acct-2"],
providers=["calendly"],
actions=["*_list_*"],
feedback=True,
)

@patch(PLUGIN_PATCH_DISCOVER, return_value=["acct-auto"])
Expand Down Expand Up @@ -261,7 +262,7 @@ def test_search_mode_uses_build_tools(self, mock_toolset_cls, mock_discover):

kwargs = mock_toolset_cls.call_args.kwargs
assert kwargs["search"] == {"method": "auto"}
mock_toolset._build_tools.assert_called_once_with(account_ids=["acct-1"])
mock_toolset._build_tools.assert_called_once_with(account_ids=["acct-1"], feedback=True)
mock_toolset.fetch_tools.assert_not_called()
tools = plugin.get_tools()
assert len(tools) == 2
Expand All @@ -288,6 +289,32 @@ def test_search_mode_threads_through_config(self, mock_toolset_cls, mock_discove
assert kwargs["execute"] == {"account_ids": ["acct-explicit"], "timeout": 120}
assert kwargs["timeout"] == 200

@patch(PLUGIN_PATCH_DISCOVER, return_value=["acct-1"])
@patch(PLUGIN_PATCH_TOOLSET)
def test_search_mode_can_disable_feedback(self, mock_toolset_cls, mock_discover):
mock_toolset = MagicMock()
mock_toolset._build_tools.return_value = _make_mock_tools(2)
mock_toolset_cls.return_value = mock_toolset

StackOnePlugin(api_key="sk-test", mode="search_and_execute", feedback=False)

mock_toolset._build_tools.assert_called_once_with(account_ids=["acct-1"], feedback=False)


class TestStackOnePluginFeedback:
@patch(PLUGIN_PATCH_DISCOVER, return_value=["acct-auto"])
@patch(PLUGIN_PATCH_TOOLSET)
def test_default_mode_can_disable_feedback(self, mock_toolset_cls, mock_discover):
mock_toolset = MagicMock()
mock_toolset.fetch_tools.return_value = _make_mock_tools(0)
mock_toolset_cls.return_value = mock_toolset

StackOnePlugin(api_key="sk-test", feedback=False)

mock_toolset.fetch_tools.assert_called_once_with(
account_ids=["acct-auto"], providers=None, actions=None, feedback=False
)

@patch(PLUGIN_PATCH_DISCOVER)
@patch(PLUGIN_PATCH_TOOLSET)
def test_search_mode_with_explicit_account_ids(self, mock_toolset_cls, mock_discover):
Expand All @@ -302,7 +329,9 @@ def test_search_mode_with_explicit_account_ids(self, mock_toolset_cls, mock_disc
)

mock_discover.assert_not_called()
mock_toolset._build_tools.assert_called_once_with(account_ids=["acct-a", "acct-b"])
mock_toolset._build_tools.assert_called_once_with(
account_ids=["acct-a", "acct-b"], feedback=True
)

@patch(PLUGIN_PATCH_DISCOVER, return_value=["acct-1"])
@patch(PLUGIN_PATCH_TOOLSET)
Expand Down