Skip to main content
Glama
awkoy

replicate-flux-mcp

prediction_list

Retrieve a list of recent predictions generated by the Replicate Flux Model, using configurable limits to manage output scope.

Instructions

Get a list of recent predictions from Replicate

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoMaximum number of predictions to return

Implementation Reference

  • The main handler function for the 'prediction_list' tool. It fetches a paginated list of predictions from the Replicate service, limits the results based on the input 'limit' parameter, and returns a formatted text response with the count and JSON-serialized predictions.
    export const registerPredictionListTool = async ({
      limit,
    }: PredictionListParams): Promise<CallToolResult> => {
      try {
        const predictions = [];
        for await (const page of replicate.paginate(replicate.predictions.list)) {
          predictions.push(...page);
          if (predictions.length >= limit) {
            break;
          }
        }
    
        const limitedPredictions = predictions.slice(0, limit);
        const totalPages = Math.ceil(predictions.length / limit);
    
        return {
          content: [
            {
              type: "text",
              text: `Found ${limitedPredictions.length} predictions (showing ${limitedPredictions.length} of ${predictions.length} total, page 1 of ${totalPages})`,
            },
            {
              type: "text",
              text: JSON.stringify(limitedPredictions, null, 2),
            },
          ],
        };
      } catch (error) {
        handleError(error);
      }
    };
  • Registration of the 'prediction_list' tool on the MCP server using server.tool(), specifying name, description, schema, and handler.
    server.tool(
      "prediction_list",
      "Get a list of recent predictions from Replicate",
      predictionListSchema,
      registerPredictionListTool
    );
  • Zod schema definition for the 'prediction_list' tool's input parameters, specifically the 'limit' field with validation and description.
    export const predictionListSchema = {
      limit: z
        .number()
        .int()
        .min(1)
        .max(100)
        .default(50)
        .describe("Maximum number of predictions to return"),
    };
    const predictionListObjectSchema = z.object(predictionListSchema);
    export type PredictionListParams = z.infer<typeof predictionListObjectSchema>;

Tool Definition Quality

Score is being calculated. Check back soon.

Install Server

Other Tools

Related Tools

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/awkoy/replicate-flux-mcp'

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