New to tool defense? Start with Tool Defense 101 for an overview of why, how, and when to use it.
Configuration Modes
Thedefender option on StackOneToolSet accepts four shapes. Each maps to a distinct behavior for the RPC calls that toolset makes.
Default (defer to project dashboard)
Omittingdefender leaves the project’s dashboard setting in charge. The SDK adds no defender_config field to the RPC payload, so whatever you configured in the StackOne dashboard takes effect.
useProjectSettings: true cannot be combined with other defender fields; passing both throws a ToolSetConfigError at construction time.
Explicit SDK-level config
Pass an object to override your project’s dashboard setting with explicit per-toolset values. Missing fields fall back toDEFAULT_DEFENDER_CONFIG, which has all scanning on and blocking off.
Force disabled
Passnull to forcibly disable defender for this toolset. The SDK sends defender_config with every field set to false, overriding whatever the dashboard says.
Inspecting the Resolved Mode
Every toolset exposes adefenderMode getter that returns one of three strings:
The getter is useful in tests, custom observability, and conditional logging without poking at private internals.
Override warning
When the SDK overrides the project dashboard (modesdisabled or explicit), it emits a console.warn once per process per distinct override shape. Repeat constructions with the same configuration stay quiet, so wrapping the SDK in a per-request factory will not flood your logs.
Reading the Response
When defender runs (modesexplicit or, on the backend side, when project mode resolves to enabled), the RPC response includes a defenderMetadata sibling next to data:
A typed accessor is not yet exposed on the SDK response surface, so casting through the response object is the current ergonomic.
Runtime Validation
The constructor validatesuseProjectSettings: true is not combined with other defender fields. JavaScript callers that bypass TypeScript get a runtime error:
Next Steps
- Full runnable example covering all four modes, the
defenderModegetter, and the override warning - Defender (platform guide) for dashboard configuration, detection pipeline, and risk thresholds
- Tool Filtering for scoping toolsets by provider, action, or account
- Basic Usage for fetching and executing tools