This page provides a complete API reference for the StackOneToolSet class, the main entry point for tool discovery and management in the StackOne AI SDK.
For information about executing tools and converting them to framework-specific formats, see StackOneTool and Tools. For semantic search configuration details, see Semantic Search API. For integration with AI frameworks, see Framework Integrations.
StackOneToolSet is the primary interface for discovering and managing StackOne tools. It provides:
The class coordinates between the MCP backend for tool definitions, the semantic search API for natural language discovery, and provides factory methods for creating tool instances.
Sources: stackone_ai/toolset.py313-852
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
api_key | str | None | No* | None | API key for authentication. If not provided, reads from STACKONE_API_KEY environment variable. |
account_id | str | None | No | None | Default account ID for tool operations. Can be overridden per-method or via set_accounts(). |
base_url | str | None | No | DEFAULT_BASE_URL | Base URL for API requests. Override for custom deployments. |
search | SearchConfig | None | No | {"method": "auto"} | Search configuration. Pass None to disable search entirely. Pass dict with method, top_k, min_similarity for custom defaults. |
* Either api_key parameter or STACKONE_API_KEY environment variable must be provided.
ToolsetConfigError: If no API key is provided via parameter or environment variableSources: stackone_ai/toolset.py316-350 stackone_ai/toolset.py338-343
| Field | Type | Description |
|---|---|---|
method | SearchMode | Search backend: "auto" (try semantic, fallback to local), "semantic" (API only), or "local" (BM25+TF-IDF only) |
top_k | int | Maximum number of results to return |
min_similarity | float | Minimum similarity score threshold (0.0-1.0) |
All fields are optional. When provided to constructor, these become defaults for search methods. Per-call parameters override these defaults.
Sources: stackone_ai/toolset.py36-53 stackone_ai/toolset.py33
Sets default account IDs for tool filtering. Returns self for method chaining.
Parameters:
account_ids: List of account ID strings to use as defaultsReturns: The StackOneToolSet instance for chaining
Example:
Sources: stackone_ai/toolset.py351-361
Fetches tools from the MCP backend with optional filtering. This is the primary method for explicit tool discovery.
Parameters:
| Parameter | Type | Description |
|---|---|---|
account_ids | list[str] | None | Account IDs to fetch tools for. If None, uses set_accounts() value or constructor account_id. If no accounts specified, fetches global tools. |
providers | list[str] | None | Provider name filters (e.g., ["bamboohr", "hibob"]). Case-insensitive matching. |
actions | list[str] | None | Action pattern filters with glob support (e.g., ["*_list_*", "bamboohr_*"]). |
Returns: Tools collection containing matched tools
Raises: ToolsetLoadError if tool fetching fails
Sources: stackone_ai/toolset.py730-805 stackone_ai/toolset.py703-728
Tools are fetched for multiple accounts by calling the MCP endpoint once per account:
account_ids parameter: Overrides all defaultsset_accounts() value: Used if no account_ids parameteraccount_id: Used if neither above specifiedSources: stackone_ai/toolset.py775-782
Provider filtering extracts the first underscore-delimited segment of tool names and performs case-insensitive matching:
bamboohr_list_employees → Provider: bamboohr["BambooHR", "hibob"] (case-insensitive)Sources: stackone_ai/toolset.py703-716 stackone_ai/toolset.py793-794
Action filtering uses Python's fnmatch for glob pattern matching:
| Pattern | Matches | Doesn't Match |
|---|---|---|
*_list_* | bamboohr_list_employees, hibob_list_contacts | bamboohr_get_employee |
bamboohr_* | bamboohr_list_employees, bamboohr_create_job | hibob_list_employees |
bamboohr_list_employees | bamboohr_list_employees (exact) | All others |
Sources: stackone_ai/toolset.py718-728 stackone_ai/toolset.py796-797
Searches for and fetches tools using natural language queries with semantic or local BM25+TF-IDF search.
Parameters:
| Parameter | Type | Description |
|---|---|---|
query | str | Natural language description (e.g., "manage employee records", "send a message") |
connector | str | None | Filter to single provider/connector (e.g., "bamboohr") |
top_k | int | None | Maximum results. Overrides constructor default. |
min_similarity | float | None | Similarity threshold 0.0-1.0. Overrides constructor default. |
account_ids | list[str] | None | Account IDs to search within. Uses set_accounts() if not provided. |
search | SearchMode | None | Search backend: "auto", "semantic", or "local". Overrides constructor default. |
Returns: Tools collection with matched and fetched tools
Raises:
ToolsetConfigError: If search is disabled (search=None in constructor)SemanticSearchError: If API fails and search="semantic"| Mode | Behavior |
|---|---|
"auto" | Try semantic API first. On failure, fall back to local BM25+TF-IDF. |
"semantic" | Use only semantic API. Raises SemanticSearchError if API unavailable. |
"local" | Use only local BM25+TF-IDF. No API call made. |
Sources: stackone_ai/toolset.py442-578 stackone_ai/toolset.py496-509 stackone_ai/toolset.py522-578
The semantic search backend:
ThreadPoolExecutor (max 10 workers)Sources: stackone_ai/toolset.py532-569
Local search uses ToolIndex from stackone_ai.local_search module, which implements BM25+TF-IDF over tool names and descriptions:
min_score thresholdtop_k limitSources: stackone_ai/toolset.py410-440
Lightweight search returning only action names and scores without fetching full tool definitions. Useful for inspecting search results or building custom filtering logic.
Parameters:
| Parameter | Type | Description |
|---|---|---|
query | str | Natural language query |
connector | str | None | Single connector filter |
account_ids | list[str] | None | Accounts to scope search. If provided, results filtered to connectors in those accounts. |
top_k | int | None | Maximum results |
min_similarity | float | None | Similarity threshold |
Returns: list[SemanticSearchResult] with action names, scores, and metadata
Raises:
ToolsetConfigError: If search is disabledAction names in results are normalized to MCP format (e.g., bamboohr::v1.0::list_employees → bamboohr_list_employees), but multiple API versions of the same action may appear with individual scores.
Sources: stackone_ai/toolset.py580-701 stackone_ai/toolset.py688-701
When account_ids is provided:
fetch_tools(account_ids) called to determine available connectorsWhen account_ids is None:
Sources: stackone_ai/toolset.py639-683
Returns a callable SearchTool wrapper for use in agent loops. The returned object can be called directly with a query string to get a Tools collection.
Parameters:
search: Override default search mode for this SearchTool instanceReturns: SearchTool instance
Raises: ToolsetConfigError if search is disabled
Example:
Sources: stackone_ai/toolset.py363-394
The SearchTool class returned by get_search_tool() is a lightweight wrapper that makes search operations directly callable:
The SearchTool.__call__ method delegates to StackOneToolSet.search_tools() with merged configuration (constructor defaults + per-call overrides).
Sources: stackone_ai/toolset.py259-311 stackone_ai/toolset.py275-310
Lazily initializes and returns a SemanticSearchClient instance configured with the toolset's API key and base URL. Used internally by search methods.
Returns: SemanticSearchClient instance
Note: The client is initialized on first access and cached in _semantic_client for subsequent calls.
Sources: stackone_ai/toolset.py396-408
The toolset creates tools using the internal _StackOneRpcTool class, which implements RPC-style execution through the /actions/rpc endpoint:
Key aspects:
POST /actions/rpc with action name in bodybody, headers, path, query parameters mapped to RPC payload structurex-account-id header if presentnullable=False, optional fields nullable=TrueSources: stackone_ai/toolset.py815-828 stackone_ai/toolset.py171-257 stackone_ai/toolset.py200-224
Base exception for all toolset-related errors.
Sources: stackone_ai/toolset.py81-84
Raised when there is a configuration error (e.g., missing API key, search disabled when attempting search operations).
Common triggers:
search=NoneSources: stackone_ai/toolset.py87-90 stackone_ai/toolset.py340-343 stackone_ai/toolset.py386-388
Raised when there is an error loading tools from the MCP backend.
Sources: stackone_ai/toolset.py93-96 stackone_ai/toolset.py801-804
API authentication uses HTTP Basic Auth with the API key:
Format: Authorization: Basic <base64(api_key:)>
Sources: stackone_ai/toolset.py126-128
All requests include a User-Agent header with SDK version:
Version is extracted from package metadata or defaults to "dev" when running from source.
Sources: stackone_ai/toolset.py57-68
MCP requests include:
Authorization: Basic auth headerUser-Agent: SDK version stringx-account-id: Account ID (if specified)Sources: stackone_ai/toolset.py806-813
The toolset uses _run_async() to run async MCP operations synchronously, with special handling for nested event loops:
Behavior:
asyncio.run()This allows synchronous toolset methods to internally use async MCP client operations.
Sources: stackone_ai/toolset.py99-123
Refresh this wiki