Sanity Library Reference Docs
    Preparing search index...

    One workflow tool, host-neutral. Hosts iterate WORKFLOW_TOOLS and register each def with their own glue (error wrapping, telemetry, result envelopes); registerWorkflowTools is the bundled convenience for hosts without opinions of their own.

    interface WorkflowToolDef {
        annotations: {
            destructiveHint?: boolean;
            idempotentHint?: boolean;
            openWorldHint?: boolean;
            readOnlyHint?: boolean;
            title?: string;
        };
        description: string;
        handler: (
            context: WorkflowToolContextThunk,
            input: unknown,
        ) => Promise<unknown>;
        inputSchema: ZodRawShape;
        name: string;
        requiresAddress: boolean;
    }
    Index

    Properties

    annotations: {
        destructiveHint?: boolean;
        idempotentHint?: boolean;
        openWorldHint?: boolean;
        readOnlyHint?: boolean;
        title?: string;
    }
    description: string
    handler: (context: WorkflowToolContextThunk, input: unknown) => Promise<unknown>

    Returns plain projected data (the Projected* shapes) — hosts own the serialisation into their transport's result envelope. Takes unknown and parses internally: a heterogeneous list of defs with typed handler inputs is unassignable under strictFunctionTypes, so the narrowing lives inside each handler instead.

    inputSchema: ZodRawShape

    Raw zod shape — the single schema source of truth: MCP servers register it directly; the runtime parser wraps it for parsing, and toolInputJsonSchema derives the JSON-schema descriptor for non-MCP consumers.

    name: string
    requiresAddress: boolean

    Whether this tool operates on a workflow environment, and so needs the engine it is handed to address the one the caller means. How a host satisfies that is its own choice: one that names an environment per call adds its own address parameters to this tool's schema, one that binds a single environment when it builds the engine adds nothing. false marks an engine-independent tool — there is no environment to name.