Skip to content

Configuring Built-in Features

GTB comes with several powerful features enabled by default. These are: - update: Automatic self-updates via GitHub releases. - init: Interactive configuration bootstrapping. - mcp: The Model Context Protocol server for AI agents. This one is a link: a generated project has it while cmd/<name>/mcp.go blank-imports pkg/mcp, and gtb disable mcp removes that file rather than rendering a Disable. See shipping without MCP. - docs: The integrated TUI documentation browser and AI assistant. - doctor: Environment and configuration health checks. - changelog: Rendering of the tool's embedded changelog.

You can selectively disable these features or enable additional opt-in features in your main.go using the props.Tool configuration.

Disabling Features

If you don't need certain functionality (like self-updates or the MCP server), you can disable it:

props := &props.Props{
    Tool: props.Tool{
        Name: "mytool",
        Features: props.SetFeatures(
            props.Disable(props.UpdateCmd), // Disable self-updates
        ),
    },
}

Shipping without MCP

mcp is not a SetFeatures toggle. The tool has it while its main package blank-imports gitlab.com/phpboyscout/go-tool-base/pkg/mcp (a generated project's cmd/<name>/mcp.go); without the import there is no mcp command and the binary carries neither go/mcp nor the MCP SDK (the claude-local and codex-local chat providers bring the SDK back through go/chat-mcptools, the tool bridge they need to accept tools, unless the manifest sets chat.tool_bridge: false). Omit the import for a build that must ship without an MCP surface. A props.Disable(props.McpCmd) left in an older main is ignored and listed by doctor.

Enabling Opt-in Features

Some features, like the AI provider setup in the init command, are disabled by default to keep the footprint small:

props := &props.Props{
        Features: props.SetFeatures(
            props.Enable(props.AiCmd), // Enables 'init ai'
        ),
}

Configuring Version checking

The version and update commands rely on GitHub releases. Ensure you have the GitHub property set correctly in your Props:

GitHub: props.GitHub{
    Org:  "my-org",
    Repo: "my-tool",
},

Feature Reference Table

The following table provides a complete reference for all FeatureID constants, showing their default state, affected commands, and typical use cases:

Constant Default State Affected Commands Use Case
props.UpdateCmd Enabled update Disable if you manage updates externally (package managers, CI/CD)
props.InitCmd Enabled init, init github Disable if your tool has no configuration requirements
props.McpCmd Linked (on while pkg/mcp is imported) mcp, mcp start, mcp tools Omit the pkg/mcp import if AI agent integration is not needed; the binary then ships without the MCP SDK
props.DocsCmd Enabled docs, docs serve Disable if you don't embed documentation
props.DoctorCmd Enabled doctor Disable if you don't ship environment/configuration health checks
props.ChangelogCmd Enabled changelog Disable if your tool has no embedded changelog
props.AiCmd Opt-in init ai, docs ask The switch for GTB's AI-based features: the ai config section and ai.provider, the init ai wizard, docs ask, the doctor check. Which chat provider modules the binary links is a separate choice, chat.providers in the manifest (see generate)
props.ConfigCmd Opt-in config get, config set, config list, config validate Enable to expose programmatic config access
props.TelemetryCmd Opt-in telemetry status, telemetry reset Enable to ship opt-in anonymous usage telemetry
props.ManCmd Opt-in man Enable to generate roff man pages for your CLI

Enable vs Disable Semantics

  • Disable: Use this to turn OFF default features your tool doesn't need
  • Enable: Use this to turn ON optional features your tool wants to provide

Most tools should only need to customize a few options. The defaults are designed to work well for typical CLI applications.


Feature Combinations

Here are some common configuration patterns:

Minimal Tool (No Auto-Updates or AI)

For simple, lightweight utilities:

props := &props.Props{
    Tool: props.Tool{
        Name: "mytool",
        Features: props.SetFeatures(
            props.Disable(props.UpdateCmd),
        ),
    },
}

AI-Powered Tool

For tools that leverage AI features:

props := &props.Props{
    Tool: props.Tool{
        Name: "mytool",
        Features: props.SetFeatures(
            props.Enable(props.AiCmd),  // Enable AI provider setup in 'init'
        ),
    },
}

Documentation-Only Tool

For tools focused on documentation delivery:

props := &props.Props{
    Tool: props.Tool{
        Name: "mydocs",
        Features: props.SetFeatures(
            props.Disable(props.UpdateCmd),
            props.Disable(props.InitCmd),
            props.Disable(props.DocsCmd), // Disable docs if not needed, otherwise it's enabled by default
        ),
    },
}

Air-Gapped Environment

For tools deployed in restricted environments without internet access:

props := &props.Props{
    Tool: props.Tool{
        Name: "mytool",
        Features: props.SetFeatures(
            props.Disable(props.UpdateCmd),  // No GitHub access for updates
        ),
        // No AI agent connectivity: omit the pkg/mcp import from main instead.
    },
}

Runtime Checks

You can check at runtime whether a feature is enabled or disabled:

func isFeatureEnabled(p *props.Props, feature props.FeatureID) bool {
    // The resolved set on Props: the registry's defaults, then Tool.Features.
    return p.GetFeatures().Enabled(feature)
}

Feature Registration

The feature mechanism affects command registration at startup. Changing these values after root.NewCmdRoot() has been called will have no effect.