@frontmcp/plugin-feature-flags 1.5.7 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,105 @@
1
+ # @frontmcp/plugin-feature-flags
2
+
3
+ Gate MCP capabilities behind feature flags — hide tools, branch behaviour, and
4
+ roll out changes per user without redeploying.
5
+
6
+ [![NPM](https://img.shields.io/npm/v/@frontmcp/plugin-feature-flags.svg)](https://www.npmjs.com/package/@frontmcp/plugin-feature-flags)
7
+
8
+ ## Install
9
+
10
+ ```bash
11
+ npm install @frontmcp/plugin-feature-flags
12
+ ```
13
+
14
+ ## Usage
15
+
16
+ ```ts
17
+ import { FeatureFlagPlugin } from '@frontmcp/plugin-feature-flags';
18
+ import { FrontMcp } from '@frontmcp/sdk';
19
+
20
+ @FrontMcp({
21
+ info: { name: 'my-server', version: '1.0.0' },
22
+ apps: [MyApp],
23
+ plugins: [
24
+ FeatureFlagPlugin.configure({
25
+ provider: 'static',
26
+ flags: { 'new-search': true, 'beta-export': false },
27
+ }),
28
+ ],
29
+ })
30
+ class Server {}
31
+ ```
32
+
33
+ Then read flags from any tool through `this.featureFlags`:
34
+
35
+ ```ts
36
+ @Tool({ name: 'search', inputSchema: { q: z.string() } })
37
+ export default class SearchTool extends ToolContext {
38
+ async execute({ q }: { q: string }) {
39
+ if (await this.featureFlags.isEnabled('new-search')) {
40
+ return newSearch(q);
41
+ }
42
+ return legacySearch(q);
43
+ }
44
+ }
45
+ ```
46
+
47
+ ## Providers
48
+
49
+ | Provider | `provider` | Notes |
50
+ | ------------ | ---------------- | ------------------------------------------------ |
51
+ | Static | `'static'` | Flags from config. Good for local dev and tests. |
52
+ | Split.io | `'splitio'` | Requires an SDK key. |
53
+ | LaunchDarkly | `'launchdarkly'` | Requires an SDK key. |
54
+ | Unleash | `'unleash'` | Requires a URL + API token. |
55
+ | Custom | `'custom'` | Supply your own `FeatureFlagAdapter`. |
56
+
57
+ ```ts
58
+ FeatureFlagPlugin.configure({
59
+ provider: 'launchdarkly',
60
+ sdkKey: process.env.LD_SDK_KEY,
61
+ // Which identity the flag is evaluated for. Defaults to the session's user.
62
+ userIdResolver: (ctx) => ctx.authInfo?.clientId,
63
+ attributesResolver: (ctx) => ({ plan: ctx.authInfo?.extra?.plan }),
64
+ });
65
+ ```
66
+
67
+ ### Custom adapter
68
+
69
+ ```ts
70
+ import { FeatureFlagPlugin, type FeatureFlagAdapter } from '@frontmcp/plugin-feature-flags';
71
+
72
+ const adapter: FeatureFlagAdapter = {
73
+ async isEnabled(key, ctx) {
74
+ return myBackend.check(key, ctx.userId);
75
+ },
76
+ };
77
+
78
+ FeatureFlagPlugin.configure({ provider: 'custom', adapter });
79
+ ```
80
+
81
+ ## API
82
+
83
+ `this.featureFlags` (an injected `FeatureFlagAccessor`):
84
+
85
+ | Method | Returns | Purpose |
86
+ | -------------------------- | ------------------------------- | --------------------------------------------- |
87
+ | `isEnabled(key, default?)` | `Promise<boolean>` | Evaluate one boolean flag |
88
+ | `getVariant(key)` | `Promise<FeatureFlagVariant>` | Multivariate flag value |
89
+ | `evaluateFlags(keys)` | `Promise<Map<string, boolean>>` | Batch evaluation in one round trip |
90
+ | `resolveRef(ref)` | `Promise<boolean>` | Resolve a flag reference (`{ flag, negate }`) |
91
+
92
+ Outside a tool, use `getFeatureFlags()` / `tryGetFeatureFlags()`.
93
+
94
+ ## Failure behaviour
95
+
96
+ If the provider is unreachable, `isEnabled` returns the `defaultValue` you pass
97
+ (or `false`). Always pass an explicit default for a flag that gates something
98
+ important, so an outage degrades the way you intend rather than silently
99
+ disabling a feature.
100
+
101
+ Full guide: [Feature Flags](https://docs.agentfront.dev/frontmcp/plugins/feature-flags-plugin)
102
+
103
+ ## License
104
+
105
+ Apache-2.0
package/esm/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@frontmcp/plugin-feature-flags",
3
- "version": "1.5.7",
3
+ "version": "1.6.0",
4
4
  "description": "Feature flag plugin for FrontMCP - dynamically gate MCP capabilities behind feature flags",
5
5
  "author": "AgentFront <info@agentfront.dev>",
6
6
  "license": "Apache-2.0",
@@ -49,7 +49,7 @@
49
49
  }
50
50
  },
51
51
  "dependencies": {
52
- "@frontmcp/sdk": "1.5.7"
52
+ "@frontmcp/sdk": "1.6.0"
53
53
  },
54
54
  "peerDependencies": {
55
55
  "@launchdarkly/node-server-sdk": "^9.0.0 || ^10.0.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@frontmcp/plugin-feature-flags",
3
- "version": "1.5.7",
3
+ "version": "1.6.0",
4
4
  "description": "Feature flag plugin for FrontMCP - dynamically gate MCP capabilities behind feature flags",
5
5
  "author": "AgentFront <info@agentfront.dev>",
6
6
  "license": "Apache-2.0",
@@ -49,7 +49,7 @@
49
49
  }
50
50
  },
51
51
  "dependencies": {
52
- "@frontmcp/sdk": "1.5.7"
52
+ "@frontmcp/sdk": "1.6.0"
53
53
  },
54
54
  "peerDependencies": {
55
55
  "@launchdarkly/node-server-sdk": "^9.0.0 || ^10.0.0",