Skip to content

feat(mcp): add in process work item stream for internal mcp wf routing#83

Open
sicoyle wants to merge 5 commits intodapr:mainfrom
sicoyle:feat/mcp-executor
Open

feat(mcp): add in process work item stream for internal mcp wf routing#83
sicoyle wants to merge 5 commits intodapr:mainfrom
sicoyle:feat/mcp-executor

Conversation

@sicoyle
Copy link
Copy Markdown

@sicoyle sicoyle commented Apr 14, 2026

Dapr's MCP Server integration registers built-in dapr.mcp.* orchestrations and dapr-mcp-* activities that run inside the sidecar. Initially I tried using a parallel task.TaskExecutor behind a RoutingExecutor wrapper, but that ended up being a completely separate execution path from the normal gRPC-backed engine. That meant that at first, internal MCP workflows couldn't use the standard TaskHubWorker lifecycle, queue-backed parallelism, or backend-driven retries.

With this PR, Dapr can register an InProcessClient as a sink for dapr.mcp.* prefixed names. The gRPC executor routes matching work items to the sink while everything else flows to the external SDK unchanged. One engine, one backend, two delivery paths - internal workflows are authored identically to SDK workflows.

CHanges:

  • Adds WorkItemSink / SinkRegistrar interfaces on grpcExecutor to route work items to in-process consumers by workflow-name and activity-name prefix, bypassing the gRPC stream
  • Adds client.InProcessClient — an in-process WorkItemSink implementation that mirrors TaskHubGrpcClient using a shared dispatcher.go for execute+response logic
  • Extracts shared dispatchWorkflow / dispatchActivity helpers from the duplicated code in worker_grpc.go and worker_inprocess.go
  • Sinks are closed before the gRPC work-item queue during Shutdown

Signed-off-by: Samantha Coyle <sam@diagrid.io>
@sicoyle sicoyle requested a review from a team as a code owner April 14, 2026 20:04
Copilot AI review requested due to automatic review settings April 14, 2026 20:04
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds an in-process work-item routing path to the existing gRPC-backed executor so internal dapr.mcp.* workflows/activities can be delivered to in-process consumers while all other work items continue to flow over the external SDK gRPC stream.

Changes:

  • Introduces backend.WorkItemSink and backend.SinkRegistrar to register sinks by workflow/activity name prefix and route matching work items in-process.
  • Adds client.InProcessClient as an in-process sink implementation and factors shared workflow/activity dispatch logic into client/dispatcher.go.
  • Adds tests validating sink registration, routing behavior, and shutdown sink closing.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
backend/executor.go Adds sink registration APIs, prefix matching, routing logic in ExecuteWorkflow/ExecuteActivity, and closes sinks first during Shutdown.
client/worker_inprocess.go Adds an in-process worker/sink that drains work items from an internal channel and completes tasks via the backend.
client/worker_grpc.go Refactors workflow/activity processing to use shared dispatch helpers.
client/dispatcher.go Centralizes workflow/activity execution + response construction shared by gRPC and in-process workers.
tests/sink_test.go Adds unit tests covering sink registrar validation, routing, and shutdown close behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread client/worker_inprocess.go Outdated
Comment thread backend/executor.go Outdated
Comment thread backend/executor.go Outdated
Comment thread backend/executor.go Outdated
Signed-off-by: Samantha Coyle <sam@diagrid.io>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/sink_test.go Outdated
Comment thread client/worker_inprocess.go Outdated
Comment thread client/worker_inprocess.go Outdated
Comment thread backend/executor.go Outdated
Comment thread backend/executor.go Outdated
Comment thread backend/executor.go Outdated
Signed-off-by: Samantha Coyle <sam@diagrid.io>
Comment thread backend/executor.go Outdated
Comment thread backend/executor.go Outdated
Comment thread backend/executor.go Outdated
Comment thread backend/executor.go Outdated
Comment thread backend/executor.go
Comment thread backend/executor.go Outdated
Comment thread client/worker_inprocess.go Outdated
Comment thread client/worker_inprocess.go Outdated
Signed-off-by: Samantha Coyle <sam@diagrid.io>
Signed-off-by: Samantha Coyle <sam@diagrid.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants