@ldavis9000aws/swarmui-generator
Version:
A Model Context Protocol server for SwarmUI image generation with TypeScript
60 lines • 2.92 kB
JavaScript
/**
* System Status MCP Tool
* * This file contains the MCP tool definition for retrieving SwarmUI system status.
*/
/**
* Input schema for the get_system_status tool.
*/
export const systemStatusSchema = {
description: 'Retrieves the current operational status of the SwarmUI image generation engine. This provides insights into its current activity and capacity, including details like the currently loaded model, whether the engine is actively generating, the current prompt (if generating), job queue length, generation progress percentage, estimated time remaining (ETA) for the current job, and running backends. This tool requires no parameters.',
type: 'object',
properties: {},
required: []
};
/**
* Handler for the get_system_status tool
*/
export async function systemStatusHandler(params, swarmui) {
try {
const status = await swarmui.getEngineStatus();
let resultText = 'SwarmUI System Status:\n';
resultText += '========================\n\n';
resultText += `Model Load State: ${status.ModelLoadState || 'Not specified / Idle'}\n`;
resultText += `Current Model Loaded: ${status.ModelName || 'None'}\n`;
resultText += `Currently Generating Image: ${status.IsGenerating !== undefined ? (status.IsGenerating ? 'Yes' : 'No') : 'Unknown'}\n`;
if (status.IsGenerating && status.CurrentPrompt) {
resultText += `Current Prompt Being Processed: "${status.CurrentPrompt}"\n`;
}
if (status.IsGenerating && status.Progress !== undefined) {
resultText += `Current Job Progress: ${Math.round(status.Progress * 100)}%\n`;
}
if (status.IsGenerating && status.ETA !== undefined) {
resultText += `Estimated Time Remaining (ETA) for Current Job: ${status.ETA} seconds\n`;
}
resultText += `Jobs in Queue: ${status.QueueLength !== undefined ? status.QueueLength : 'Unknown'}\n`;
resultText += `Running Backend Services: ${(status.RunningBackends && status.RunningBackends.length > 0) ? status.RunningBackends.join(", ") : 'None reported or not specified'}\n`;
return {
content: [{
type: 'text',
text: resultText.trim()
}],
_meta: {
modelLoadState: status.ModelLoadState,
modelName: status.ModelName,
isGenerating: status.IsGenerating,
queueLength: status.QueueLength
}
};
}
catch (error) {
return {
content: [{
type: 'text',
text: `Error getting system status: ${error instanceof Error ? error.message : String(error)}`
}],
isError: true,
_meta: { error: error instanceof Error ? error.message : String(error) }
};
}
}
//# sourceMappingURL=system-status.js.map