Skip to content

ExecuteToolsConfig account_ids not propagated to _account_ids — tool_search fails with 400 #167

@RomSes2

Description

@RomSes2

Bug

ExecuteToolsConfig.account_ids passed to the StackOneToolSet constructor does not populate self._account_ids. When tool_search is called, it invokes search_tools() which calls fetch_tools(account_ids=self._account_ids) — but _account_ids is empty, so the MCP request to https://api.stackone.com/mcp has no x-account-id header, resulting in a 400 Bad Request.

Reproduction

from stackone_ai import StackOneToolSet

toolset = StackOneToolSet(
    search={"method": "auto", "top_k": 5},
    execute={"account_ids": ["my-account-id"], "timeout": 60},
)

# This fails with: ToolsetLoadError: Error fetching tools: unhandled errors in a TaskGroup (1 sub-exception)
# Root cause: httpx.HTTPStatusError: Client error '400 Bad Request' for url 'https://api.stackone.com/mcp'
toolset.execute("tool_search", {"query": "list orders"})

Workaround

Calling set_accounts() explicitly after construction fixes it:

toolset = StackOneToolSet(
    search={"method": "auto", "top_k": 5},
    execute={"account_ids": account_ids, "timeout": 60},
)
toolset.set_accounts(account_ids)  # <-- this is needed

# Now works
toolset.execute("tool_search", {"query": "list orders"})

Root cause

In StackOneToolSet.__init__(), the execute config is stored as self._execute_config but its account_ids are never copied to self._account_ids. The search_tools() method reads from self._account_ids (line 871), which is always [] unless set_accounts() is called explicitly.

Expected behavior

ExecuteToolsConfig.account_ids should populate self._account_ids during __init__(), so that tool_search works without requiring a separate set_accounts() call.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions