getFeatureFlag
Retrieve a specific feature flag by its ID from the Bucketeer MCP Server to check current status and configuration settings.
Instructions
Get a specific feature flag by ID
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | The ID of the feature flag to retrieve | |
| environmentId | No | Environment ID (uses default if not provided) | |
| featureVersion | No | Specific version of the feature to retrieve |
Implementation Reference
- src/tools/get-flag.ts:37-96 (handler)The handler function that executes the tool logic: validates input with Zod, creates BucketeerClient, fetches the feature flag via API, logs, and returns structured response or error.handler: async (input: unknown) => { try { // Validate input const params = getFlagSchema.parse(input); logger.debug('Getting feature flag', params); // Create API client const client = new BucketeerClient(config.bucketeerHost, config.bucketeerApiKey); // Prepare request const request: GetFeatureRequest = { id: params.id, environmentId: getEnvironmentId(params.environmentId), featureVersion: params.featureVersion, }; // Make API call const response = await client.getFeature(request); logger.info(`Successfully retrieved feature flag: ${response.feature.id}`); return { content: [{ type: 'text', text: JSON.stringify({ success: true, feature: response.feature, }, null, 2), }], }; } catch (error) { logger.error('Failed to get feature flag', error); if (error instanceof z.ZodError) { return { content: [{ type: 'text', text: JSON.stringify({ success: false, error: 'Invalid input parameters', details: error.errors, }, 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/get-flag.ts:19-36 (schema)JSON Schema defining the input parameters for the getFeatureFlag tool: id (required string), optional environmentId and featureVersion.inputSchema: { type: 'object' as const, properties: { id: { type: 'string', description: 'The ID of the feature flag to retrieve', }, environmentId: { type: 'string', description: 'Environment ID (uses default if not provided)', }, featureVersion: { type: 'number', description: 'Specific version of the feature to retrieve', }, }, required: ['id'], },
- src/tools/get-flag.ts:8-12 (schema)Zod schema for internal input validation in the getFeatureFlag handler.export const getFlagSchema = z.object({ id: z.string().min(1, 'Feature flag ID is required'), environmentId: z.string().optional(), featureVersion: z.number().optional(), });
- src/tools/index.ts:3-13 (registration)Registration of getFlagTool by importing it and adding to the central tools array used by the MCP server.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-65 (registration)MCP server request handlers for listing tools and calling tools, which use the imported tools array (including getFeatureFlag) to provide tool metadata and execute handlers.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; } });