Skip to main content

Initialise the ToolSet

Start by creating a StackOneToolSet instance:
import { StackOneToolSet } from "@stackone/ai";

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

Fetch Tools

Use fetchTools() to dynamically load tools from StackOne’s MCP endpoint:
// Fetch all tools for the configured account
const tools = await toolset.fetchTools();

// Or fetch with filtering options
const hrisTools = await toolset.fetchTools({
  actions: ['*_list_*', '*_get_*'],  // Only read operations
});

Execute Tools

Basic Tool Execution

// Get a specific tool
const employeeTool = tools.getTool('bamboohr_list_employees');

// Execute with parameters
const employees = await employeeTool.execute({
  query: { limit: 10 },
});

console.log(employees);

Tool Filtering with fetchTools()

Filter by Account IDs

// Filter by account IDs using options
const tools = await toolset.fetchTools({
  accountIds: ['account-123', 'account-456'],
});

// Or use setAccounts() for persistent filtering
toolset.setAccounts(['account-123', 'account-456']);
const tools = await toolset.fetchTools();

Filter by Providers

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

Filter by Actions with Glob Patterns

// Filter by actions with exact match
const tools = await toolset.fetchTools({
  actions: ['bamboohr_list_employees', 'bamboohr_get_employee'],
});

// Filter by actions with glob patterns
const listTools = await toolset.fetchTools({
  actions: ['*_list_*'],  // All list operations
});

// Combine multiple filters
const tools = await toolset.fetchTools({
  accountIds: ['account-123'],
  providers: ['hibob'],
  actions: ['*_list_*'],
});

List Available Tools

// Fetch all available tools
const tools = await toolset.fetchTools();
console.log('Tools:', tools.toArray());

Environment Configuration

Using Environment Variables

// Set in your .env file
// STACKONE_API_KEY=your_api_key
// STACKONE_ACCOUNT_ID=your_account_id

const toolset = new StackOneToolSet({
  // API key and account ID are automatically read from environment
});

Example

examples/fetch-tools.ts
View on GitHub →

Next Steps