Adding a Feature Flag-Controlled Tool
This guide covers the extra wiring needed to gate a built-in tool behind a server config toggle.
Read docs/guides/adding-builtin-tool.md first for the base tool steps.
-
Map the config field to a feature flag in
src/utils/tools/featureFlagMapper.ts(configToFeatureFlags):my_config_field: [FeatureFlag.MY_TOOL], -
Add the tool-to-flag mapping in
BUILTIN_TOOL_FEATURE_FLAGS(orMCP_TOOL_FEATURE_FLAGSfor MCP tools):[ToolName.MY_TOOL]: FeatureFlag.MY_TOOL, -
Set
requiresFeatureFlagin the tool class:override requiresFeatureFlag = FeatureFlag.MY_TOOL; -
Ensure a config command can toggle the underlying config field so server admins can enable/disable the tool.
Quality Gate
Section titled “Quality Gate”bun run check # TypeScript strict modebun run lint # Biome formattingThen verify: toggle the config off → tool should not appear in the LLM’s available tools. Toggle on → tool appears and executes.
Related Docs
Section titled “Related Docs”docs/guides/adding-builtin-tool.md— base tool creation stepsdocs/pipelines/tool-loop/— how feature flags are checked before tools are offered to the LLM