Skip to main content
Glama

Bucket Feature Flags MCP Server

Official
by reflagcom
flags.ts2.25 kB
import { z } from "zod"; import { authRequest } from "../utils/auth.js"; import { booleanish, EnvironmentQuerySchema } from "../utils/schemas.js"; import { PaginatedResponse } from "../utils/types.js"; export type Stage = { id: string; name: string; order: number; }; export type RemoteConfigVariant = { key?: string; payload?: any; }; export type RemoteConfig = { variants: [ { variant: RemoteConfigVariant; }, ]; }; export type FlagName = { id: string; name: string; key: string; }; export type Flag = FlagName & { description: string | null; remoteConfigs: RemoteConfig[]; stage: Stage | null; }; export type FlagsResponse = PaginatedResponse<Flag>; export const FlagsQuerySchema = EnvironmentQuerySchema.extend({ sortBy: z.string().default("key").describe("Field to sort features by"), sortOrder: z .enum(["asc", "desc"]) .default("asc") .describe("Sort direction (ascending or descending)"), includeRemoteConfigs: booleanish .default(false) .describe("Include remote configuration data"), }).strict(); export const FlagCreateSchema = z .object({ name: z .string() .min(1, "Flag name is required") .describe("Name of the flag"), key: z .string() .min(1, "Flag key is required") .describe("Unique identifier key for the flag"), description: z .string() .optional() .describe("Optional description of the flag"), }) .strict(); export type FlagsQuery = z.input<typeof FlagsQuerySchema>; export type FlagCreate = z.input<typeof FlagCreateSchema>; export async function listFlags(appId: string, query: FlagsQuery) { return authRequest<FlagsResponse>(`/apps/${appId}/features`, { params: FlagsQuerySchema.parse(query), }); } type CreateFlagResponse = { feature: FlagName & { description: string | null; }; }; export async function createFlag(appId: string, featureData: FlagCreate) { return authRequest<CreateFlagResponse>(`/apps/${appId}/features`, { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify({ source: "event", ...FlagCreateSchema.parse(featureData), }), }).then(({ feature }) => feature); }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/reflagcom/bucket-javascript-sdk'

If you have feedback or need assistance with the MCP directory API, please join our Discord server