Skip to main content
When building applications with multiple connected accounts, you often need to dynamically load tools based on which integrations are actually available for each account. The fetch_tools() method enables this by fetching tool definitions at runtime based on the provided account IDs, rather than loading a static catalogue. This is particularly useful for:
  • Multi-tenant applications: Each customer may have different integrations connected
  • AI agents: Provide only the tools that are actually available for the current user’s connected accounts
  • Runtime flexibility: Tool availability adapts automatically as integrations are added or removed

Basic Usage

from stackone_ai import StackOneToolSet

toolset = StackOneToolSet()

# Fetch tools available for specific accounts
tools = toolset.fetch_tools(account_ids=["account-123", "account-456"])

employee_tool = tools.get_tool("hris_list_employees")
result = employee_tool.call(limit=5)
fetch_tools() pulls the current tool definitions directly from StackOne based on your account IDs, reusing the credentials you already configured (e.g., via STACKONE_API_KEY).
Note: Install the optional extra (pip install 'stackone-ai[mcp]') on Python 3.10+ to enable dynamic discovery.

Filtering Tools

You can filter tools by account IDs, providers, and action patterns:
# Filter by account IDs
toolset.set_accounts(["account-123", "account-456"])
tools = toolset.fetch_tools()
# OR
tools = toolset.fetch_tools(account_ids=["account-123", "account-456"])

# Filter by providers
tools = toolset.fetch_tools(providers=["hibob", "bamboohr"])

# Filter by actions with exact match
tools = toolset.fetch_tools(
    actions=["hibob_list_employees", "hibob_create_employees"]
)

# Filter by actions with glob patterns
tools = toolset.fetch_tools(actions=["*_list_employees"])

# Combine multiple filters
tools = toolset.fetch_tools(
    account_ids=["account-123"],
    providers=["hibob"],
    actions=["*_list_*"],
)
This is especially useful when you want to:
  • Limit tools to specific linked accounts
  • Focus on specific HR/CRM/ATS providers
  • Get only certain types of operations (e.g., all “list” operations)

Example

See the complete example with all filtering options: examples/