feat(mcp): expose Elsa workflows as MCP tools - #209
Draft
RalfvandenBurg wants to merge 2 commits into
Draft
RalfvandenBurg wants to merge 2 commits into
RalfvandenBurg wants to merge 2 commits into
Conversation
Adds Elsa.Mcp.Server, which serves a workflow as a Model Context Protocol tool: the catalog turns every opted-in definition into a tool an agent can list and call, and a suspended instance can be resumed through the same tool by answering what it is waiting on. A workflow opts in through custom properties (mcp:enabled), and names itself through its own name rather than its definition id - an agent picking a tool by a generated hex string picks blind. Elsa.Mcp.Abstractions holds those names and rules on their own, so an editor that lets an author configure a workflow as a tool does not have to take the server with it. Resuming needs to know what a bookmark is waiting for, which is what Elsa.Bookmarks.Ui adds: each feature registers a provider for its own bookmark types, and the provider says what to show, what to ask before resuming, and whether the bookmark is answerable at all. Providers for Delay, Event and RunTask ship with it, plus a fallback. Elsa.Bookmarks.Ui.Domain carries the models and contracts free of any Elsa dependency, so a client that only reads a described bookmark - a Blazor host, a mobile app - can take that package without the engine. A unit test pins that split. Elsa.Bookmarks.Ui is useful on its own and can be split off into its own pull request if that reads better; Elsa.Mcp.Server does not compile without it, which is why it travels here. Note on Elsa.Extensions.sln: beyond the seven new projects, `dotnet sln add` dropped 48 configuration lines belonging to four GUIDs that have no Project entry in the solution. Those were already orphaned; nothing that builds today loses a configuration. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
Closes #210.
Related to #58, but the other direction: that issue is about Elsa agents consuming MCP tools from elsewhere, this is about Elsa exposing its own workflows as tools to any MCP client.
What this adds
Two things a workflow engine needs before an agent can drive it, in four packages.
Elsa.Mcp.Server+Elsa.Mcp.AbstractionsServes workflows as Model Context Protocol tools over the MCP HTTP transport.
mcp:enabled), and the catalog turns every opted-in definition into a tool an agent can list and call.^[a-zA-Z0-9_-]{1,64}$, accents folded rather than dropped, and a clash is disambiguated by appending the id.mcp:instructionsandmcp:input:<name>let an author write guidance a model needs and a person reading the designer does not.Elsa.Mcp.Abstractionsholds those names and rules on their own, with no dependencies, so an editor that lets an author configure a workflow as a tool does not have to take the server with it.Elsa.Bookmarks.Ui+Elsa.Bookmarks.Ui.DomainDescribes what a suspended workflow is waiting for, which is what the resume path needs to do anything better than pass raw JSON through.
IBookmarkUiProviderfor its own bookmark types; the provider says what to show, what to ask before resuming, and whether the bookmark is answerable at all. Providers forDelay,EventandRunTaskship with it, plus a fallback.Elsa.Bookmarks.Ui.Domaincarries the models and contracts free of any Elsa dependency, so a client that only reads a described bookmark — a Blazor host, a mobile app — can take that package without the engine.DomainPackageTestspins that split; one stray using silently undoes it and nothing else would notice.Layout
One new central package version:
ModelContextProtocol.AspNetCore1.3.0. Everything else resolves through the existing$(ElsaVersion)entries.On scope
This is arguably two concerns.
Elsa.Bookmarks.Uistands on its own and I am happy to split it into its own PR first and rebase this one on top —Elsa.Mcp.Serverdoes not compile without it, which is why the two travel together here. Say the word.Verification
All three test projects build and pass on
net10.0:Elsa.Mcp.Abstractions.UnitTestsElsa.Bookmarks.Ui.UnitTestsElsa.Mcp.Server.UnitTestsThe four source modules build clean across
net8.0,net9.0andnet10.0with no new compiler warnings.One thing to look at
Beyond the seven new projects,
dotnet sln adddropped 48 configuration lines fromElsa.Extensions.slnbelonging to four GUIDs that have noProjectentry in the solution. They were already orphaned, so nothing that builds today loses a configuration — but it is churn in this diff that is not mine, and I can restore it if you would rather keep the solution byte-identical apart from the additions.🤖 Generated with Claude Code