feat(tasks): add task streaming with partial result notifications#2015
Open
morozow wants to merge 4 commits intomodelcontextprotocol:mainfrom
Open
feat(tasks): add task streaming with partial result notifications#2015morozow wants to merge 4 commits intomodelcontextprotocol:mainfrom
morozow wants to merge 4 commits intomodelcontextprotocol:mainfrom
Conversation
- Add task streaming support to client and server with `callToolStream` API - Implement `subscribeTaskPartials` for consuming partial result notifications - Add `TaskPartialNotificationParams` schema and validation for partial content blocks - Create example implementations demonstrating streaming text consumption - Add comprehensive test coverage for task partial notifications and streaming lifecycle - Enable clients to declare `tasks.streaming.partial` capability for server negotiation - Support wire-format task lifecycle: taskCreated → taskStatus (working) → partial notifications → result - Update package.json dependencies to support task streaming capabilities
🦋 Changeset detectedLatest commit: d581c0f The changes in this PR will be included in the next version bump. This PR includes changesets to release 7 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
@modelcontextprotocol/client
@modelcontextprotocol/server
@modelcontextprotocol/express
@modelcontextprotocol/fastify
@modelcontextprotocol/hono
@modelcontextprotocol/node
commit: |
- Add TaskPartialNotificationParamsSchema and TaskPartialNotificationSchema Zod schemas for partial result validation - Extend ServerTasksCapabilitySchema and ClientTasksCapabilitySchema with streaming.partial capability flag - Extend ToolExecutionSchema with optional streamPartial boolean for task configuration - Add hand-written conformance types in spec.types.ts for runtime validation - Implement ExperimentalMcpServerTasks.sendTaskPartial(taskId, content, seq) with Zod validation and capability gating - Implement ExperimentalMcpServerTasks.createPartialEmitter(taskId) for auto-incrementing seq in background work - Add automatic tasks.streaming.partial capability declaration when registerToolTask is called with streamPartial: true - Implement ExperimentalClientTasks.subscribeTaskPartials(taskId, handler) with seq-based ordering and duplicate detection - Enables servers to push incremental content chunks to clients during long-running task execution per SEP-0000
…ts-notifications' into sep/task-streaming-partial-results-notifications
9 tasks
|
Good job merge STOMDE |
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.
Reference implementation for SEP-2679 — Task Streaming via Partial Results for Long-Running Operations.
Referenced SEP: modelcontextprotocol/modelcontextprotocol#2679
Motivation
SEP-1686 (Tasks) introduced a "call-now, fetch-later" mechanism for long-running MCP operations but has no standard way to deliver incremental content during execution. This forces agent-to-agent calls to block for 10–30s with no feedback, degrades IDE streaming UX to a spinner, and adds polling overhead.
This PR implements
notifications/tasks/partial— a new JSON-RPC notification that enables servers to push incremental content chunks to clients while a task is in progress, extending the existing Tasks infrastructure without transport-level changes.Changes
Core package (
packages/core/)src/types/schemas.tsTaskPartialNotificationParamsSchema,TaskPartialNotificationSchema; extendedServerTasksCapabilitySchemaandClientTasksCapabilitySchemawithstreaming.partial; extendedToolExecutionSchemawithstreamPartial; added toServerNotificationSchemaunionsrc/types/types.tsTaskPartialNotificationParams,TaskPartialNotificationtypessrc/types/spec.types.tsServerCapabilities,ClientCapabilities,ToolExecution,ServerNotificationsrc/types/specTypeSchema.tstest/spec.types.test.tstest/types/taskPartialNotification.test.tsServer package (
packages/server/)src/experimental/tasks/mcpServer.tssendTaskPartial(taskId, content, seq)with Zod validation, terminal status check, capability gating;createPartialEmitter(taskId)with auto-incrementing seq; auto capability declaration inregisterToolTaskwhenstreamPartial: truetest/server/taskPartialNotification.test.tsClient package (
packages/client/)src/experimental/tasks/client.tssubscribeTaskPartials(taskId, handler)with cleanup function; notification handler fornotifications/tasks/partial; seq-based ordering, duplicate detection, gap warningtest/client/taskPartialNotification.test.tsIntegration tests (
test/integration/)test/experimental/tasks/taskPartialStreaming.test.tsExamples
examples/server/src/simpleTaskStreaming.tsexamples/client/src/simpleTaskStreamingClient.tsDesign Decisions
sendTaskPartialandcreatePartialEmitteronExperimentalMcpServerTasks— keeps experimental surface isolated, follows existingregisterToolTaskpatterncreatePartialEmitter(taskId)returns a standalone function — compatible with the fire-and-forgetToolTaskHandler.createTaskpattern where background work runs after the handler returns"partial": {}) — matches the existing pattern used bylist,cancel,requestsin task capabilitiessendTaskPartial— usesTaskPartialNotificationParamsSchema.safeParse()for consistent error messagessubscribeTaskPartialscall, resets on re-subscribeTest Results
Zero regressions against existing tests. Property-based tests run 100 iterations each via fast-check.
Checklist
pnpm build:all)AI Disclosure
This PR was developed with AI assistance (Claude via Kiro IDE). AI was used for codebase analysis, implementation of types/schemas/server/client APIs, and test generation. All architectural decisions (API placement, emitter pattern, capability format, seq ordering semantics) and protocol design were made by the human author.