replicate-flux-mcp
Version:
MCP for Replicate Flux Model
25 lines (24 loc) • 785 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,
});
await replicate.predictions.get(prediction.id);
const completed = await pollForCompletion(prediction.id);
return {
content: [
{
type: "text",
text: JSON.stringify(completed || "Processing timed out", null, 2),
},
],
};
}
catch (error) {
handleError(error);
}
};