Skip to main content

Overview

import { WorkflowRegistry } from '@frontmcp/sdk';

// Access via scope
const workflows = scope.workflows;

// List all workflows
const allWorkflows = workflows.getWorkflows();

// Find a specific workflow
const wf = workflows.findByName('data-pipeline');

Methods

getWorkflows()

Get all workflows (local + dynamic).
getWorkflows(includeHidden?: boolean): WorkflowEntry[]
ParameterTypeDefaultDescription
includeHiddenbooleanfalseInclude hidden workflows in results
Example:
// Get all visible workflows
const workflows = registry.getWorkflows();

// Include hidden workflows
const allWorkflows = registry.getWorkflows(true);

findByName()

Find a workflow by its base name.
findByName(name: string): WorkflowEntry | undefined
Example:
const wf = registry.findByName('data-pipeline');
if (wf) {
  console.log(`Found: ${wf.name}, steps: ${wf.getSteps().length}`);
}

findById()

Find a workflow by its ID.
findById(id: string): WorkflowEntry | undefined
Search workflows by query, tags, or labels.
search(
  query?: string,
  opts?: { tags?: string[]; labels?: Record<string, string> }
): WorkflowEntry[]
Example:
// Search by name/description
const results = registry.search('pipeline');

// Filter by tags
const tagged = registry.search(undefined, { tags: ['etl'] });

registerDynamic()

Register a dynamic workflow at runtime.
registerDynamic(record: WorkflowDynamicRecord): void

removeDynamic()

Remove a dynamic workflow.
removeDynamic(workflowId: string): boolean
Returns: true if the workflow was found and removed, false otherwise.

subscribe()

Subscribe to workflow change events.
subscribe(
  opts: { immediate?: boolean },
  cb: (event: WorkflowChangeEvent) => void
): () => void
Returns: Unsubscribe function. Example:
const unsubscribe = registry.subscribe(
  { immediate: true },
  (event) => {
    console.log(`Workflow ${event.kind}:`, event.version);
  }
);

// Later: stop listening
unsubscribe();

hasAny()

Check if any workflows exist in the registry.
hasAny(): boolean

MCP Tools Registered

When the jobs & workflows system is enabled, workflow capabilities are exposed through these MCP tools:
ToolDescription
list-workflowsList all registered workflows with optional filtering
execute-workflowExecute a workflow by name (inline or background)
get-workflow-statusGet execution status with per-step results
register-workflowRegister a dynamic workflow at runtime
remove-workflowRemove a dynamic workflow

Change Events

The registry emits events when workflows are added, updated, or removed:
interface WorkflowChangeEvent {
  kind: 'added' | 'updated' | 'removed' | 'reset';
  changeScope: 'global' | 'session';
  version: number;
  snapshot: readonly WorkflowEntry[];
  sessionId?: string;
}

Lifecycle

buildMap()     → Extract tokens, definitions from metadata
buildGraph()   → Validate dependencies, populate graph
initialize()   → Create instances, register dynamic workflows