@featureflip/mcp 0.2.0 → 0.3.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.
@@ -4,7 +4,7 @@ import * as n from "zod/v4";
4
4
  //#region src/version.ts
5
5
  var r = {
6
6
  name: "@featureflip/mcp",
7
- version: "0.2.0",
7
+ version: "0.3.0",
8
8
  mcpName: "io.github.canopy-labs/featureflip",
9
9
  description: "MCP server for managing Featureflip feature flags from AI agents and editors",
10
10
  keywords: [
@@ -280,7 +280,7 @@ var D = n.string().describe("Project key"), O = n.string().describe("Flag key or
280
280
  };
281
281
  //#endregion
282
282
  //#region src/tools/projects.ts
283
- function j(e, t) {
283
+ function ee(e, t) {
284
284
  e.registerTool("list_projects", {
285
285
  title: "List projects",
286
286
  description: "List projects in the Featureflip organization. Paginated: pass cursor from next_cursor to continue.",
@@ -372,7 +372,7 @@ function j(e, t) {
372
372
  }
373
373
  //#endregion
374
374
  //#region src/tools/environments.ts
375
- function ee(e, t) {
375
+ function j(e, t) {
376
376
  e.registerTool("list_environments", {
377
377
  title: "List environments",
378
378
  description: "List the environments of a project (e.g. development, staging, production).",
@@ -432,7 +432,7 @@ function ee(e, t) {
432
432
  //#endregion
433
433
  //#region src/tools/sdk-keys.ts
434
434
  var M = "This is the only time the full key is returned; it cannot be shown again. Store it in a secret or an untracked .env file, never in source control or a chat log.";
435
- function te(e, t) {
435
+ function N(e, t) {
436
436
  let r = (e, n) => `/api/v1/orgs/${o(t.org)}/projects/${o(e)}/environments/${o(n)}/sdk-keys`;
437
437
  e.registerTool("list_sdk_keys", {
438
438
  title: "List SDK keys",
@@ -506,14 +506,17 @@ function te(e, t) {
506
506
  }
507
507
  //#endregion
508
508
  //#region src/tools/etag.ts
509
- var N = {
509
+ var P = {
510
510
  type: "string",
511
511
  description: "ETag of what was read. Pass it as ifMatch on the matching update so the write is refused (412) instead of overwriting a change made since."
512
+ }, F = {
513
+ type: "string",
514
+ description: "ETag of what this write left behind. Pass it as ifMatch on the next update to chain writes without re-reading. Absent when the API sent none; read the resource again before the next conditional write."
512
515
  };
513
- function P(e) {
516
+ function I(e) {
514
517
  return n.string().optional().describe(`etag from ${e}. The write is refused with 412 if the resource changed since that read; re-read and re-apply. Omit to write unconditionally.`);
515
518
  }
516
- function F({ data: e, etag: t }) {
519
+ function L({ data: e, etag: t }) {
517
520
  return t ? {
518
521
  ...e,
519
522
  etag: t
@@ -521,7 +524,7 @@ function F({ data: e, etag: t }) {
521
524
  }
522
525
  //#endregion
523
526
  //#region src/tools/segments.ts
524
- function ne(e, t) {
527
+ function te(e, t) {
525
528
  e.registerTool("list_segments", {
526
529
  title: "List user segments",
527
530
  description: "List reusable user segments in a project. Segments are referenced from targeting rules via userSegmentId.",
@@ -541,9 +544,9 @@ function ne(e, t) {
541
544
  project: n.string().describe("Project key"),
542
545
  segment: n.string().describe("Segment key or id")
543
546
  }),
544
- outputSchema: C("GET /api/v1/orgs/{org}/projects/{project}/segments/{segment}", { etag: N }),
547
+ outputSchema: C("GET /api/v1/orgs/{org}/projects/{project}/segments/{segment}", { etag: P }),
545
548
  annotations: { readOnlyHint: !0 }
546
- }, async ({ project: e, segment: n }) => p(async () => d(F(await t.api.requestWithEtag("GET", `/api/v1/orgs/${o(t.org)}/projects/${o(e)}/segments/${o(n)}`)))));
549
+ }, async ({ project: e, segment: n }) => p(async () => d(L(await t.api.requestWithEtag("GET", `/api/v1/orgs/${o(t.org)}/projects/${o(e)}/segments/${o(n)}`)))));
547
550
  let r = n.object({
548
551
  attribute: n.string().describe("Context attribute name, e.g. plan, country, user_id"),
549
552
  operator: n.string().describe("Case-sensitive: Equals, NotEquals, Contains, NotContains, GreaterThan, LessThan, GreaterThanOrEqual, LessThanOrEqual, In, NotIn, MatchesRegex, StartsWith, EndsWith, Before, After, SemverEquals, SemverGreaterThan, SemverGreaterThanOrEqual, SemverLessThan, SemverLessThanOrEqual"),
@@ -570,7 +573,7 @@ function ne(e, t) {
570
573
  name: n.string().optional().describe("Display name; required for create"),
571
574
  description: n.string().optional().describe("What the segment means; \"\" clears it"),
572
575
  conditions: n.array(r).optional().describe("Conditions a user must match to be in the segment; on update, replaces the whole list"),
573
- ifMatch: P("get_segment")
576
+ ifMatch: I("get_segment")
574
577
  }),
575
578
  outputSchema: T(y("POST /api/v1/orgs/{org}/projects/{project}/segments"), E({
576
579
  segment: { type: "string" },
@@ -580,7 +583,8 @@ function ne(e, t) {
580
583
  conditions: {
581
584
  type: ["array", "null"],
582
585
  items: { type: "object" }
583
- }
586
+ },
587
+ etag: F
584
588
  }, ["segment", "updated"]), E({ deleted: { type: "string" } }, ["deleted"])),
585
589
  annotations: { destructiveHint: !0 }
586
590
  }, async ({ action: e, project: n, segment: r, key: a, name: s, description: c, conditions: l, ifMatch: u }) => p(async () => {
@@ -599,23 +603,26 @@ function ne(e, t) {
599
603
  name: s ?? e.name,
600
604
  description: c ?? e.description,
601
605
  conditions: l ?? (e.conditions ?? []).map(i)
602
- };
603
- return await t.api.request("PUT", m, {
606
+ }, { etag: o } = await t.api.requestWithEtag("PUT", m, {
604
607
  body: a,
605
608
  ifMatch: u ?? n
606
- }), d({
607
- segment: r,
608
- updated: !0,
609
- ...a
610
609
  });
610
+ return d(L({
611
+ data: {
612
+ segment: r,
613
+ updated: !0,
614
+ ...a
615
+ },
616
+ etag: o
617
+ }));
611
618
  }
612
619
  return await t.api.request("DELETE", m), d({ deleted: r });
613
620
  }));
614
621
  }
615
622
  //#endregion
616
623
  //#region src/tools/owner.ts
617
- var I = n.string().optional().describe("Only flags with this owner: an email, \"me\" for the token's own user, or \"none\" for unowned flags");
618
- async function L(e, t) {
624
+ var R = n.string().optional().describe("Only flags with this owner: an email, \"me\" for the token's own user, or \"none\" for unowned flags");
625
+ async function z(e, t) {
619
626
  let n = t?.trim();
620
627
  if (!n) return;
621
628
  if (n.toLowerCase() !== "me") return n;
@@ -625,13 +632,13 @@ async function L(e, t) {
625
632
  }
626
633
  //#endregion
627
634
  //#region src/tools/flags.ts
628
- var R = n.enum([
635
+ var B = n.enum([
629
636
  "Boolean",
630
637
  "String",
631
638
  "Number",
632
639
  "Json"
633
640
  ]);
634
- function z(e, t) {
641
+ function ne(e, t) {
635
642
  let r = (e) => `/api/v1/orgs/${o(t.org)}/projects/${o(e)}/flags`;
636
643
  e.registerTool("list_flags", {
637
644
  title: "List feature flags",
@@ -640,16 +647,16 @@ function z(e, t) {
640
647
  project: D,
641
648
  search: n.string().optional().describe("Substring of the flag key or name"),
642
649
  tag: n.string().optional().describe("Only flags carrying this tag"),
643
- type: R.optional().describe("Only flags of this type"),
650
+ type: B.optional().describe("Only flags of this type"),
644
651
  archived: n.boolean().optional().describe("true = only archived, false = only active"),
645
- owner: I,
652
+ owner: R,
646
653
  ...A
647
654
  }),
648
655
  outputSchema: S("GET /api/v1/orgs/{org}/projects/{project}/flags"),
649
656
  annotations: { readOnlyHint: !0 }
650
657
  }, async ({ project: e, owner: n, ...i }) => p(async () => d(await t.api.request("GET", r(e), { query: {
651
658
  ...i,
652
- owner: await L(t, n)
659
+ owner: await z(t, n)
653
660
  } })))), e.registerTool("get_flag", {
654
661
  title: "Get feature flag",
655
662
  description: "Get one feature flag with its variations and metadata, including its owner (null when unowned). Address by flag key or id.",
@@ -657,16 +664,16 @@ function z(e, t) {
657
664
  project: D,
658
665
  flag: O
659
666
  }),
660
- outputSchema: C("GET /api/v1/orgs/{org}/projects/{project}/flags/{flag}", { etag: N }),
667
+ outputSchema: C("GET /api/v1/orgs/{org}/projects/{project}/flags/{flag}", { etag: P }),
661
668
  annotations: { readOnlyHint: !0 }
662
- }, async ({ project: e, flag: n }) => p(async () => d(F(await t.api.requestWithEtag("GET", `${r(e)}/${o(n)}`))))), e.registerTool("create_flag", {
669
+ }, async ({ project: e, flag: n }) => p(async () => d(L(await t.api.requestWithEtag("GET", `${r(e)}/${o(n)}`))))), e.registerTool("create_flag", {
663
670
  title: "Create feature flag",
664
671
  description: "Create a feature flag. type is one of Boolean|String|Number|Json. Boolean flags get true/false variations automatically; for other types pass initialVariations. The flag is created in every environment of the project (disabled).",
665
672
  inputSchema: n.object({
666
673
  project: D,
667
674
  key: n.string().describe("Unique flag key, e.g. checkout-v2"),
668
675
  name: n.string().describe("Display name"),
669
- type: R.describe("Value type; Boolean gets true/false variations automatically"),
676
+ type: B.describe("Value type; Boolean gets true/false variations automatically"),
670
677
  description: n.string().optional().describe("What the flag controls"),
671
678
  tags: n.array(n.string()).optional().describe("Tags for filtering, e.g. team or area"),
672
679
  clientSideVisible: n.boolean().optional().describe("Expose to client-side SDKs (browser/mobile)"),
@@ -696,12 +703,13 @@ function z(e, t) {
696
703
  description: n.string().optional().describe("New description; \"\" clears it"),
697
704
  tags: n.array(n.string()).optional().describe("Replaces the whole tag list"),
698
705
  clientSideVisible: n.boolean().optional().describe("Expose to client-side SDKs (browser/mobile); false hides the flag from them entirely"),
699
- ifMatch: P("get_flag")
706
+ ifMatch: I("get_flag")
700
707
  }),
701
708
  outputSchema: w({
702
709
  project: { type: "string" },
703
710
  flag: { type: "string" },
704
- updated: { type: "boolean" }
711
+ updated: { type: "boolean" },
712
+ etag: F
705
713
  }, [
706
714
  "project",
707
715
  "flag",
@@ -714,15 +722,18 @@ function z(e, t) {
714
722
  description: a ?? p?.description,
715
723
  tags: s,
716
724
  clientSideVisible: c
717
- };
718
- return await t.api.request("PUT", u, {
725
+ }, { etag: h } = await t.api.requestWithEtag("PUT", u, {
719
726
  body: m,
720
727
  ifMatch: l ?? f?.etag
721
- }), d({
722
- project: e,
723
- flag: n,
724
- updated: !0
725
728
  });
729
+ return d(L({
730
+ data: {
731
+ project: e,
732
+ flag: n,
733
+ updated: !0
734
+ },
735
+ etag: h
736
+ }));
726
737
  })), e.registerTool("set_flag_expiry", {
727
738
  title: "Set or clear flag expiry",
728
739
  description: "Set the date a flag is expected to be removed by, or pass expiresAtUtc: null to clear it. Expiry is advisory: evaluation never changes. Once the date passes, find_stale_flags reports the flag as expired. expiresAtUtc takes a date (2026-12-31), which means the end of that day in UTC, the same as picking it in the dashboard, or a full ISO-8601 timestamp, which is stored exactly. Refused with EXPIRY_IN_PAST for a time that has already passed (today's date is allowed), with FEATURE_NOT_ENABLED while flag expiration is not enabled for the organization, and with PERMANENT_FLAG_HAS_EXPIRY on a permanent flag (make it temporary first with set_flag_permanent). Clearing is always allowed.",
@@ -804,7 +815,7 @@ function z(e, t) {
804
815
  idempotentHint: !0
805
816
  }
806
817
  }, async ({ project: e, flag: n, owner: i }) => p(async () => {
807
- let a = `${r(e)}/${o(n)}/owner`, s = i?.trim().toLowerCase() === "none" ? void 0 : await L(t, i ?? void 0);
818
+ let a = `${r(e)}/${o(n)}/owner`, s = i?.trim().toLowerCase() === "none" ? void 0 : await z(t, i ?? void 0);
808
819
  return s === void 0 ? await t.api.request("DELETE", a) : await t.api.request("PUT", a, { body: { email: s } }), d({
809
820
  project: e,
810
821
  flag: n,
@@ -854,12 +865,12 @@ function z(e, t) {
854
865
  }
855
866
  //#endregion
856
867
  //#region src/tools/flag-environments.ts
857
- var B = n.enum([
868
+ var re = n.enum([
858
869
  "SingleVariation",
859
870
  "PercentageRollout",
860
871
  "TargetedRollout"
861
872
  ]);
862
- function V(e, t) {
873
+ function ie(e, t) {
863
874
  let r = (e, n) => `/api/v1/orgs/${o(t.org)}/projects/${o(e)}/flags/${o(n)}`;
864
875
  e.registerTool("toggle_flag", {
865
876
  title: "Toggle flag in environment",
@@ -895,7 +906,7 @@ function V(e, t) {
895
906
  flag: O,
896
907
  environment: k,
897
908
  defaultVariationId: n.string().describe("Variation id to serve on fallthrough — required by the API"),
898
- strategy: B.optional().describe("Serving strategy; only SingleVariation is currently supported here"),
909
+ strategy: re.optional().describe("Serving strategy; only SingleVariation is currently supported here"),
899
910
  prerequisites: n.array(n.object({
900
911
  prerequisiteFlagKey: n.string(),
901
912
  expectedVariationKey: n.string()
@@ -981,25 +992,25 @@ function V(e, t) {
981
992
  }
982
993
  //#endregion
983
994
  //#region src/tools/targeting.ts
984
- var H = n.object({
995
+ var ae = n.object({
985
996
  attribute: n.string().describe("Context attribute name, e.g. plan, country, user_id"),
986
997
  operator: n.string().describe("OperatorType member name, case-sensitive — e.g. Equals, NotEquals, Contains, In, GreaterThan"),
987
998
  values: n.array(n.string()),
988
999
  negate: n.boolean().optional().default(!1)
989
- }), U = n.object({
1000
+ }), V = n.object({
990
1001
  description: n.string().optional(),
991
1002
  variationId: n.string().optional().describe("Variation served when the rule matches"),
992
1003
  rolloutPercentage: n.number().int().min(0).max(100).optional().describe("Percentage rollout for this rule"),
993
1004
  userSegmentId: n.string().optional().describe("Match users in this segment (see list_segments)"),
994
1005
  conditionGroups: n.array(n.object({
995
1006
  operator: n.enum(["And", "Or"]).describe("How conditions inside this group combine"),
996
- conditions: n.array(H)
1007
+ conditions: n.array(ae)
997
1008
  })).optional().describe("Groups are ANDed together; conditions inside a group use the group operator")
998
- }), W = (e) => ({
1009
+ }), H = (e) => ({
999
1010
  ...e,
1000
1011
  conditionGroups: e.conditionGroups ?? []
1001
1012
  });
1002
- function G(e, t) {
1013
+ function U(e, t) {
1003
1014
  let r = (e, n, r) => `/api/v1/orgs/${o(t.org)}/projects/${o(e)}/flags/${o(n)}/environments/${o(r)}/targeting`;
1004
1015
  e.registerTool("get_targeting", {
1005
1016
  title: "Get targeting rules",
@@ -1009,23 +1020,24 @@ function G(e, t) {
1009
1020
  flag: O,
1010
1021
  environment: k
1011
1022
  }),
1012
- outputSchema: C("GET /api/v1/orgs/{org}/projects/{project}/flags/{flag}/environments/{env}/targeting", { etag: N }),
1023
+ outputSchema: C("GET /api/v1/orgs/{org}/projects/{project}/flags/{flag}/environments/{env}/targeting", { etag: P }),
1013
1024
  annotations: { readOnlyHint: !0 }
1014
- }, async ({ project: e, flag: n, environment: i }) => p(async () => d(F(await t.api.requestWithEtag("GET", r(e, n, i)))))), e.registerTool("update_targeting", {
1025
+ }, async ({ project: e, flag: n, environment: i }) => p(async () => d(L(await t.api.requestWithEtag("GET", r(e, n, i)))))), e.registerTool("update_targeting", {
1015
1026
  title: "Replace targeting rules",
1016
1027
  description: "REPLACE all targeting rules of a flag in one environment (full PUT — rules not included are removed). Rules are evaluated in order. Get the current rules first with get_targeting. Pass ifMatch (the etag from get_targeting) so rules someone else changed meanwhile are not overwritten.",
1017
1028
  inputSchema: n.object({
1018
1029
  project: D,
1019
1030
  flag: O,
1020
1031
  environment: k,
1021
- rules: n.array(U).describe("The complete ordered rule list; rules left out are deleted"),
1022
- ifMatch: P("get_targeting")
1032
+ rules: n.array(V).describe("The complete ordered rule list; rules left out are deleted"),
1033
+ ifMatch: I("get_targeting")
1023
1034
  }),
1024
1035
  outputSchema: w({
1025
1036
  project: { type: "string" },
1026
1037
  flag: { type: "string" },
1027
1038
  environment: { type: "string" },
1028
- rulesReplaced: { type: "integer" }
1039
+ rulesReplaced: { type: "integer" },
1040
+ etag: F
1029
1041
  }, [
1030
1042
  "project",
1031
1043
  "flag",
@@ -1033,15 +1045,21 @@ function G(e, t) {
1033
1045
  "rulesReplaced"
1034
1046
  ]),
1035
1047
  annotations: { destructiveHint: !0 }
1036
- }, async ({ project: e, flag: n, environment: i, rules: a, ifMatch: o }) => p(async () => (await t.api.request("PUT", r(e, n, i), {
1037
- body: { rules: a.map(W) },
1038
- ifMatch: o
1039
- }), d({
1040
- project: e,
1041
- flag: n,
1042
- environment: i,
1043
- rulesReplaced: a.length
1044
- })))), e.registerTool("manage_targeting_rule", {
1048
+ }, async ({ project: e, flag: n, environment: i, rules: a, ifMatch: o }) => p(async () => {
1049
+ let { etag: s } = await t.api.requestWithEtag("PUT", r(e, n, i), {
1050
+ body: { rules: a.map(H) },
1051
+ ifMatch: o
1052
+ });
1053
+ return d(L({
1054
+ data: {
1055
+ project: e,
1056
+ flag: n,
1057
+ environment: i,
1058
+ rulesReplaced: a.length
1059
+ },
1060
+ etag: s
1061
+ }));
1062
+ })), e.registerTool("manage_targeting_rule", {
1045
1063
  title: "Add, update, remove, or reorder one targeting rule",
1046
1064
  description: "Edit a single targeting rule instead of replacing them all with update_targeting. action=add needs rule (appended last); action=update needs ruleId + rule and changes only the fields you pass (conditionGroups replaces the rule's groups; to clear rolloutPercentage or userSegmentId use update_targeting); action=remove needs ruleId; action=reorder needs ruleIds, every existing rule id exactly once, in the new order. Rule ids come from get_targeting.",
1047
1065
  inputSchema: n.object({
@@ -1055,7 +1073,7 @@ function G(e, t) {
1055
1073
  flag: O,
1056
1074
  environment: k,
1057
1075
  ruleId: n.string().optional().describe("Rule id from get_targeting; required for update and remove"),
1058
- rule: U.optional().describe("Rule fields; required for add and update"),
1076
+ rule: V.optional().describe("Rule fields; required for add and update"),
1059
1077
  ruleIds: n.array(n.string()).optional().describe("Every rule id exactly once, in evaluation order; required for reorder")
1060
1078
  }),
1061
1079
  outputSchema: T(y("POST /api/v1/orgs/{org}/projects/{project}/flags/{flag}/environments/{env}/rules"), E({
@@ -1068,7 +1086,7 @@ function G(e, t) {
1068
1086
  annotations: { destructiveHint: !0 }
1069
1087
  }, async ({ action: e, project: n, flag: r, environment: i, ruleId: a, rule: s, ruleIds: c }) => p(async () => {
1070
1088
  let l = `/api/v1/orgs/${o(t.org)}/projects/${o(n)}/flags/${o(r)}/environments/${o(i)}/rules`;
1071
- if (e === "add") return s ? d(await t.api.request("POST", l, { body: W(s) })) : f(/* @__PURE__ */ Error("action=add requires rule"));
1089
+ if (e === "add") return s ? d(await t.api.request("POST", l, { body: H(s) })) : f(/* @__PURE__ */ Error("action=add requires rule"));
1072
1090
  if (e === "reorder") return c ? (await t.api.request("PUT", `${l}/reorder`, { body: { ruleIds: c } }), d({ reordered: c })) : f(/* @__PURE__ */ Error("action=reorder requires ruleIds (see get_targeting)"));
1073
1091
  if (!a) return f(/* @__PURE__ */ Error(`action=${e} requires ruleId (see get_targeting)`));
1074
1092
  let u = `${l}/${o(a)}`;
@@ -1081,7 +1099,7 @@ function G(e, t) {
1081
1099
  userSegmentId: s.userSegmentId ?? e.userSegmentId,
1082
1100
  conditionGroups: s.conditionGroups ?? (e.conditionGroups ?? []).map((e) => ({
1083
1101
  operator: e.operator,
1084
- conditions: e.conditions.map((e) => ({
1102
+ conditions: (e.conditions ?? []).map((e) => ({
1085
1103
  attribute: e.attribute,
1086
1104
  operator: e.operator,
1087
1105
  values: e.values,
@@ -1102,7 +1120,7 @@ function G(e, t) {
1102
1120
  }
1103
1121
  //#endregion
1104
1122
  //#region src/tools/variations.ts
1105
- function K(e, t) {
1123
+ function W(e, t) {
1106
1124
  e.registerTool("manage_variation", {
1107
1125
  title: "Add, update, or remove a variation",
1108
1126
  description: "Manage a flag's variations. action=add requires key + value; action=update/remove require variationId (get ids via get_flag). Removing a variation fails with VARIATION_HAS_DEPENDENTS if other flags depend on it.",
@@ -1144,13 +1162,13 @@ function K(e, t) {
1144
1162
  }
1145
1163
  //#endregion
1146
1164
  //#region src/tools/webhooks.ts
1147
- var q = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i, J = "Requires an Admin token. A 404 on every webhook call means webhooks are not enabled for the organization.";
1148
- function re(e, t) {
1165
+ var G = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i, K = "Requires an Admin token. A 404 on every webhook call means webhooks are not enabled for the organization.";
1166
+ function q(e, t) {
1149
1167
  let r = `/api/v1/orgs/${o(t.org)}/webhooks`, i = (e) => `${r}/${o(e)}`;
1150
1168
  async function a(e) {
1151
1169
  let n = [];
1152
1170
  for (let r of e) {
1153
- if (q.test(r)) {
1171
+ if (G.test(r)) {
1154
1172
  n.push(r);
1155
1173
  continue;
1156
1174
  }
@@ -1162,7 +1180,7 @@ function re(e, t) {
1162
1180
  }
1163
1181
  async function s(e) {
1164
1182
  let n = e.map((e) => {
1165
- if (q.test(e)) return { id: e };
1183
+ if (G.test(e)) return { id: e };
1166
1184
  let t = e.indexOf("/"), n = e.slice(0, t), r = e.slice(t + 1);
1167
1185
  if (t < 0 || !n || !r) throw Error(`Environment "${e}" needs its project: pass "<project>/<environment>", e.g. "web/production", or the environment's id.`);
1168
1186
  return {
@@ -1183,7 +1201,7 @@ function re(e, t) {
1183
1201
  }
1184
1202
  e.registerTool("list_webhooks", {
1185
1203
  title: "List webhook subscriptions",
1186
- description: "List the organization's outbound webhook subscriptions (url, event/project/environment filters, enabled state, failure count, signing secret ids — never secret values), plus availableEventTypes: the event types a subscription can filter on. Empty filter lists mean \"all\". Paginated via cursor. " + J,
1204
+ description: "List the organization's outbound webhook subscriptions (url, event/project/environment filters, enabled state, failure count, signing secret ids — never secret values), plus availableEventTypes: the event types a subscription can filter on. Empty filter lists mean \"all\". Paginated via cursor. " + K,
1187
1205
  inputSchema: n.object({ ...A }),
1188
1206
  outputSchema: C("GET /api/v1/orgs/{org}/webhooks", { availableEventTypes: {
1189
1207
  type: "array",
@@ -1202,7 +1220,7 @@ function re(e, t) {
1202
1220
  });
1203
1221
  })), e.registerTool("list_webhook_deliveries", {
1204
1222
  title: "List webhook deliveries",
1205
- description: "List one subscription's delivery attempts, most recent first. status is Pending (awaiting an attempt, backing off, or in flight), Succeeded or DeadLettered; lastResponseStatusCode and lastError explain a failure. Paginated via cursor. " + J,
1223
+ description: "List one subscription's delivery attempts, most recent first. status is Pending (awaiting an attempt, backing off, or in flight), Succeeded or DeadLettered; lastResponseStatusCode and lastError explain a failure. Paginated via cursor. " + K,
1206
1224
  inputSchema: n.object({
1207
1225
  id: n.string().describe("Subscription id (from list_webhooks)"),
1208
1226
  ...A
@@ -1214,7 +1232,7 @@ function re(e, t) {
1214
1232
  cursor: r
1215
1233
  } })))), e.registerTool("manage_webhook", {
1216
1234
  title: "Create, update, or delete a webhook subscription, or rotate its secret",
1217
- description: "action=create requires name + url and returns the signing secret. action=update/delete/rotate_secret/retire_secret require id. update changes only the fields you pass and keeps the rest; pass an empty list to widen that filter back to \"all\". projects take project keys or ids; environments take \"<project>/<environment>\" keys (e.g. \"web/production\") or ids. eventTypes come from list_webhooks → availableEventTypes. create and rotate_secret return a secret that is NEVER shown again: relay it to the user verbatim so they can store it. rotate_secret adds a new active secret while the old one keeps signing; retire_secret (secretId from list_webhooks) removes one and is refused for the last active secret. A project-restricted service token must list at least one project, all in its scope. " + J,
1235
+ description: "action=create requires name + url and returns the signing secret. action=update/delete/rotate_secret/retire_secret require id. update changes only the fields you pass and keeps the rest; pass an empty list to widen that filter back to \"all\". projects take project keys or ids; environments take \"<project>/<environment>\" keys (e.g. \"web/production\") or ids. eventTypes come from list_webhooks → availableEventTypes. create and rotate_secret return a secret that is NEVER shown again: relay it to the user verbatim so they can store it. rotate_secret adds a new active secret while the old one keeps signing; retire_secret (secretId from list_webhooks) removes one and is refused for the last active secret. A project-restricted service token must list at least one project, all in its scope. " + K,
1218
1236
  inputSchema: n.object({
1219
1237
  action: n.enum([
1220
1238
  "create",
@@ -1297,7 +1315,7 @@ function re(e, t) {
1297
1315
  })) : f(/* @__PURE__ */ Error("action=retire_secret requires secretId (see list_webhooks)"));
1298
1316
  })), e.registerTool("deliver_webhook", {
1299
1317
  title: "Send a test event or redeliver",
1300
- description: "action=test queues one synthetic flag.toggled event to this subscription alone; action=redeliver (deliveryId from list_webhook_deliveries) re-sends a finished delivery, restarting its retry schedule. Delivery is asynchronous: read list_webhook_deliveries for the outcome. Both are refused for a disabled subscription, and redeliver for a delivery that is still Pending. " + J,
1318
+ description: "action=test queues one synthetic flag.toggled event to this subscription alone; action=redeliver (deliveryId from list_webhook_deliveries) re-sends a finished delivery, restarting its retry schedule. Delivery is asynchronous: read list_webhook_deliveries for the outcome. Both are refused for a disabled subscription, and redeliver for a delivery that is still Pending. " + K,
1301
1319
  inputSchema: n.object({
1302
1320
  action: n.enum(["test", "redeliver"]).describe("test sends a synthetic event; redeliver re-sends deliveryId"),
1303
1321
  id: n.string().describe("Subscription id (from list_webhooks)"),
@@ -1318,15 +1336,15 @@ function re(e, t) {
1318
1336
  }
1319
1337
  //#endregion
1320
1338
  //#region src/tools/workflows/stale-flags.ts
1321
- var ie = n.enum(["dead", "stale"]), Y = 50;
1322
- function ae(e, t) {
1339
+ var oe = n.enum(["dead", "stale"]), J = 50;
1340
+ function se(e, t) {
1323
1341
  e.registerTool("find_stale_flags", {
1324
1342
  title: "Find stale flags",
1325
- description: `Find flags that look ready for code cleanup: not updated in N days AND either enabled in every environment (verify rollout is complete before removing — per-rule percentage ramps are not inspected) or disabled in every environment (dead — remove flag and code path). A flag whose expiry date (set_flag_expiry) has passed is always a candidate, however recently it was edited; if it is on in some environments and off in others its reason is past-expiry, meaning the owner has to decide which way to fold it. A project can give its temporary flags a default lifetime, so a flag with no date of its own can still be past expiry. Every result carries expiresAtUtc (the date set on the flag), effectiveExpiresAtUtc (the date in effect, from the flag or its project default), expirySource (explicit, project-default, or null), expired and owner (null when unowned). Flags marked permanent (kill switches, ops toggles) are never listed. Pass owner to see one person's stale flags ("me" for your own) or "none" for the unowned ones. Every result also carries blockedBy: the live flags that still list it as a prerequisite, which have to be removed and archived before it ([] when none). blockedBy is null when the server did not classify the flag as a removal candidate, which means unknown, not unblocked. A flag that other live flags list as a prerequisite has to be removed LAST, dependents first: archiving it while a dependent still names it makes that dependent fail its prerequisite check and serve its off variation, so archive_flag refuses it with FLAG_HAS_DEPENDENTS. Checks at most ${Y} candidates per call, expired flags first.`,
1343
+ description: `Find flags that look ready for code cleanup: not updated in N days AND either enabled in every environment (verify rollout is complete before removing — per-rule percentage ramps are not inspected) or disabled in every environment (dead — remove flag and code path). A flag whose expiry date (set_flag_expiry) has passed is always a candidate, however recently it was edited; if it is on in some environments and off in others its reason is past-expiry, meaning the owner has to decide which way to fold it. A project can give its temporary flags a default lifetime, so a flag with no date of its own can still be past expiry. Every result carries expiresAtUtc (the date set on the flag), effectiveExpiresAtUtc (the date in effect, from the flag or its project default), expirySource (explicit, project-default, or null), expired and owner (null when unowned). Flags marked permanent (kill switches, ops toggles) are never listed. Pass owner to see one person's stale flags ("me" for your own) or "none" for the unowned ones. Every result also carries blockedBy: the live flags that still list it as a prerequisite, which have to be removed and archived before it ([] when none). blockedBy is null when the server did not classify the flag as a removal candidate, which means unknown, not unblocked. A flag that other live flags list as a prerequisite has to be removed LAST, dependents first: archiving it while a dependent still names it makes that dependent fail its prerequisite check and serve its off variation, so archive_flag refuses it with FLAG_HAS_DEPENDENTS. Checks at most ${J} candidates per call, expired flags first.`,
1326
1344
  inputSchema: n.object({
1327
1345
  project: D,
1328
1346
  days: n.number().int().min(1).optional().default(30).describe("Minimum age in days since last update"),
1329
- owner: I
1347
+ owner: R
1330
1348
  }),
1331
1349
  outputSchema: w({
1332
1350
  project: { type: "string" },
@@ -1371,7 +1389,7 @@ function ae(e, t) {
1371
1389
  ]),
1372
1390
  annotations: { readOnlyHint: !0 }
1373
1391
  }, async ({ project: e, days: n, owner: r }) => p(async () => {
1374
- let a = await L(t, r), s = `/api/v1/orgs/${o(t.org)}/projects/${o(e)}/flags`, c = Date.now(), l = c - n * 24 * 60 * 60 * 1e3, u = (e) => e.effectiveExpiresAtUtc ?? e.expiresAtUtc ?? null, f = (e) => e.expirySource ?? (e.expiresAtUtc ? "explicit" : null), p = (e) => {
1392
+ let a = await z(t, r), s = `/api/v1/orgs/${o(t.org)}/projects/${o(e)}/flags`, c = Date.now(), l = c - n * 24 * 60 * 60 * 1e3, u = (e) => e.effectiveExpiresAtUtc ?? e.expiresAtUtc ?? null, f = (e) => e.expirySource ?? (e.expiresAtUtc ? "explicit" : null), p = (e) => {
1375
1393
  let t = u(e);
1376
1394
  return !!t && new Date(t).getTime() <= c;
1377
1395
  }, m = [], h;
@@ -1386,7 +1404,7 @@ function ae(e, t) {
1386
1404
  m.push(...(e.items ?? []).filter((e) => !!e.key && !!e.name && !!e.updatedAt && (new Date(e.updatedAt).getTime() < l || p(e)))), h = e.next_cursor ?? void 0;
1387
1405
  } while (h);
1388
1406
  m.sort((e, t) => Number(p(t)) - Number(p(e)));
1389
- let g = m.length > Y, _ = m.slice(0, Y), v = [];
1407
+ let g = m.length > J, _ = m.slice(0, J), v = [];
1390
1408
  for (let e of _) {
1391
1409
  let n = await t.api.request("GET", `${s}/${o(e.key)}/environments`);
1392
1410
  if (n.length === 0) continue;
@@ -1428,7 +1446,7 @@ function ae(e, t) {
1428
1446
  ...a ? { owner: a } : {},
1429
1447
  checked: _.length,
1430
1448
  truncated: g,
1431
- ...g ? { note: `Only the first ${Y} of ${m.length} candidates were checked.` } : {},
1449
+ ...g ? { note: `Only the first ${J} of ${m.length} candidates were checked.` } : {},
1432
1450
  ...y ? { blockedByNote: y } : {},
1433
1451
  stale: v
1434
1452
  });
@@ -1437,7 +1455,7 @@ function ae(e, t) {
1437
1455
  description: "List the flags the server is confident can be removed from code, the same list the Featureflip flag cleanup GitHub Action works from. Each item has key, reason, status (Dead or Stale), treatment (true = keep the on-branch, false = keep the off-branch) and blockedBy: the live flags that still list it as a prerequisite. Only remove a flag whose blockedBy is empty. A flag that other live flags list as a prerequisite has to be removed LAST, dependents first: archiving it while a dependent still names it makes that dependent fail its prerequisite check and serve its off variation, so archive_flag refuses it with FLAG_HAS_DEPENDENTS. staleness \"dead\" (the default) returns only dead flags, \"stale\" adds stale ones. Paginated via cursor.",
1438
1456
  inputSchema: n.object({
1439
1457
  project: D,
1440
- staleness: ie.optional().describe("Minimum staleness tier: dead (default) or stale"),
1458
+ staleness: oe.optional().describe("Minimum staleness tier: dead (default) or stale"),
1441
1459
  ...A
1442
1460
  }),
1443
1461
  outputSchema: S("GET /api/v1/orgs/{org}/projects/{project}/flags/removal-candidates"),
@@ -1446,7 +1464,7 @@ function ae(e, t) {
1446
1464
  }
1447
1465
  //#endregion
1448
1466
  //#region src/tools/workflows/snippets.ts
1449
- var oe = [
1467
+ var ce = [
1450
1468
  "js",
1451
1469
  "node",
1452
1470
  "browser",
@@ -1458,16 +1476,16 @@ var oe = [
1458
1476
  "php",
1459
1477
  "ruby",
1460
1478
  "swift"
1461
- ], se = [
1479
+ ], le = [
1462
1480
  "browser",
1463
1481
  "react",
1464
1482
  "swift"
1465
1483
  ];
1466
- function ce(e) {
1467
- return se.includes(e);
1484
+ function ue(e) {
1485
+ return le.includes(e);
1468
1486
  }
1469
- var X = "Uses a SERVER-side SDK key (Featureflip dashboard → environment → SDK keys).", Z = "Uses a CLIENT-side SDK key (safe to ship to browsers/apps).";
1470
- function le(e, t) {
1487
+ var Y = "Uses a SERVER-side SDK key (Featureflip dashboard → environment → SDK keys).", X = "Uses a CLIENT-side SDK key (safe to ship to browsers/apps).";
1488
+ function de(e, t) {
1471
1489
  switch (e) {
1472
1490
  case "js": return {
1473
1491
  install: "npm install @featureflip/js",
@@ -1482,7 +1500,7 @@ const enabled = client.boolVariation('${t}', { user_id: userId }, false);
1482
1500
  if (enabled) {
1483
1501
  // new code path
1484
1502
  }`,
1485
- notes: X
1503
+ notes: Y
1486
1504
  };
1487
1505
  case "node": return {
1488
1506
  install: "npm install @featureflip/node",
@@ -1493,7 +1511,7 @@ const enabled = client.boolVariation('${t}', { user_id: userId }, false);
1493
1511
  if (enabled) {
1494
1512
  // new code path
1495
1513
  }`,
1496
- notes: X
1514
+ notes: Y
1497
1515
  };
1498
1516
  case "browser": return {
1499
1517
  install: "npm install @featureflip/browser",
@@ -1505,7 +1523,7 @@ const enabled = client.boolVariation('${t}', false);
1505
1523
  if (enabled) {
1506
1524
  // new code path
1507
1525
  }`,
1508
- notes: Z
1526
+ notes: X
1509
1527
  };
1510
1528
  case "react": return {
1511
1529
  install: "npm install @featureflip/react @featureflip/browser",
@@ -1518,7 +1536,7 @@ function MyComponent() {
1518
1536
  const enabled = useFeatureFlag('${t}', false);
1519
1537
  return enabled ? <NewExperience /> : <CurrentExperience />;
1520
1538
  }`,
1521
- notes: Z
1539
+ notes: X
1522
1540
  };
1523
1541
  case "python": return {
1524
1542
  install: "pip install featureflip",
@@ -1529,7 +1547,7 @@ enabled = client.variation("${t}", {"user_id": user_id}, default=False)
1529
1547
  if enabled:
1530
1548
  # new code path
1531
1549
  ...`,
1532
- notes: X
1550
+ notes: Y
1533
1551
  };
1534
1552
  case "csharp": return {
1535
1553
  install: "dotnet add package Featureflip.Client",
@@ -1542,7 +1560,7 @@ if (enabled)
1542
1560
  {
1543
1561
  // new code path
1544
1562
  }`,
1545
- notes: X
1563
+ notes: Y
1546
1564
  };
1547
1565
  case "java": return {
1548
1566
  install: "implementation 'io.featureflip:featureflip-java:2.0.0'",
@@ -1556,7 +1574,7 @@ boolean enabled = client.boolVariation("${t}",
1556
1574
  if (enabled) {
1557
1575
  // new code path
1558
1576
  }`,
1559
- notes: X
1577
+ notes: Y
1560
1578
  };
1561
1579
  case "go": return {
1562
1580
  install: "go get github.com/canopy-labs/featureflip-go/v2",
@@ -1572,7 +1590,7 @@ ctx := featureflip.EvaluationContext{UserID: userID}
1572
1590
  if client.BoolVariation("${t}", ctx, false) {
1573
1591
  // new code path
1574
1592
  }`,
1575
- notes: X
1593
+ notes: Y
1576
1594
  };
1577
1595
  case "php": return {
1578
1596
  install: "composer require featureflip/featureflip-php",
@@ -1587,7 +1605,7 @@ $enabled = $client->boolVariation('${t}', ['user_id' => $userId], false);
1587
1605
  if ($enabled) {
1588
1606
  // new code path
1589
1607
  }`,
1590
- notes: X + " Requires PSR-16 cache and PSR-18 HTTP implementations."
1608
+ notes: Y + " Requires PSR-16 cache and PSR-18 HTTP implementations."
1591
1609
  };
1592
1610
  case "ruby": return {
1593
1611
  install: "gem \"featureflip\"",
@@ -1598,7 +1616,7 @@ enabled = client.bool_variation("${t}", { "user_id" => user_id }, false)
1598
1616
  if enabled
1599
1617
  # new code path
1600
1618
  end`,
1601
- notes: X
1619
+ notes: Y
1602
1620
  };
1603
1621
  case "swift": return {
1604
1622
  install: ".package(url: \"https://github.com/canopy-labs/featureflip-swift\", from: \"2.0.0\")",
@@ -1611,13 +1629,13 @@ let enabled = client.boolVariation("${t}", default: false)
1611
1629
  if enabled {
1612
1630
  // new code path
1613
1631
  }`,
1614
- notes: Z
1632
+ notes: X
1615
1633
  };
1616
1634
  }
1617
1635
  }
1618
1636
  //#endregion
1619
1637
  //#region src/tools/workflows/wrap-feature.ts
1620
- function ue(e, t) {
1638
+ function Z(e, t) {
1621
1639
  e.registerTool("wrap_feature", {
1622
1640
  title: "Wrap a feature in a new flag",
1623
1641
  description: "Create a Boolean feature flag and get back the SDK code snippet to guard the new code path with it. Returns the snippet only — apply the edit yourself. The flag starts DISABLED in every environment; enable it with toggle_flag when ready.",
@@ -1627,7 +1645,7 @@ function ue(e, t) {
1627
1645
  name: n.string().optional().describe("Display name; defaults to the key"),
1628
1646
  description: n.string().optional().describe("What this flag guards"),
1629
1647
  tags: n.array(n.string()).optional().describe("Tags for filtering, e.g. team or area"),
1630
- language: n.enum(oe).describe("SDK language of the codebase being edited"),
1648
+ language: n.enum(ce).describe("SDK language of the codebase being edited"),
1631
1649
  idempotency_key: n.string().optional().describe("Idempotency-Key header for safe retries")
1632
1650
  }),
1633
1651
  outputSchema: w({
@@ -1656,10 +1674,10 @@ function ue(e, t) {
1656
1674
  type: "Boolean",
1657
1675
  description: i,
1658
1676
  tags: a,
1659
- ...ce(s) ? { clientSideVisible: !0 } : {}
1677
+ ...ue(s) ? { clientSideVisible: !0 } : {}
1660
1678
  },
1661
1679
  idempotencyKey: c
1662
- }), u = le(s, n);
1680
+ }), u = de(s, n);
1663
1681
  return d({
1664
1682
  flag: l,
1665
1683
  integration: {
@@ -1678,12 +1696,12 @@ function ue(e, t) {
1678
1696
  }
1679
1697
  //#endregion
1680
1698
  //#region src/server.ts
1681
- function de(t) {
1699
+ function fe(t) {
1682
1700
  let n = new e({
1683
1701
  name: "featureflip",
1684
1702
  version: r
1685
1703
  });
1686
- return j(n, t), ee(n, t), te(n, t), ne(n, t), z(n, t), V(n, t), G(n, t), K(n, t), re(n, t), ae(n, t), ue(n, t), n;
1704
+ return ee(n, t), j(n, t), N(n, t), te(n, t), ne(n, t), ie(n, t), U(n, t), W(n, t), q(n, t), se(n, t), Z(n, t), n;
1687
1705
  }
1688
1706
  //#endregion
1689
1707
  //#region src/config.ts
@@ -1696,14 +1714,14 @@ function $(e = process.env) {
1696
1714
  org: e.FEATUREFLIP_ORG?.trim() || void 0
1697
1715
  } : null;
1698
1716
  }
1699
- function fe(e = process.env) {
1717
+ function pe(e = process.env) {
1700
1718
  let t = $(e);
1701
1719
  if (!t) throw Error(Q);
1702
1720
  return t;
1703
1721
  }
1704
1722
  //#endregion
1705
1723
  //#region src/org.ts
1706
- async function pe(e, t) {
1724
+ async function me(e, t) {
1707
1725
  if (t) return t;
1708
1726
  let n = (await e.request("GET", "/api/v1/orgs", { query: { limit: 100 } })).items ?? [];
1709
1727
  if (n.length === 1) {
@@ -1714,4 +1732,4 @@ async function pe(e, t) {
1714
1732
  throw n.length === 0 ? Error("The token can see no organizations. Check the token in the Featureflip dashboard.") : Error(`The token can see ${n.length} organizations — set FEATUREFLIP_ORG to one of: ` + n.map((e) => e.slug ?? "?").join(", "));
1715
1733
  }
1716
1734
  //#endregion
1717
- export { de as a, r as c, $ as i, Q as n, i as o, fe as r, u as s, pe as t };
1735
+ export { fe as a, r as c, $ as i, Q as n, i as o, pe as r, u as s, me as t };