Skip to content

rust(feat): gate MCP tools with account feature flags at startup - #764

Draft
evan-sift wants to merge 3 commits into
mainfrom
rust/mcp-feature-flag-gating
Draft

rust(feat): gate MCP tools with account feature flags at startup#764
evan-sift wants to merge 3 commits into
mainfrom
rust/mcp-feature-flag-gating

Conversation

@evan-sift

@evan-sift evan-sift commented Aug 26, 2026

Copy link
Copy Markdown
Collaborator

Description

The MCP server now resolves the account's enabled feature flags at startup, using the configured API key, and excludes tools whose flag is not enabled. Most tools carry no flag and are always registered.

  • New sift_mcp::FeatureFlags: fetched once at startup via GET /api/v1/feature-flags/variants (5s timeout, bearer auth). A flag is enabled when its variant value is non-empty and not off.
  • A static registry in feature_flags.rs maps tool names to required flags; gated tools are removed from the router before serving, so they are absent from tools/list and rejected on call.
  • Fail-closed: if the fetch fails, the server starts normally with flag-gated tools disabled and logs a warning with the full error chain. Flag changes apply on MCP restart.
  • The fetch is functional traffic and still runs under --disable-nonessential-traffic (help text updated).
  • Removed the temporary Cargo feature that gated a tool domain at build time; those tools are now always built and gate at runtime instead.

Verification

  • cargo test -p sift_mcp: 311 passed. New coverage: wire-level fetch test (request line, bearer header, trailing-slash URI, 500 handling, response parse), registry drift guard, client-event invariant with all flags enabled, wire-level tools/list and tools/call for both flag states, fail-closed default behavior, enabled-semantics unit tests.
  • cargo check -p sift_cli, cargo fmt --all --check, cargo clippy --all-features (no new warnings) all pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant