replicate-flux-mcp
Version:
MCP for Replicate Flux Model
24 lines (23 loc) • 736 B
JavaScript
import { pollForCompletion, replicate } from "../services/replicate.js";
import { handleError } from "../utils/error.js";
import { CONFIG } from "../config/index.js";
export const registerCreatePredictionTool = async (input) => {
try {
const prediction = await replicate.predictions.create({
model: CONFIG.imageModelId,
input,
});
const completed = await pollForCompletion(prediction.id);
return {
content: [
{
type: "text",
text: JSON.stringify(completed || "Processing timed out", null, 2),
},
],
};
}
catch (error) {
return handleError(error);
}
};