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 fetchTools() method enables this by fetching tool definitions at runtime based on the provided account IDs, rather than loading a static catalog. 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

import { StackOneToolSet } from "@stackone/stackone-client-ts";

const toolset = new StackOneToolSet({
  baseUrl: "https://api.stackone.com",
});

// Fetch tools available for specific accounts
const tools = await toolset.fetchTools({
  accountIds: ["account-123", "account-456"],
});

const employeeTool = tools.getTool("hris_list_employees");
const result = await employeeTool?.execute({
  query: { limit: 5 },
});
fetchTools() 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).

Filtering Tools

You can filter tools by account IDs, providers, and action patterns:
// Filter by account IDs
toolset.setAccounts(["account-123", "account-456"]);
const tools = await toolset.fetchTools();
// OR
const tools = await toolset.fetchTools({
  accountIds: ["account-123", "account-456"],
});

// Filter by providers
const tools = await toolset.fetchTools({ providers: ["hibob", "bamboohr"] });

// Filter by actions with exact match
const tools = await toolset.fetchTools({
  actions: ["hibob_list_employees", "hibob_create_employees"],
});

// Filter by actions with glob patterns
const tools = await toolset.fetchTools({ actions: ["*_list_employees"] });

// Combine multiple filters
const tools = await toolset.fetchTools({
  accountIds: ["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)

Complete Example

For a comprehensive example including all filtering options and usage patterns, see: View full example
I