listFeatureFlags
Retrieve and filter feature flags from Bucketeer by environment, tags, maintainer, or search terms to manage feature rollout and configuration.
Instructions
List all feature flags in the specified environment
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| archived | No | Filter by archived status | |
| cursor | No | Pagination cursor for next page | |
| environmentId | No | Environment ID (uses default if not provided) | |
| maintainer | No | Filter by maintainer email | |
| orderBy | No | Field to order by | |
| orderDirection | No | Order direction | |
| pageSize | No | Number of items per page (1-100) | |
| searchKeyword | No | Search keyword for feature name or ID | |
| tags | No | Filter by tags |
Implementation Reference
- src/tools/list-flags.ts:70-159 (handler)The handler function that parses input, calls the Bucketeer API to list feature flags, and returns a formatted JSON response or handles errors.handler: async (input: unknown) => { try { // Validate input const params = listFlagsSchema.parse(input); logger.debug("Listing feature flags", params); // Create API client const client = new BucketeerClient( config.bucketeerHost, config.bucketeerApiKey, ); // Prepare request const request: ListFeaturesRequest = { environmentId: getEnvironmentId(params.environmentId), pageSize: params.pageSize, cursor: params.cursor, tags: params.tags, orderBy: params.orderBy, orderDirection: params.orderDirection, searchKeyword: params.searchKeyword, maintainer: params.maintainer, archived: params.archived, }; // Make API call const response = await client.listFeatures(request); logger.info( `Successfully listed ${response.features.length} feature flags`, ); return { content: [ { type: "text", text: JSON.stringify( { success: true, features: response.features, cursor: response.cursor, totalCount: response.totalCount, }, null, 2, ), }, ], }; } catch (error) { logger.error("Failed to list feature flags", error); if (error instanceof z.ZodError) { return { content: [ { type: "text", text: JSON.stringify( { success: false, error: "Invalid input parameters", details: error.issues, }, null, 2, ), }, ], isError: true, }; } return { content: [ { type: "text", text: JSON.stringify( { success: false, error: error instanceof Error ? error.message : "Unknown error", }, null, 2, ), }, ], isError: true, }; }
- src/tools/list-flags.ts:8-18 (schema)Zod schema for validating the input parameters of the listFeatureFlags tool.export const listFlagsSchema = z.object({ environmentId: z.string().optional(), pageSize: z.number().min(1).max(100).optional().default(20), cursor: z.string().optional(), tags: z.array(z.string()).optional(), orderBy: z.enum(["CREATED_AT", "UPDATED_AT", "NAME"]).optional(), orderDirection: z.enum(["ASC", "DESC"]).optional(), searchKeyword: z.string().optional(), maintainer: z.string().optional(), archived: z.boolean().optional(), });
- src/tools/index.ts:1-13 (registration)Registers the listFlagsTool (listFeatureFlags) by importing and adding it to the exported tools array used by the MCP server.import { listFlagsTool } from "./list-flags.js"; import { createFlagTool } from "./create-flag.js"; import { getFlagTool } from "./get-flag.js"; import { updateFlagTool } from "./update-flag.js"; import { archiveFlagTool } from "./archive-flag.js"; export const tools = [ listFlagsTool, createFlagTool, getFlagTool, updateFlagTool, archiveFlagTool, ];
- src/server.ts:8-66 (registration)MCP server setup that imports the tools array and registers generic handlers for listing tools and executing tool handlers by name, including listFeatureFlags.import { tools } from "./tools/index.js"; export class BucketeerMCPServer { private server: Server; constructor() { this.server = new Server( { name: "bucketeer-mcp-server", version: "1.0.0", }, { capabilities: { tools: {}, }, }, ); this.setupHandlers(); this.setupErrorHandling(); } private setupHandlers() { // Handle list tools request this.server.setRequestHandler(ListToolsRequestSchema, async () => { logger.debug("Listing available tools"); return { tools: tools.map((tool) => ({ name: tool.name, description: tool.description, inputSchema: tool.inputSchema, })), }; }); // Handle tool calls this.server.setRequestHandler(CallToolRequestSchema, async (request) => { const { name, arguments: args } = request.params; logger.info(`Tool called: ${name}`, { arguments: args }); const tool = tools.find((t) => t.name === name); if (!tool) { logger.error(`Tool not found: ${name}`); throw new Error(`Tool not found: ${name}`); } try { const result = await tool.handler(args); logger.info(`Tool ${name} executed successfully`); return result; } catch (error) { logger.error(`Tool ${name} execution failed`, error); throw error; } }); }