Skip to main content
Glama
flipt-io

Flipt MCP Server

Official
by flipt-io

evaluate_batch

Process multiple feature flag evaluations in a single request, optimizing decision-making workflows for AI assistants and LLMs through the Flipt MCP Server.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
requestsYes

Implementation Reference

  • MCP tool handler function that calls FliptClient.evaluateBatch with the input requests, formats the JSON response, and handles errors.
    async args => {
      try {
        const response = await fliptClient.evaluateBatch(args.requests);
    
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify(response, null, 2),
            },
          ],
        };
      } catch (error: any) {
        console.error('Error evaluating batch:', error);
        return {
          content: [
            {
              type: 'text',
              text: `Failed to evaluate batch: ${error.message}`,
            },
          ],
          isError: true,
        };
      }
    }
  • Zod schema defining the input for the evaluate_batch tool: an array of requests each with namespaceKey, flagKey, entityId, and optional context.
    {
      requests: z.array(
        z.object({
          namespaceKey: z.string().min(1),
          flagKey: z.string().min(1),
          entityId: z.string().min(1),
          context: z.record(z.string()).optional(),
        })
      ),
    },
  • src/index.ts:718-754 (registration)
    Registration of the 'evaluate_batch' MCP tool on the server using server.tool(name, schema, handler).
      'evaluate_batch',
      {
        requests: z.array(
          z.object({
            namespaceKey: z.string().min(1),
            flagKey: z.string().min(1),
            entityId: z.string().min(1),
            context: z.record(z.string()).optional(),
          })
        ),
      },
      async args => {
        try {
          const response = await fliptClient.evaluateBatch(args.requests);
    
          return {
            content: [
              {
                type: 'text',
                text: JSON.stringify(response, null, 2),
              },
            ],
          };
        } catch (error: any) {
          console.error('Error evaluating batch:', error);
          return {
            content: [
              {
                type: 'text',
                text: `Failed to evaluate batch: ${error.message}`,
              },
            ],
            isError: true,
          };
        }
      }
    );
  • FliptClient helper method that maps the requests to API format and calls the generated evaluationApi.evaluateBatch.
    async evaluateBatch(
      requests: Array<{
        namespaceKey: string;
        flagKey: string;
        entityId: string;
        context?: Record<string, string>;
      }>
    ) {
      try {
        const response = await this.evaluationApi.evaluateBatch({
          requests: requests.map(req => ({
            namespaceKey: req.namespaceKey,
            flagKey: req.flagKey,
            entityId: req.entityId,
            context: req.context || {},
          })),
        });
        return response;
      } catch (error) {
        console.error('Error evaluating batch:', error);
        throw error;
      }
    }

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/flipt-io/mcp-server-flipt'

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