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
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Maximum number of predictions to return |
Implementation Reference
- src/tools/predictionList.ts:6-36 (handler)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); } };
- src/tools/index.ts:57-62 (registration)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 );
- src/types/index.ts:117-127 (schema)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>;