import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import type { BirstClient } from "../../client/birstClient.js";
import { z } from "zod";
interface Workflow {
workflowId: string;
name: string;
description?: string;
enabled?: boolean;
restricted?: boolean;
createdByUsername?: string;
modifiedByUsername?: string;
modifiedByTimestamp?: string;
}
const inputSchema = z.object({
workflowId: z.string().describe("The ID of the workflow to get status for"),
});
export function registerGetWorkflowStatus(server: McpServer, client: BirstClient): void {
server.tool(
"birst_get_workflow_status",
"Get the current status and details of a specific workflow.",
inputSchema.shape,
async (args) => {
const { workflowId } = inputSchema.parse(args);
const workflow = await client.rest<Workflow>(`/workflows/${workflowId}`);
return {
content: [
{
type: "text" as const,
text: JSON.stringify(
{
success: true,
workflow: {
id: workflow.workflowId,
name: workflow.name,
description: workflow.description,
enabled: workflow.enabled,
restricted: workflow.restricted,
createdBy: workflow.createdByUsername,
modifiedBy: workflow.modifiedByUsername,
modifiedAt: workflow.modifiedByTimestamp,
},
},
null,
2
),
},
],
};
}
);
}