Repository navigation
feat(mcp): build complete workflows through the MCP server - #518
Merged
Merged
Conversation
Extend the workflow tools from useplunk#497 to the whole graph: every step type (WAIT_FOR_EVENT, yes/no and multi-branch CONDITION, UPDATE_CONTACT, WEBHOOK, EXIT), placement after a step or branch or between two steps, connecting and disconnecting steps, editing and deleting steps, and updating, duplicating and deleting workflows. Add plunk_check_workflow, which outlines a workflow in walk order and lists what would fail at run time, and refuse to enable a workflow while it reports errors. Step settings are validated against the executor's schemas before they are saved, since the API stores them unvalidated. Steps are now connected explicitly instead of through addStep's autoConnect, which can link from an EXIT step or without a branch from a CONDITION. Deleting a step states what happens below it, because the plain step DELETE cascades. Also add plunk_list_workflow_fields, plunk_get_workflow_execution, plunk_start_workflow_execution and plunk_cancel_workflow_executions.
driaug
approved these changes
Oct 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Follow-up to #497. The MCP workflow tools could build a linear
SEND_EMAIL/DELAYsequence; conditions, waits, contact updates, webhooks and exits had to be added in the dashboard builder. This covers the rest of the graph through the existing/workflowsAPI, so an agent can build and maintain a branching workflow end to end. No API changes.New read-only tools
plunk_check_workflowGET /workflows/:id; a numbered outline in walk order plus the problems listed belowplunk_list_workflow_fieldsGET /workflows/fieldsplunk_get_workflow_executionGET /workflows/:id/executions/:executionIdNew writing tools
plunk_add_workflow_stepsafter/branchplunk_update_workflow_stepPATCH /workflows/:id/steps/:stepId, overlaying only the arguments passedplunk_delete_workflow_stepDELETE /workflows/:id/steps/:stepId, seedownstreambelowplunk_connect_workflow_stepsPOST /workflows/:id/transitionsplunk_disconnect_workflow_stepsDELETE /workflows/:id/transitions/:transitionIdplunk_update_workflowPATCH /workflows/:id(name, description,triggerConfig.eventName,allowReentry)plunk_duplicate_workflowPOST /workflows/:id/duplicate, optionally renaming / re-triggering the copyplunk_delete_workflowDELETE /workflows/:id, disabled workflows onlyplunk_start_workflow_executionPOST /workflows/:id/executions, by contact ID or emailplunk_cancel_workflow_executionsDELETE .../executions/:executionIdorPOST .../executions/cancel-allplunk_add_workflow_stepnow takes every step type (WAIT_FOR_EVENT,CONDITIONyes/no and multi-branch,UPDATE_CONTACT,WEBHOOK,EXIT), placed withafter+branch. If that position already leads to a step, the new one goes in between viainsert-step.Notes
POST/PATCH .../stepsstoreconfigas-is and only the executor parses it, so a bad config surfaces as aFAILEDexecution for a real contact. Arguments are checked against a copy ofWorkflowStepConfigSchemas(the package is published standalone, so it does not import@plunk/shared), plus the dashboard's rule that comparison operators need a value, plus the pathsresolveFieldcan reach (contact.email,contact.subscribed,data.*/contact.data.*,event.*,workflow.*). Any other field always resolves toundefined.DELETEremoves everything reachable from the step, sodownstreamisreconnect(default,?splice=true),detach(drops the step's outgoing transitions first, then the step) ordelete(the cascade, listing every step it removes). A CONDITION with steps below it requiresdetachordelete.continueOn) needs the downstream path moved off theyesbranch the API attaches, which takes two more calls; that is refused while the workflow is enabled.plunk_update_workflow_steprefuses to drop a condition branch that still has a transition.plunk_cancel_workflow_executionsrefuses executions that are notRUNNINGorWAITING.resolveContactincontacts.tsis exported forplunk_start_workflow_execution. README,mcp-server.mdxand the server instructions are updated.Changes to the #497 tools
plunk_add_workflow_stepcreates the step withautoConnect: falseand then the transition, removing the step again if the transition is rejected.addStep'sautoConnectlinks from the most recent step with no outgoing transition, which can be anEXITstep or aCONDITION(giving a branch-less transition that is followed for every contact). Withoutafter, the step goes after the single step that leads nowhere; if there are several, the tool lists the open positions instead of guessing.autoConnect: falsebehaves as before, and the default step names (Send email,Wait N days) are unchanged.plunk_set_workflow_enabledrefuses to enable whileplunk_check_workflowreports errors: invalid configs,SEND_EMAILwithout a template, transitions on branches the condition does not produce, or more than one exit from a non-condition step. Warnings (steps unreachable from the trigger) do not block.plunk_get_workflowprepends the outline to its summary; the JSON payload is unchanged.Observed in the API, not changed here
cancelExecutiondoes not check the current status, so cancelling a finished execution overwrites its outcome (the tool guards against it).WAIT_FOR_EVENTkeeps its step executionWAITING, sohandleEvent/processTimeoutresume it. The cancel tool's description says so.Happy to open issues or follow-up PRs for either.
Type of Change
feat:New feature (MINOR version bump)Testing
apps/mcp/src/__tests__/workflow-builder.test.tsdrives the tools through a real MCP client against an in-memory fake of the/workflowsroutes. The fake keeps steps and transitions and appliescreateTransition's rules (one exit per non-condition step, one transition per branch, no loops, nothing out ofEXIT) anddeleteStep's cascade, so assertions are on the resulting graph. The rollback, detach, confirmation, cancel and live-insert guards were each checked by disabling them and seeing their test fail.workflows.test.tsandserver.test.tsare updated for the new tools, destructive annotations and fixtures with valid configs.vitest run --project mcp: 90 passed.eslint .andtsc --noEmitinapps/mcp: clean.UPDATE_CONTACT,DELAY,SEND_EMAIL,WAIT_FOR_EVENT,WEBHOOKandEXITin oneplunk_add_workflow_stepscall; inserted a step mid-flow; edited a delay; deleted a leaf (reconnect) and detached a condition; checked the result; deleted the workflow.Checklist
Related Issues
Follow-up to #497.