feat(mcp): stream workflow task status (ENG-161)#309
Merged
betterclever merged 5 commits intomainfrom Feb 21, 2026
Merged
Conversation
067642e to
557918a
Compare
…atus to chat Signed-off-by: betterclever <paliwal.pranjal83@gmail.com>
9774062 to
6c2bc67
Compare
storeTaskResult refuses to update a task already in a terminal state. Previously, updateTaskStatus was called first (setting the task to 'completed'/'failed'), then storeTaskResult would throw with an internal error, causing the client to receive a -32603 McpError. Fix: skip updateTaskStatus for terminal workflow states and let storeTaskResult perform the terminal status transition itself. Only call updateTaskStatus for non-terminal (working) states. Signed-off-by: betterclever <paliwal.pranjal83@gmail.com>
…ty response The AI agent test was producing an empty text response because the prompt didn't explicitly request a textual summary. Updated the prompt to ask for a summary of the final output message so the agent always returns a non-empty response. Signed-off-by: betterclever <paliwal.pranjal83@gmail.com>
Adds a new E2E test that validates the full MCP task lifecycle via StreamableHTTPClientTransport: - Connects to /studio-mcp with API key auth - Calls run_workflow using the experimental callToolStream API - Asserts taskCreated, taskStatus, and result messages are received - Verifies the result contains workflow output and no errors Also removes the scratch test-mcp-server.ts file used for local debugging during development. Signed-off-by: betterclever <paliwal.pranjal83@gmail.com>
updateTaskStatus is no longer called for terminal states (COMPLETED/ FAILED/CANCELLED) — storeTaskResult handles the terminal transition. Update unit test expectations to reflect this behaviour. Signed-off-by: betterclever <paliwal.pranjal83@gmail.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.
Overview
Migrates `run_workflow` from simple fire-and-poll to a native MCP Task — meaning AI agents now receive real-time streaming status updates as the workflow progresses, instead of blocking on a final result.
What Changed
`StudioMcpService` — task-augmented execution
Key bug fixed in this PR
The initial implementation had a double terminal-state bug: `updateTaskStatus` was called first (setting the task status to `completed`), then `storeTaskResult` threw an internal error because the SDK refuses to overwrite a task already in a terminal state. Fixed by skipping `updateTaskStatus` for terminal run states and letting `storeTaskResult` perform the transition itself.
Stream Message Sequence
```
taskCreated → { taskId, status: "working" }
taskStatus → { status: "working", statusMessage: "RUNNING" }
...
taskStatus → { status: "completed", statusMessage: "COMPLETED" }
result → { content: [{ type: "text", text: "{ outputs: ... }" }] }
```
Testing
The new E2E test (`studio-mcp-tasks.test.ts`) connects directly via `StreamableHTTPClientTransport`, calls `run_workflow` using `client.experimental.tasks.callToolStream()`, and asserts the full `taskCreated → taskStatus → result` sequence is received correctly.
Linear
Closes ENG-161